示例#1
0
        public MatchResults Play(int numberOfRounds, IPlayer player1, IPlayer player2)
        {
            var rounds = new List <MatchResults.Round>();

            for (int roundNumber = 1; roundNumber <= numberOfRounds; roundNumber++)
            {
                var player1Move = player1.Move();
                var player2Move = player2.Move();
                var score       = rules.GetScore(player1Move, player2Move);
                var round       = new MatchResults.Round()
                {
                    Number       = roundNumber,
                    Player1Move  = player1Move,
                    Player2Move  = player2Move,
                    Player1Score = score,
                    Player2Score = -1 * score,
                };
                rounds.Add(round);
                RoundPlayed?.Invoke(this, new RoundEventArgs(round));
            }
            return(new MatchResults()
            {
                Rounds = rounds.AsReadOnly()
            });
        }
示例#2
0
 public RoundEventArgs(MatchResults.Round round)
 {
     Round = round;
 }
示例#3
0
 private static void ShowRound(MatchResults.Round round)
 {
     Console.WriteLine($"{round.Number} \t Player1: {round.Player1Move.ToString().PadRight(8, ' ')} ( {round.Player1Score.ToString().PadLeft(2, ' ')} ) \t Player2: {round.Player2Move.ToString().PadRight(8, ' ')} ( {round.Player2Score.ToString().PadLeft(2, ' ')} )");
 }