Beispiel #1
0
        public override PlayerAchievementViewModel Map(PlayerAchievement source)
        {
            var result = base.Map(source);

            var achievement = AchievementFactory.GetAchievementById(source.AchievementId);

            result.Achievement    = _achievementToAchievementViewModelMapper.Map(achievement);
            result.PlayerProgress = achievement.IsAwardedForThisPlayer(result.PlayerId).PlayerProgress;

            switch (achievement.Group)
            {
            case AchievementGroup.Game:
                result.RelatedGameDefinitions =
                    _gameDefinitionRetriever.GetGameDefinitionSummaries(source.RelatedEntities)
                    .Select(g => _gameDefinitionSummaryToGameDefinitionSummaryListViewModelMapper.Map(g))
                    .ToList();
                break;

            case AchievementGroup.Player:
                result.RelatedPlayers =
                    _playerRetriever.GetPlayers(source.RelatedEntities)
                    .Select(g => _playerToPlayerListSummaryViewModelMapper.Map(g))
                    .ToList();
                break;

            case AchievementGroup.PlayedGame:
                result.RelatedPlayedGames =
                    _playedGameRetriever.GetPlayedGamesQuickStats(source.RelatedEntities)
                    .Select(g => _playedGameQuickStatsToPlayedGameQuickStatsViewModelMapper.Map(g))
                    .ToList();
                break;
            }

            return(result);
        }
Beispiel #2
0
 public IActionResult OnGet(Guid gameID)
 {
     if (!env.IsDevelopment())
     {
         return(Redirect("../NoPermission"));
     }
     games   = gameRetriever.GetAllGames();
     players = playerRetriever.GetPlayers();
     game    = gameRetriever.GetGameById(gameID);
     return(Page());
 }
Beispiel #3
0
 public void OnGet()
 {
     players = playerRetreiver.GetPlayers();
 }
Beispiel #4
0
 public void SetupTeammateStats(Guid playerID)
 {
     players = playerRetriever.GetPlayers();
     games   = gameRetriever.GetAllGames();
     foreach (var player in players)
     {
         teammateStats.Add(player.ID, new int[] { 0, 0 });
     }
     foreach (var game in games)
     {
         if (playerID == game.BlueDefense)
         {
             if (game.BlueOffense == null)
             {
                 continue;
             }
             teammateStats[game.BlueOffense][0] += 1;
             if (game.BlueScore > game.RedScore)
             {
                 teammateStats[game.BlueOffense][1] += 1;
             }
         }
         else if (playerID == game.BlueOffense)
         {
             if (game.BlueDefense == null)
             {
                 continue;
             }
             teammateStats[game.BlueDefense][0] += 1;
             if (game.BlueScore > game.RedScore)
             {
                 teammateStats[game.BlueDefense][1] += 1;
             }
         }
         else if (playerID == game.RedDefense)
         {
             if (game.RedOffense == null)
             {
                 continue;
             }
             teammateStats[game.RedOffense][0] += 1;
             if (game.RedScore > game.BlueScore)
             {
                 teammateStats[game.RedOffense][1] += 1;
             }
         }
         else if (playerID == game.RedOffense)
         {
             if (game.RedDefense == null)
             {
                 continue;
             }
             teammateStats[game.RedDefense][0] += 1;
             if (game.RedScore > game.BlueScore)
             {
                 teammateStats[game.RedDefense][1] += 1;
             }
         }
     }
     teammateStats.Remove(playerID);
 }
Beispiel #5
0
 public TeamGenerator(IPlayerRetriever playerRetriever, ITeamRetriever teamRetriever)
 {
     this.playerRetriever = playerRetriever;
     teams   = teamRetriever.GetAllTeams();
     players = playerRetriever.GetPlayers();
 }