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

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

            _ = AddTeam(new EloTeam(player, place));
            return(player.Identifier);
        }
Beispiel #3
0
 public void AddPlayer(EloPlayer playerToAdd)
 {
     if (!Members.Add(playerToAdd))
     {
         throw new InvalidOperationException($"Player with identifier {playerToAdd.Identifier} already exists in this team.");
     }
     ;
 }
Beispiel #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);
        }
Beispiel #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);
Beispiel #6
0
 public EloTeam(EloPlayer player, bool won)
     : this(player, won ? 0 : 1)
 {
 }
Beispiel #7
0
 public EloTeam(EloPlayer player, int place)
     : this(new List <EloPlayer> {
     player
 }, place)
 {
 }
Beispiel #8
0
 public EloTeam(EloTeamIdentifier identifier, EloPlayer player, bool won)
     : this(identifier, new HashSet <EloPlayer> {
     player
 }, won ? 0 : 1)
 {
 }
Beispiel #9
0
 public EloTeam(EloTeamIdentifier identifier, EloPlayer player, int place)
     : this(identifier, new HashSet <EloPlayer> {
     player
 }, place)
 {
 }