Beispiel #1
0
        public void CompareHands(string player1Choice, string player2Choice)
        {
            int player1ChoiceIndex = GetChoiceIndex(player1Choice);
            int player2ChoiceIndex = GetChoiceIndex(player2Choice);

            int winResult = (5 + player1ChoiceIndex - player2ChoiceIndex) % 5;

            switch (winResult)
            {
            case 0:
                Console.WriteLine("   [DRAW!]");
                CheckGameWinner();
                break;

            case 1:
            case 3:
                Console.WriteLine("   [" + player1.GetName() + " wins this round!]");
                player1.IncrementScore();
                CheckGameWinner();
                break;

            case 2:
            case 4:
                Console.WriteLine("   [" + player2.GetName() + " wins this round!]");
                player2.IncrementScore();
                CheckGameWinner();
                break;

            default:
                break;
            }
        }
Beispiel #2
0
        public void CompareChoices(string OtherPlayerChoice)
        {
            switch (PlayerOne.Choice)
            {
            case "rock":

                switch (OtherPlayerChoice)
                {
                case "rock":
                    Console.WriteLine($"{PlayerOne.Name} ties with {PlayerTwo.Name}");
                    break;

                case "paper":
                    Console.WriteLine($"{PlayerOne.Name} Wins!");
                    PlayerOne.IncrementScore();
                    break;

                case "scissors":
                    Console.WriteLine($"{PlayerTwo.Name} Wins");
                    PlayerTwo.IncrementScore();
                    break;

                case "lizard":
                    Console.WriteLine($"{PlayerTwo.Name} Wins");
                    PlayerTwo.IncrementScore();
                    break;

                case "spock":
                    Console.WriteLine($"{PlayerOne.Name} Wins!");
                    PlayerOne.IncrementScore();
                    break;

                default:
                    break;
                }
                break;

            case "paper":

                switch (OtherPlayerChoice)
                {
                case "rock":
                    Console.WriteLine($"{PlayerOne.Name} Wins!");
                    PlayerOne.IncrementScore();
                    break;

                case "paper":
                    Console.WriteLine($"{PlayerOne.Name} ties with {PlayerTwo.Name}");
                    break;

                case "scissors":
                    Console.WriteLine($"{PlayerOne.Name} Wins");
                    PlayerOne.IncrementScore();
                    break;

                case "lizard":
                    Console.WriteLine($"{PlayerTwo.Name} Wins");
                    PlayerTwo.IncrementScore();
                    break;

                case "spock":
                    Console.WriteLine($"{PlayerTwo.Name} Wins");
                    PlayerTwo.IncrementScore();
                    break;

                default:
                    break;
                }
                break;

            case "scissors":

                switch (OtherPlayerChoice)
                {
                case "rock":
                    Console.WriteLine($"{PlayerTwo.Name} Wins!");
                    PlayerTwo.IncrementScore();
                    break;

                case "paper":
                    Console.WriteLine($"{PlayerOne.Name}");
                    PlayerOne.IncrementScore();
                    break;

                case "scissors":
                    Console.WriteLine($"{PlayerOne.Name} ties with {PlayerTwo.Name}");
                    break;

                case "lizard":
                    Console.WriteLine($"{PlayerOne.Name} Wins");
                    PlayerOne.IncrementScore();
                    break;

                case "spock":
                    Console.WriteLine($"{PlayerTwo.Name} Wins");
                    PlayerTwo.IncrementScore();
                    break;

                default:
                    break;
                }
                break;

            case "lizard":

                switch (OtherPlayerChoice)
                {
                case "rock":
                    Console.WriteLine($"{PlayerTwo.Name} Wins!");
                    PlayerTwo.IncrementScore();
                    break;

                case "paper":
                    Console.WriteLine($"{PlayerOne.Name} Wins!");
                    PlayerOne.IncrementScore();
                    break;

                case "scissors":
                    Console.WriteLine($"{PlayerTwo.Name} Wins!");
                    PlayerTwo.IncrementScore();
                    break;

                case "lizard":
                    Console.WriteLine($"{PlayerTwo.Name} ties with {PlayerOne.Name}");
                    break;

                case "spock":
                    Console.WriteLine($"{PlayerOne.Name} Wins");
                    PlayerOne.IncrementScore();
                    break;

                default:
                    break;
                }
                break;

            case "spock":

                switch (OtherPlayerChoice)
                {
                case "rock":
                    Console.WriteLine($"{PlayerTwo.Name} Wins!");
                    PlayerTwo.IncrementScore();
                    break;

                case "paper":
                    Console.WriteLine($"{PlayerOne.Name} Wins!");
                    PlayerOne.IncrementScore();
                    break;

                case "scissors":
                    Console.WriteLine($"{PlayerOne.Name} Wins");
                    PlayerOne.IncrementScore();
                    break;

                case "lizard":
                    Console.WriteLine($"{PlayerTwo.Name} Wins");
                    PlayerTwo.IncrementScore();
                    break;

                case "spock":
                    Console.WriteLine($"{PlayerOne.Name} ties with {PlayerTwo.Name}");
                    break;

                default:
                    break;
                }
                break;
            }
        }