Example #1
0
        public PlayRoundResponse PlayRound(Choice player1Choice)
        {
            PlayRoundResponse response = new PlayRoundResponse();

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

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

            //Player 1 winse?
            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);
        }
Example #2
0
        public void Start()
        {
            Choice      player1Choice;
            GameManager gm = new GameManager(new RandomChoice());

            while (true)
            {
                Console.Clear();
                player1Choice = ConsoleInput.GetChoiceFromUser();
                PlayRoundResponse response = gm.PlayRound(player1Choice);

                ConsoleOutput.DisplayResult(response);

                if (!ConsoleInput.QueryPlayAgain())
                {
                    return;
                }
            }
        }