public async Task <PlayerMmrTimeline> CreateMmrTimeline(Match match, PlayerMMrChange player) { var count = await _matchRepository.CountFor(player.battleTag, null, match.gateway, match.gameMode, match.season); int pageSize = (int)count; var matches = await _matchRepository.LoadFor(player.battleTag, null, match.gateway, match.gameMode, pageSize, 0, match.season); PlayerMmrTimeline mmrTimeline = new PlayerMmrTimeline(player.battleTag, player.race, match.gateway, match.season); // Is there a better way to traverse through this? foreach (Matchup m in matches) { foreach (Team t in m.Teams) { foreach (PlayerOverviewMatches p in t.Players) { if (p.BattleTag == player.battleTag) { // Is this the correct sorting? mmrTimeline.MmrAtTimes.Add(new MmrAtTime(p.CurrentMmr, m.EndTime)); } } } } return(mmrTimeline); }
private async Task <PlayerWinLoss> LoadAndApply(PlayerMMrChange p, int season) { var playerWinLoss = await _playerRepository.LoadPlayerWinrate(p.battleTag, season); var loadPlayerWinrate = playerWinLoss ?? PlayerWinLoss.Create(p.battleTag, season); return(loadPlayerWinrate.Apply(p.won)); }
private GameMode GetGameModeStatGameMode(GameMode gameMode, PlayerMMrChange player) { if (gameMode == GameMode.GM_2v2 && player.IsAt) { return(GameMode.GM_2v2_AT); } return(gameMode); }
public async Task UpdateLocation(PlayerMMrChange player) { if (!string.IsNullOrEmpty(player.country)) { var setting = await _personalSettingsRepository.Load(player.battleTag) ?? new PersonalSetting(player.battleTag); setting.Location = player.country; await _personalSettingsRepository.Save(setting); } }
private static void CreateMatchTeam(MatchFinishedEvent fakeEvent, bool won, int team, int playersPerTeam) { for (int i = 0; i < playersPerTeam; i++) { var player = new PlayerMMrChange() { battleTag = $"{team}#{i}", team = team, won = won }; fakeEvent.match.players.Add(player); } }
private static MatchFinishedEvent CreateMatchEvent( PlayerMMrChange player, List <Hero> playerHeroes, PlayerMMrChange enemyPlayer, List <Hero> enemyHeroes) { var matchFinishedEvent = TestDtoHelper.CreateFakeEvent(); matchFinishedEvent.match.players[0] = player; matchFinishedEvent.result.players[0].heroes = playerHeroes; matchFinishedEvent.match.players[1] = enemyPlayer; matchFinishedEvent.result.players[1].heroes = enemyHeroes; return(matchFinishedEvent); }
private GameMode GetOverviewGameMode(GameMode gameMode, PlayerMMrChange player) { if (gameMode == GameMode.GM_2v2 && player.IsAt) { return(GameMode.GM_2v2_AT); } if (gameMode == GameMode.GM_4v4 && player.IsAt) { return(GameMode.GM_4v4_AT); } if (gameMode == GameMode.GM_LEGION_4v4_x20 && player.IsAt) { return(GameMode.GM_LEGION_4v4_x20_AT); } return(gameMode); }