public EloIndividualResult(EloPlayerIdentifier playerIdentifier, EloTeamIdentifier teamIdentifier, EloRating ratingBefore, EloRating ratingAfter) { PlayerIdentifier = playerIdentifier ?? throw new ArgumentNullException(nameof(playerIdentifier)); TeamIdentifier = teamIdentifier ?? throw new ArgumentNullException(nameof(teamIdentifier)); RatingBefore = ratingBefore; RatingAfter = ratingAfter; }
public EloTeam(EloTeamIdentifier identifier, IEnumerable <EloPlayer> players, int place) { if (players == null) { throw new ArgumentNullException(nameof(players)); } Identifier = identifier; Place = place; Members = new HashSet <EloPlayer>(); foreach (var player in players) { AddPlayer(player); } }
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); }
public EloTeam(EloTeamIdentifier identifier, bool won) : this(identifier, new HashSet <EloPlayer>(), won ? 0 : 1) { }
public EloTeam(EloTeamIdentifier identifier, int place) : this(identifier, new HashSet <EloPlayer>(), place) { }
public IEnumerable <EloIndividualResult> GetResults(EloTeamIdentifier teamIdentifier) => _results.Where(x => x.TeamIdentifier == teamIdentifier);
public void AddPlayerToTeam(EloTeamIdentifier teamIdentifier, int rating) => AddPlayerToTeam(teamIdentifier, new EloPlayer(rating));