public PlayRoundResponse PlayRound(Choice player1Choice)
        {
            PlayRoundResponse response = new PlayRoundResponse();

            response.Player1Choice = player1Choice;
            response.Player2Choice = _choiceBehavior.GetChoice();

            // Tie?
            if (response.Player1Choice == response.Player2Choice)
            {
                response.Player1Result = GameResult.Tie;
                return(response);
            }

            // Player 1 wins?
            if (response.Player1Choice == Choice.Rock &&
                response.Player2Choice == Choice.Scissors ||
                response.Player1Choice == Choice.Scissors &&
                response.Player2Choice == Choice.Paper ||
                response.Player1Choice == Choice.Paper &&
                response.Player2Choice == Choice.Rock)
            {
                response.Player1Result = GameResult.Win;
                return(response);
            }

            // otherwise loss
            response.Player1Result = GameResult.Loss;
            return(response);
        }
Beispiel #2
0
        public RoundResult PlayRound()
        {
            RPSChoice p1Choice = _player1.GetChoice();
            RPSChoice p2Choice = _player2.GetChoice();

            int result = CompareThrows(p1Choice, p2Choice);

            return(new RoundResult(p1Choice, p2Choice, result));
        }
Beispiel #3
0
        public PlayerRoundResponse PlayerRound(Choice userChoice)
        {
            PlayerRoundResponse response = new PlayerRoundResponse();

            response.UserChoice     = userChoice;
            response.ComputerChoice = _chooser.GetChoice();

            if (response.ComputerChoice == response.UserChoice)
            {
                response.Result = GameResult.Tie;
                return(response);
            }

            if (response.ComputerChoice == Choice.Rock && response.UserChoice == Choice.Scissors ||
                response.ComputerChoice == Choice.Scissors && response.UserChoice == Choice.Paper ||
                response.ComputerChoice == Choice.Paper && response.UserChoice == Choice.Rock)
            {
                response.Result = GameResult.Loss;
                return(response);
            }

            response.Result = GameResult.Win;
            return(response);
        }
 public Choice GetComputerChoice()
 {
     return(_chooser.GetChoice());
 }