コード例 #1
0
        public void completeActivity()
        {
            view.createActivityPopUp();

            if (currentChallenge != null)
            {
                var currentChallengeString = user.CurrentChallenge.Challenge.Name;
            }

            var listWithNotification = user.CompleteCurrentActivity(Grade, Comment);

            if (user.ChallengeCompleted())              //If challenge if completed
            {
                listWithNotification.Add(new Notification("Challenge Completed!", "Congratulations, you completed the challenge: " + user.CurrentChallenge.Challenge.Name + "!"));
                DropChallenge();
                view.ShowChallengesDisplayed();
                view.HideActivitiesForChallenge();
                view.updateChallengeList(user.ActiveChallenges());
            }

            view.AddAndRemoveCompletedTrophies(user.trophiesEarned);
            UpdateTotalPoints();

            if (listWithNotification.Count > 0)
            {
                foreach (Notification n in listWithNotification)
                {
                    if (n.Title == "Challenge Completed!")
                    {
                        view.createChallengePopUp();
                    }
                    else if (n.Title == "Trophy Earned!")
                    {
                        view.createTrophyPopUp();
                        UpdateTrophies();
                    }
                }
            }

            if (user.CurrentChallenge != null)
            {
                List <Activity> activitysLeft = ChallengeActivitiesLeftInCurrentChallenge();
                Debug.WriteLine("Activities left in challenge: ");
                foreach (Activity activity in activitysLeft)
                {
                    Debug.WriteLine(activity.Name);
                }
                view.UpdateActivityForChallengeList(activitysLeft);
            }
        }
コード例 #2
0
ファイル: UserTestSuite.cs プロジェクト: Benngard/Halso-Hub
        public void TestCompleteCurrentActivity()
        {
            string UserName = "******";
            User User = new User(UserName);
            List<MoodType> CuresMoods = new List<MoodType>();
            CuresMoods.Add(MoodType.Sad);
            Activity Activity = new Activity("test", "Check this out", 8, 25, CuresMoods);

            User.SetCurrentActivity(Activity);
            Assert.AreEqual(0, User.CompleteCurrentActivity(ActivityGrade.Good, "Like!").Count);
        }