Exemplo n.º 1
0
 public static WinLoss GetWinLoss(this PlayerRaceOnMapVersusRaceRatio ratio, Race myRace, Race enemyRace, string map, string patch)
 {
     return(ratio.RaceWinsOnMapByPatch[patch]
            .Single(r => r.Race == myRace).WinLossesOnMap
            .Single(r => r.Map == map).WinLosses
            .Single(w => w.Race == enemyRace));
 }
        public async Task LoadAndSaveMapAndRace()
        {
            var playerRepository = new PlayerStatsRepository(MongoClient);

            var player = PlayerRaceOnMapVersusRaceRatio.Create("peter#123", 0);
            await playerRepository.UpsertMapAndRaceStat(player);

            var playerLoaded = await playerRepository.LoadMapAndRaceStat(player.BattleTag, 0);

            Assert.AreEqual(player.BattleTag, playerLoaded.BattleTag);
        }
        public async Task MapWinsAsTotalRace()
        {
            var playerRepository = new PlayerStatsRepository(MongoClient);

            var player = PlayerRaceOnMapVersusRaceRatio.Create("peter#123", 0);
            var patch  = "1.32.5";

            player.AddMapWin(Race.HU, Race.UD, "TM", true, patch);
            player.AddMapWin(Race.NE, Race.UD, "TM", true, patch);
            player.AddMapWin(Race.OC, Race.UD, "TM", true, patch);

            await playerRepository.UpsertMapAndRaceStat(player);

            var playerLoaded = await playerRepository.LoadMapAndRaceStat(player.BattleTag, 0);

            Assert.AreEqual(3, playerLoaded.GetWinLoss(Race.Total, Race.UD, "TM", patch).Wins);
        }
 public Task UpsertMapAndRaceStat(PlayerRaceOnMapVersusRaceRatio playerRaceOnMapVersusRaceRatio)
 {
     return(Upsert(playerRaceOnMapVersusRaceRatio));
 }
Exemplo n.º 5
0
        public async Task <IActionResult> GetRaceOnMapVersusRaceStat([FromRoute] string battleTag, int season)
        {
            var matches = await _playerRepository.LoadMapAndRaceStat(battleTag, season);

            return(Ok(matches ?? PlayerRaceOnMapVersusRaceRatio.Create(battleTag, season)));
        }