private void ProcessAchievement(Player player, IAchievement achievement)
        {
            var currentPlayerAchievement = player.PlayerAchievements.FirstOrDefault(pa => pa.AchievementId == achievement.Id);

            if (currentPlayerAchievement == null ||
                (int)(currentPlayerAchievement.AchievementLevel) <
                (int)achievement.LevelThresholds.OrderByDescending(al => al.Key).First().Key)
            {
                var achievementAwarded = achievement.IsAwardedForThisPlayer(player.Id);

                if (achievementAwarded.LevelAwarded.HasValue &&
                    achievementAwarded.LevelAwarded.Value > AchievementLevel.None)
                {
                    CreateOrUpdateAchievement(player, achievement, currentPlayerAchievement, achievementAwarded);
                }
                DataContext.CommitAllChanges();
            }
        }
Exemplo n.º 2
0
        private void ProcessAchievementForPlayer(Player player, IAchievement achievement)
        {
            if (player.PlayerAchievements == null)
            {
                return;
            }

            var currentPlayerAchievement = player.PlayerAchievements.FirstOrDefault(pa => pa.AchievementId == achievement.Id);

            if (currentPlayerAchievement == null ||
                (int)currentPlayerAchievement.AchievementLevel <
                (int)achievement.LevelThresholds.OrderByDescending(al => al.Key).First().Key)
            {
                var achievementAwarded = achievement.IsAwardedForThisPlayer(player.Id);

                if (achievementAwarded.LevelAwarded.HasValue &&
                    achievementAwarded.LevelAwarded.Value > AchievementLevel.None)
                {
                    CreateOrUpdateAchievement(player, achievement, currentPlayerAchievement, achievementAwarded);
                }
            }
        }