public async Task PlayerStats_RaceBasedMMR()
        {
            var playerRepository       = new PlayerRepository(MongoClient);
            var playerHeroStatsHandler = new PlayOverviewHandler(playerRepository);

            var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent();
            var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent();

            matchFinishedEvent1.match.gateway = GateWay.Europe;
            matchFinishedEvent2.match.gateway = GateWay.Europe;

            matchFinishedEvent1.match.gameMode = GameMode.GM_1v1;
            matchFinishedEvent2.match.gameMode = GameMode.GM_1v1;

            matchFinishedEvent1.match.season = 2;
            matchFinishedEvent2.match.season = 2;

            matchFinishedEvent1.match.players[0].race = Race.NE;
            matchFinishedEvent2.match.players[0].race = Race.NE;

            matchFinishedEvent1.match.players[0].battleTag = "peter#123";
            matchFinishedEvent2.match.players[0].battleTag = "peter#123";

            await playerHeroStatsHandler.Update(matchFinishedEvent1);

            await playerHeroStatsHandler.Update(matchFinishedEvent2);

            var enemyStatsVsPlayerRace = await playerRepository.LoadOverview("2_peter#123@20_GM_1v1_NE");

            Assert.AreEqual(2, enemyStatsVsPlayerRace.Wins);
            Assert.AreEqual(0, enemyStatsVsPlayerRace.Losses);
        }
Exemplo n.º 2
0
        public async Task UpdateOverview_HandlerUpdate_2v2RT()
        {
            var matchFinishedEvent  = TestDtoHelper.CreateFake2v2RTEvent();
            var playerRepository    = new PlayerRepository(MongoClient);
            var playOverviewHandler = new PlayOverviewHandler(playerRepository);

            await playOverviewHandler.Update(matchFinishedEvent);

            var winners = matchFinishedEvent.match.players.Where(x => x.won);

            Assert.AreEqual(2, winners.Count());

            foreach (var player in winners)
            {
                var playerProfile = await playerRepository.LoadOverview($"0_{player.battleTag}@20_GM_2v2");

                Assert.AreEqual(1, playerProfile.Wins);
                Assert.AreEqual(0, playerProfile.Losses);
                Assert.AreEqual(GameMode.GM_2v2, playerProfile.GameMode);
            }

            var losers = matchFinishedEvent.match.players.Where(x => !x.won);

            Assert.AreEqual(2, losers.Count());

            foreach (var player in losers)
            {
                var playerProfile = await playerRepository.LoadOverview($"0_{player.battleTag}@20_GM_2v2");

                Assert.AreEqual(0, playerProfile.Wins);
                Assert.AreEqual(1, playerProfile.Losses);
                Assert.AreEqual(GameMode.GM_2v2, playerProfile.GameMode);
            }
        }
        public async Task PlayerStats_LoadMMRsByValidEnumValues()
        {
            var testing_season      = 0;
            var playerRepository    = new PlayerRepository(MongoClient);
            var playOverviewHandler = new PlayOverviewHandler(playerRepository);

            var mmrDistributionHandler = new MmrDistributionHandler(playerRepository);

            var gateWayValues  = Enum.GetValues(typeof(GateWay));
            var gameModeValues = Enum.GetValues(typeof(GameMode));

            foreach (GateWay gateWay in gateWayValues)
            {
                //skip undefinded value of ENums
                if (gateWay == GateWay.Undefined)
                {
                    continue;
                }
                foreach (GameMode gameMode in gameModeValues)
                {
                    if (gameMode == GameMode.Undefined ||
                        gameMode == GameMode.GM_2v2 ||
                        gameMode == GameMode.GM_2v2_AT ||
                        gameMode == GameMode.GM_4v4 ||
                        gameMode == GameMode.GM_4v4_AT ||
                        gameMode == GameMode.GM_LEGION_4v4_x20 ||
                        gameMode == GameMode.GM_LEGION_4v4_x20_AT)
                    {
                        continue;
                    }

                    var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent();
                    matchFinishedEvent1.match.players[0].battleTag = "peter#123";
                    matchFinishedEvent1.match.season          = testing_season;
                    matchFinishedEvent1.match.players[0].race = Race.HU;
                    matchFinishedEvent1.match.gateway         = gateWay;
                    matchFinishedEvent1.match.gameMode        = gameMode;

                    var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent();
                    matchFinishedEvent2.match.players[0].battleTag = "peter#123";
                    matchFinishedEvent2.match.season          = testing_season;
                    matchFinishedEvent2.match.players[0].race = Race.NE;
                    matchFinishedEvent2.match.gateway         = gateWay;
                    matchFinishedEvent2.match.gameMode        = gameMode;

                    await playOverviewHandler.Update(matchFinishedEvent1);

                    await playOverviewHandler.Update(matchFinishedEvent2);


                    var distribution = await mmrDistributionHandler.GetDistributions(testing_season, gateWay, gameMode);

                    Assert.IsNotNull(distribution);
                }
            }
        }
Exemplo n.º 4
0
        public async Task UpdateOverview_HandlerUpdate_2v2AT()
        {
            var matchFinishedEvent  = TestDtoHelper.CreateFake2v2Event();
            var playerRepository    = new PlayerRepository(MongoClient);
            var playOverviewHandler = new PlayOverviewHandler(playerRepository);

            matchFinishedEvent.match.players[0].battleTag = "peter#123";
            matchFinishedEvent.match.players[1].battleTag = "wolf#123";
            matchFinishedEvent.match.gateway  = GateWay.America;
            matchFinishedEvent.match.gameMode = GameMode.GM_2v2_AT;

            await playOverviewHandler.Update(matchFinishedEvent);

            var playerProfile = await playerRepository.LoadOverview("0_peter#123@10_wolf#123@10_GM_2v2_AT");

            Assert.AreEqual(1, playerProfile.Wins);
            Assert.AreEqual(0, playerProfile.Losses);
            Assert.AreEqual(GameMode.GM_2v2_AT, playerProfile.GameMode);
        }
Exemplo n.º 5
0
        public async Task RaceBasedMMRUpdate()
        {
            var matchEventRepository = new MatchEventRepository(MongoClient);
            var rankRepository       = new RankRepository(MongoClient);
            var playerRepository     = new PlayerRepository(MongoClient);

            var matchFinishedEvent  = TestDtoHelper.CreateFakeEvent();
            var rankingChangedEvent = TestDtoHelper.CreateRankChangedEvent();

            matchFinishedEvent.match.players[0].battleTag = "peTer#123";
            matchFinishedEvent.match.players[0].race      = Race.NE;
            matchFinishedEvent.match.gameMode             = GameMode.GM_1v1;
            matchFinishedEvent.match.season  = 2;
            matchFinishedEvent.match.gateway = GateWay.America;

            rankingChangedEvent.ranks[0].battleTags = new List <string> {
                "peTer#123"
            };
            rankingChangedEvent.ranks[0].race = Race.NE;
            rankingChangedEvent.gateway       = GateWay.America;
            rankingChangedEvent.gameMode      = GameMode.GM_1v1;
            rankingChangedEvent.season        = 2;

            await InsertRankChangedEvent(rankingChangedEvent);

            await matchEventRepository.InsertIfNotExisting(matchFinishedEvent);

            var playOverviewHandler = new PlayOverviewHandler(playerRepository);
            await playOverviewHandler.Update(matchFinishedEvent);

            var rankHandler = new RankSyncHandler(rankRepository, matchEventRepository);

            await playOverviewHandler.Update(matchFinishedEvent);

            await rankHandler.Update();

            var rank = await rankRepository.SearchPlayerOfLeague("peT", 2, GateWay.America, GameMode.GM_1v1);

            Assert.AreEqual(1, rank.Count);
            Assert.AreEqual(Race.NE, rank[0].Race);
        }
        public async Task UpdateOverview_HandlerUpdate_RaceBasedMMR()
        {
            var playerRepository    = new PlayerRepository(MongoClient);
            var playOverviewHandler = new PlayOverviewHandler(playerRepository);


            var matchFinishedEvent1 = TestDtoHelper.CreateFakeEvent();

            matchFinishedEvent1.match.players[0].battleTag = "peter#123";
            matchFinishedEvent1.match.season          = 2;
            matchFinishedEvent1.match.players[0].race = Race.HU;
            matchFinishedEvent1.match.gateway         = GateWay.America;
            matchFinishedEvent1.match.gameMode        = GameMode.GM_1v1;

            var matchFinishedEvent2 = TestDtoHelper.CreateFakeEvent();

            matchFinishedEvent2.match.players[0].battleTag = "peter#123";
            matchFinishedEvent2.match.season          = 2;
            matchFinishedEvent2.match.players[0].race = Race.NE;
            matchFinishedEvent2.match.gateway         = GateWay.America;
            matchFinishedEvent2.match.gameMode        = GameMode.GM_1v1;

            await playOverviewHandler.Update(matchFinishedEvent1);

            await playOverviewHandler.Update(matchFinishedEvent2);

            var playerProfile1 = await playerRepository.LoadOverview("2_peter#123@10_GM_1v1_HU");

            var playerProfile2 = await playerRepository.LoadOverview("2_peter#123@10_GM_1v1_NE");

            Assert.AreEqual(1, playerProfile1.Wins);
            Assert.AreEqual(0, playerProfile1.Losses);
            Assert.AreEqual(1, playerProfile2.Wins);
            Assert.AreEqual(0, playerProfile2.Losses);

            Assert.AreEqual(Race.HU, playerProfile1.Race);
            Assert.AreEqual(Race.NE, playerProfile2.Race);
        }
Exemplo n.º 7
0
        public async Task RankIntegrationWithMultipleIds()
        {
            var matchEventRepository = new MatchEventRepository(MongoClient);
            var rankRepository       = new RankRepository(MongoClient, personalSettingsProvider);
            var playerRepository     = new PlayerRepository(MongoClient);

            var matchFinishedEvent  = TestDtoHelper.CreateFakeEvent();
            var rankingChangedEvent = TestDtoHelper.CreateRankChangedEvent();

            matchFinishedEvent.match.players[0].battleTag = "peTer#123";
            matchFinishedEvent.match.gameMode             = GameMode.GM_1v1;
            matchFinishedEvent.match.gateway = GateWay.America;

            rankingChangedEvent.ranks[0].battleTags = new List <string> {
                "peTer#123"
            };
            rankingChangedEvent.gateway  = GateWay.America;
            rankingChangedEvent.gameMode = GameMode.GM_1v1;

            await InsertRankChangedEvent(rankingChangedEvent);

            await matchEventRepository.InsertIfNotExisting(matchFinishedEvent);

            var playOverviewHandler = new PlayOverviewHandler(playerRepository);
            await playOverviewHandler.Update(matchFinishedEvent);

            var rankHandler = new RankSyncHandler(rankRepository, matchEventRepository);

            await playOverviewHandler.Update(matchFinishedEvent);

            await rankHandler.Update();

            var rank = await rankRepository.SearchPlayerOfLeague("peT", 0, GateWay.America, GameMode.GM_1v1);

            Assert.AreEqual(1, rank.Count);
        }