예제 #1
0
 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;
 }
예제 #2
0
        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);
            }
        }
예제 #3
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);
        }
예제 #4
0
 public EloTeam(EloTeamIdentifier identifier, bool won)
     : this(identifier, new HashSet <EloPlayer>(), won ? 0 : 1)
 {
 }
예제 #5
0
 public EloTeam(EloTeamIdentifier identifier, int place)
     : this(identifier, new HashSet <EloPlayer>(), place)
 {
 }
예제 #6
0
 public IEnumerable <EloIndividualResult> GetResults(EloTeamIdentifier teamIdentifier)
 => _results.Where(x => x.TeamIdentifier == teamIdentifier);
예제 #7
0
 public void AddPlayerToTeam(EloTeamIdentifier teamIdentifier, int rating)
 => AddPlayerToTeam(teamIdentifier, new EloPlayer(rating));