public ActionResult Create(String id)
        {
            PlayerAchievement playerArchivement = new PlayerAchievement();

            playerArchivement.PlayerID = id;
            ViewBag.AchievementName    = new SelectList(_achievementRepository.GetAchievements(), "Name", "Name");

            return(View(playerArchivement));
        }
Beispiel #2
0
        private void ReloadViewModel()
        {
            AchievementsOrdered.Clear();

            var achievements = Enumerable.Empty <Achievement>();

            if (achievementRepository != null)
            {
                achievements = achievementRepository.GetAchievements();
            }

            foreach (var category in achievements.AsCategories())
            {
                var sortedAchievements = category.Achievements
                                         .Where(a => IsUnlocked(achievements, a))
                                         .OrderByDescending(a => a.IsCompleted)
                                         .ThenByDescending(a => a.DateCompleted)
                                         .ThenBy(a => a.Name);

                AchievementsOrdered.Add(new AchievementsPerCategory(sortedAchievements)
                {
                    CategoryName = category.CategoryName,
                });
            }
        }
Beispiel #3
0
        public IEnumerable <Achievement> PerformStaticAnalysis(StaticAnalysisManifest staticAnalysisManifest, bool onlyUnlockable)
        {
            IEnumerable <Achievement> unlockedAchievements = Enumerable.Empty <Achievement>();

            using (var statisAnalysisSession = new StatisAnalysisSession(staticAnalysisManifest))
            {
                OnStaticAnalysisStarted(this, new EventArgs());
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                var allAchievements = onlyUnlockable
                                    ? AchievementRepository.GetUnlockableAchievements()
                                    : AchievementRepository.GetAchievements();

                var availableStaticAnalysisAchievements = allAchievements.Where
                                                          (
                    a => typeof(StaticAnalysisAchievementBase).IsAssignableFrom(a.AchievementType)
                                                          ).ToList();

                unlockedAchievements = GetUnlockedAchievements
                                       (
                    statisAnalysisSession, availableStaticAnalysisAchievements
                                       ).ToList();

                stopwatch.Stop();
                OnStaticAnalysisCompleted(this, new StaticAnalysisEventArgs
                {
                    AchievementsTested  = availableStaticAnalysisAchievements.Count,
                    ElapsedMilliseconds = (int)stopwatch.ElapsedMilliseconds
                });
            }

            if (unlockedAchievements.Any())
            {
                foreach (var completedAchievement in unlockedAchievements)
                {
                    AchievementRepository.MarkAchievementAsCompleted(completedAchievement);
                }

                OnAchievementsUnlocked(this, new AchievementEventArgs
                {
                    UnlockedAchievements = unlockedAchievements
                });
            }

            return(unlockedAchievements);
        }
 public ActionResult Index()
 {
     return(View(_repository.GetAchievements()));
 }
Beispiel #5
0
 public List <Achievement> GetAchievements()
 {
     return(_achievementRepository.GetAchievements());
 }
 public void GetAchievementIds()
 {
     AssertIds <List <string> >(repository.GetAchievements());
 }