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;
}
}