Exemple #1
0
        public async Task GetAssignedPlayers_TwoPlayers_OnePlayerAssignedToEachTeam()
        {
            var match = new Match {
                Id = "M1"
            };

            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 1, Id = "1", Kills = 1, Deaths = 1
            });
            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 2, Id = "2", Kills = 2, Deaths = 2
            });
            myMatchRepository.Add(match);
            myMatchRepository.SaveChanges();
            var skillBasedAssigner = new SkillBasedAssigner(myMatchRepository, new SteamworksApi());

            (var t, var ct) = await skillBasedAssigner.GetAssignedPlayers(new List <Player> {
                new Player {
                    SteamID = "1"
                }, new Player {
                    SteamID = "2"
                }
            });

            Assert.Single(t.Players);
            Assert.Single(ct.Players);
        }
Exemple #2
0
        public async Task GetAssignedPlayers_ThreePlayers_TwoPlayersVersusOnePlayerPlusBot()
        {
            var match = new Match {
                Id = "M1"
            };

            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 1, Id = "1", Kills = 1, Deaths = 1
            });
            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 2, Id = "2", Kills = 2, Deaths = 2
            });
            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 3, Id = "3", Kills = 3, Deaths = 3
            });
            myMatchRepository.Add(match);
            myMatchRepository.SaveChanges();
            var skillBasedAssigner = new SkillBasedAssigner(myMatchRepository, new SteamworksApi());

            (var t, var ct) = await skillBasedAssigner.GetAssignedPlayers(new List <Player> {
                new Player {
                    SteamID = "1", Name = "Emma"
                },
                new Player {
                    SteamID = "2", Name = "Kathy"
                },
                new Player {
                    SteamID = "3", Name = "Baltasar"
                }
            });

            Assert.Equal(2, t.Players.Count);
            Assert.Equal(2, ct.Players.Count);
            Assert.True(t.Players.Any(x => x.Name.Equals("BOT")) || ct.Players.Any(x => x.Name.Equals("BOT")));
        }
Exemple #3
0
        public async Task GetAssignedPlayers_TwoStrongPlayersAndFourMediumPlayers_OneStrongTwoMediumEach()
        {
            var match = new Match {
                Id = "M1"
            };
            var strongPlayer1 = new Player {
                SteamID = "1"
            };

            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 1, Id = Guid.NewGuid().ToString(), Kills = 10, Deaths = 2, Rounds = 5
            });
            var strongPlayer2 = new Player {
                SteamID = "2"
            };

            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 2, Id = Guid.NewGuid().ToString(), Kills = 11, Deaths = 3, Rounds = 5
            });
            var mediumPlayer1 = new Player {
                SteamID = "3"
            };

            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 3, Id = Guid.NewGuid().ToString(), Kills = 2, Deaths = 2, Rounds = 5
            });
            var mediumPlayer2 = new Player {
                SteamID = "4"
            };

            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 4, Id = Guid.NewGuid().ToString(), Kills = 2, Deaths = 3, Rounds = 5
            });
            var mediumPlayer3 = new Player {
                SteamID = "5"
            };

            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 5, Id = Guid.NewGuid().ToString(), Kills = 2, Deaths = 3, Rounds = 5
            });
            var mediumPlayer4 = new Player {
                SteamID = "6"
            };

            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 6, Id = Guid.NewGuid().ToString(), Kills = 2, Deaths = 3, Rounds = 5
            });
            myMatchRepository.Add(match);
            myMatchRepository.SaveChanges();
            var skillBasedAssigner = new SkillBasedAssigner(myMatchRepository, new SteamworksApi());

            (var t, var ct) = await skillBasedAssigner.GetAssignedPlayers(new List <Player> {
                strongPlayer1, strongPlayer2, mediumPlayer1, mediumPlayer2, mediumPlayer3, mediumPlayer4
            });

            Assert.Equal(3, t.Players.Count);
            Assert.Equal(3, ct.Players.Count);
            Assert.False(t.Players.Contains(strongPlayer1) && t.Players.Contains(strongPlayer2));
            Assert.False(ct.Players.Contains(strongPlayer1) && ct.Players.Contains(strongPlayer2));
        }
Exemple #4
0
        public async Task GetAssignedPlayers_ThreePlayersIncludeBotParameterFalse_NoBotAddedToBalanceTeamSizes()
        {
            var match = new Match {
                Id = "M1"
            };

            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 1, Id = "1", Kills = 1, Deaths = 1
            });
            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 2, Id = "2", Kills = 2, Deaths = 2
            });
            match.PlayerResults.Add(new MatchStatistics {
                SteamID = 3, Id = "3", Kills = 3, Deaths = 3
            });
            myMatchRepository.Add(match);
            myMatchRepository.SaveChanges();
            var skillBasedAssigner = new SkillBasedAssigner(myMatchRepository, new SteamworksApi());

            (var t, var ct) = await skillBasedAssigner.GetAssignedPlayers(
                new List <Player> {
                new Player {
                    SteamID = "1", Name = "Emma"
                },
                new Player {
                    SteamID = "2", Name = "Kathy"
                },
                new Player {
                    SteamID = "3", Name = "Baltasar"
                }
            },
                false);

            var numberOfAssignedPlayers = t.Players.Count + ct.Players.Count;

            Assert.Equal(3, numberOfAssignedPlayers);
        }