BusinessLogic.Logic.Achievements.MechanicalPurveyorAchievement.IsAwardedForThisPlayer C# (CSharp) Метод

IsAwardedForThisPlayer() публичный Метод

public IsAwardedForThisPlayer ( int playerId ) : AchievementAwarded
playerId int
Результат AchievementAwarded
        public override AchievementAwarded IsAwardedForThisPlayer(int playerId)
        {
            var result = new AchievementAwarded
            {
                AchievementId = Id
            };

            var allPlayedGamesWithMechanics =
                DataContext
                    .GetQueryable<PlayerGameResult>()
                    .Where(x => x.PlayerId == playerId)
                    .Select(x => x.PlayedGame.GameDefinition.BoardGameGeekGameDefinition.Mechanics)
                    .Where(y => y.Count != 0)
                    .ToList();

            // Brute forced, could not figure out LINQ query for this. Probably needs cleaning up.
            List<string> finalMechanicList = new List<string>();
            foreach (var subList in allPlayedGamesWithMechanics)
            {
                foreach (var subSubList in subList)
                {
                    finalMechanicList.Add(subSubList.MechanicName);
                }
            }

            result.PlayerProgress = finalMechanicList.Distinct().Count();
            //result.RelatedEntities = allPlayedCategories.ToList();

            if (result.PlayerProgress < LevelThresholds[AchievementLevel.Bronze])
            {
                return result;
            }

            result.LevelAwarded = GetLevelAwarded(result.PlayerProgress);
            return result;
        }
    }