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