コード例 #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
ファイル: EloTeam.cs プロジェクト: ihs7/EloCalculatorNET
        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
ファイル: EloMatch.cs プロジェクト: ihs7/EloCalculatorNET
        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
ファイル: EloTeam.cs プロジェクト: ihs7/EloCalculatorNET
 public EloTeam(EloTeamIdentifier identifier, bool won)
     : this(identifier, new HashSet <EloPlayer>(), won ? 0 : 1)
 {
 }
コード例 #5
0
ファイル: EloTeam.cs プロジェクト: ihs7/EloCalculatorNET
 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
ファイル: EloMatch.cs プロジェクト: ihs7/EloCalculatorNET
 public void AddPlayerToTeam(EloTeamIdentifier teamIdentifier, int rating)
 => AddPlayerToTeam(teamIdentifier, new EloPlayer(rating));