示例#1
0
        public EloPlayerIdentifier AddPlayer(int rating, bool won)
        {
            var player = new EloPlayer(rating);

            _ = AddTeam(new EloTeam(player, won));
            return(player.Identifier);
        }
示例#2
0
        public EloPlayerIdentifier AddPlayer(int rating, int place)
        {
            var player = new EloPlayer(rating);

            _ = AddTeam(new EloTeam(player, place));
            return(player.Identifier);
        }
示例#3
0
 public void AddPlayer(EloPlayer playerToAdd)
 {
     if (!Members.Add(playerToAdd))
     {
         throw new InvalidOperationException($"Player with identifier {playerToAdd.Identifier} already exists in this team.");
     }
     ;
 }
示例#4
0
        public void AddPlayerToTeam(EloTeamIdentifier teamIdentifier, EloPlayer playerToAdd)
        {
            if (playerToAdd == null)
            {
                throw new ArgumentNullException(nameof(playerToAdd));
            }

            if (_teams.Any(x => x.Members.Select(s => s.Identifier).Contains(playerToAdd.Identifier)))
            {
                throw new ArgumentException($"Player with identifier {playerToAdd.Identifier} already exists in a team in this match.");
            }

            var team = _teams.FirstOrDefault(x => x.Identifier == teamIdentifier);

            if (team == null)
            {
                throw new InvalidOperationException($"No team with identifier {teamIdentifier} found in match.");
            }

            team.AddPlayer(playerToAdd);
        }
示例#5
0
 /// <summary>
 /// Calculates the expected score between two players.
 /// </summary>
 /// <param name="player">Player to calculate expected score for.</param>
 /// <param name="opponent">Opponent to calculate expected score against.</param>
 /// <returns>Returns a float value between 0 and 1 representing the likelyhood of player winning another.</returns>
 public static float ExpectedScoreAgainst(this EloPlayer player, EloPlayer opponent)
 => ExpectedScore(player.Rating, opponent.Rating);
示例#6
0
 public EloTeam(EloPlayer player, bool won)
     : this(player, won ? 0 : 1)
 {
 }
示例#7
0
 public EloTeam(EloPlayer player, int place)
     : this(new List <EloPlayer> {
     player
 }, place)
 {
 }
示例#8
0
 public EloTeam(EloTeamIdentifier identifier, EloPlayer player, bool won)
     : this(identifier, new HashSet <EloPlayer> {
     player
 }, won ? 0 : 1)
 {
 }
示例#9
0
 public EloTeam(EloTeamIdentifier identifier, EloPlayer player, int place)
     : this(identifier, new HashSet <EloPlayer> {
     player
 }, place)
 {
 }