public void AddChallenge(Challenge challenge) {
            if (Challenges.Any(c => c.Date.Date == DateTime.Today))
                throw new ArgumentException("A challenge has already been chosen for today.");

            Challenges.Add(challenge);
            challenge.Name = $"Challenge {Challenges.Count}";

            if (Challenges.Count == 1)
                StartedAt = DateTime.Now;
        }
        public void AddChallenge(Challenge challenge) {
            if (Challenges.Any(c => (c.TimeToAccept > 0 && c.Done == false)))
                throw new ArgumentException("A challenge has already been chosen for today.");

            Challenges.Add(challenge);
            challenge.Name = $"Challenge {Challenges.Count}";

            if (Challenges.Count == 1)
                StartedAt = DateTime.Now;
            BadgeSigner.Instance.RewardBadges(this, challenge);
        }
 private void FillGeneralData(Challenge challenge, ChallengeViewModel data)
 {
     challenge.Date = DateTime.Now;
     challenge.Done = false;
     challenge.Type = data.Type;
     if (data.Type.Contains(".")) {
         string[] parts = data.Type.Split('.');
         challenge.Type = parts[0];
         data.Type = parts[1];
     }
 }
        public Badge GenerateNewBadge(ApplicationUser user, Challenge currentChallenge)
        {
            if (user.Challenges.Count == 1 && currentChallenge.Done == false)
                return new Badge() {
                    Name = "starter",
                    Description = "You requested your first challenge!"
                };

            return null;
        }
 public Badge GenerateNewBadge(ApplicationUser user, Challenge currentChallenge)
 {
     //  throw new NotImplementedException();
     return null;
 }
 public void ChangeBadge(Badge badge, ApplicationUser user, Challenge currentChallenge)
 {
     if (user.Points >= 50)
         badge.Name = "level6";
 }
 public Badge GenerateNewBadge(ApplicationUser user, Challenge currentChallenge)
 {
     var levels = new string[] { "level1", "level2", "level3", "level4", "level5", "level6" };
     foreach (var level in levels)
         if (user.HasBadge(level))
             return null;
     if (user.Points == 0)
         return new Badge() { Name = "level1", Description = "Level one reached." };
     return null;
 }
 public Badge GenerateNewBadge(ApplicationUser user, Challenge currentChallenge)
 {
     //  throw new NotImplementedException();
     if (user.Challenges.Count(c => c is RestaurantChallenge) == 1 && currentChallenge is RestaurantChallenge && currentChallenge.Done)
         return new Badge() { Name = "genieter", Description = "      " };
     return null;
 }
 public Badge GenerateNewBadge(ApplicationUser user, Challenge currentChallenge)
 {
     //  throw new NotImplementedException();
     return(null);
 }
 public Badge GenerateNewBadge(ApplicationUser user, Challenge currentChallenge)
 {
     if (user.Challenges.Count(c => c.Done) >= 10)
         return new Badge() { Name = "trotsegebruiker", Description = "    " };
     return null;
 }
 public Badge GenerateNewBadge(ApplicationUser user, Challenge currentChallenge)
 {
     if (user.Challenges.Count(c => c.Done) == 21)
         return new Badge() {
             Name = "doorzetter",
             Description = "  "
         };
     return null;
 }
 public Badge GenerateNewBadge(ApplicationUser user, Challenge currentChallenge)
 {
     //  throw new NotImplementedException();
     if (user.Challenges.Count(c => c is CreativeCookingChallenge && c.Done) == 1 && currentChallenge is CreativeCookingChallenge && currentChallenge.Done)
         return new Badge() { Name = "creatieveling", Description = "            " };
     return null;
 }
        public void RewardBadges(ApplicationUser user, Challenge current)
        {
            foreach (var kv in _rewarders) {

                if (user.HasBadge(kv.Key))
                    kv.Value.ChangeBadge(user.GiveBadge(kv.Key), user, current);
                else {
                    var newBadge = kv.Value.GenerateNewBadge(user, current);
                    if (newBadge != null)
                        user.Badges.Add(newBadge);
                }
            }
        }
 /// <summary>
 /// Fill the challenge with challengespecific data.
 /// </summary>
 /// <param name="challenge">The object to be filled.</param>
 /// <param name="context">Context where you can get data.</param>
 protected abstract void FillSpecificData(Challenge challenge, RestContext context, ChallengeViewModel data);
 public void ChangeBadge(Badge badge, ApplicationUser user, Challenge currentChallenge)
 {
 }
 public Badge GenerateNewBadge(ApplicationUser user, Challenge currentChallenge)
 {
     //  throw new NotImplementedException();
     if (user.Challenges.Count(c => c is TextChallenge && c.Done && c.Type.Equals("Suikervrij")) == 1 && currentChallenge is TextChallenge && currentChallenge.Done && currentChallenge.Type.Equals("Suikervrij"))
         return new Badge() { Name = "sugarrush", Description = "            " };
     return null;
 }
 public void HasDoneChallenge(Challenge challenge) {
     if (challenge.Date.Date != DateTime.Today)
         throw new ArgumentException("You cannot do a challenge that is from the past.");
     challenge.Done = true;
     Points += challenge.Earnings;
 }
 public void ChangeBadge(Badge badge, ApplicationUser user, Challenge currentChallenge)
 {
 }
 public void HasDoneChallenge(Challenge challenge) {
     if (challenge.TimeToAccept < 0)
         throw new ArgumentException("You cannot do a challenge that is from the past.");
     challenge.Done = true;
     Points += challenge.Earnings;
     BadgeSigner.Instance.RewardBadges(this, challenge);
 }
 public Badge GenerateNewBadge(ApplicationUser user, Challenge currentChallenge)
 {
     //  throw new NotImplementedException();
     if (user.Challenges.Count(c => c is RecipeChallenge && c.Done && (c as RecipeChallenge).Recipe.Properties.Count(p => p.Type.Equals("Regio")) >= 1) == 1 && currentChallenge is RestaurantChallenge && currentChallenge.Done)
         return new Badge() { Name = "explorer", Description = "            " };
     return null;
 }
Example #21
0
 public void DeleteChallenge(Challenge challenge)
 {
     Challenges.Remove(challenge);
 }
 public void DeleteChallenge(Challenge challenge) {
     Challenges.Remove(challenge);
 }
 public Badge GenerateNewBadge(ApplicationUser user, Challenge currentChallenge)
 {
     //  throw new NotImplementedException();
     if (user.Challenges.Count(c => c is RecipeChallenge && c.Done && (c as RecipeChallenge).PrepareFor != TargetSubject.Self) == 1 && currentChallenge is RecipeChallenge && currentChallenge.Done && (currentChallenge as RecipeChallenge).PrepareFor != TargetSubject.Self)
         return new Badge() { Name = "gastheer", Description = "            " };
     return null;
 }