예제 #1
0
        //Regular Rock, Paper, Scissors
        public MatchResult PlayRound(Player p1, Player p2)
        {
            MatchResult result = new MatchResult();

            result.Player1_Choice = p1.GetChoice();
            result.Player2_Choice = p2.GetChoice();



            if (result.Player1_Choice == result.Player2_Choice)
            {
                result.Match_Result = Result.Tie;
                GameResults.Add(gameCount, result.Match_Result);
            }
            else if ((result.Player1_Choice == Choice.Rock && result.Player2_Choice == Choice.Scissors) ||
                     (result.Player1_Choice == Choice.Paper && result.Player2_Choice == Choice.Rock) ||
                     (result.Player1_Choice == Choice.Scissors && result.Player2_Choice == Choice.Paper))

            {
                result.Match_Result = Result.Win;
                GameResults.Add(gameCount, result.Match_Result);
            }
            else
            {
                result.Match_Result = Result.Loss;
                GameResults.Add(gameCount, result.Match_Result);
            }

            ProcessResult(p1, p2, result);
            MatchHistory(GameResults, p1, p2);
            gameCount++;

            return(result);
        }
예제 #2
0
 public void StartGame()
 {
     while (CheckIfWinnerExists())
     {
         playerOne.GetChoice();
         playerTwo.GetChoice();
         if (CheckTie())
         {
             ShowTieMessage();
         }
         else if (!CheckPlayerOneWins())
         {
             playerTwo.score++;
             ShowRoundWinner(playerTwo);
         }
         else
         {
             playerOne.score++;
             ShowRoundWinner(playerOne);
         }
     }
     ShowWinningMessage();
 }