public HandSign GetAIHandSign(int AIHandSign)
        {

            int ChosenHandSign =AIHandSign;
            switch (ChosenHandSign)
            {
                case 0:
                    Rock rock = new Rock("Rock");
                    return rock;
                case 1:
                    Paper paper = new Paper("Paper");
                    return paper;
                case 2:
                    Scissors scissors = new Scissors("Scissors");
                    return scissors;
                case 3:
                    Lizard lizard = new Lizard("Lizard");
                    return lizard;
                case 4:
                    Spock spock = new Spock("Spock");
                    return spock;
                default:
                    return GetUserInputHandSign();
            }
        }
        public HandSign GetUserInputHandSign()
        {

            string ChosenHandSign = null;
            Console.WriteLine("What hand sign do you want to choose Rock, Paper, Scissors, Lizard, or Spock?");
            ChosenHandSign = Console.ReadLine();
            switch (ChosenHandSign)
            {
                case "Rock":
                    Rock rock = new Rock("Rock");
                    return rock;
                case "Paper":
                    Paper paper = new Paper("Paper");
                    return paper;
                case "Scissors":
                    Scissors scissors = new Scissors("Scissors");
                    return scissors;
                case "Lizard":
                    Lizard lizard = new Lizard("Lizard");
                    return lizard;
                case "Spock":
                    Spock spock = new Spock("Spock");
                    return spock;
                default:
                    return GetUserInputHandSign();
            }
        }
 public RunGame()
 {
     scissor = new Scissor("Scissor");
     paper = new Paper("Paper");
     rock = new Rock("Rock");
     spock = new Spock("Spock");
     lizard = new Lizard("Lizard");
     player = new Player();
     ai = new AI();
     display = new Display();
 }
Пример #4
0
        public void VsComputer()
        {
            display = new Display();
            player = new Player();
            ai = new AI("AI");
            rock = new Rock("Rock");
            paper = new Paper("Paper");
            scissors = new Scissors("Scissors");
            bool gameActive = true;

            while (gameActive == true)
            {
                display.OutputToFile("ScoresVsAI.txt");
                Console.WriteLine("New game? yes/no");
                string userContinue = Console.ReadLine().ToLower();
                Console.Clear();
                display.DisplayScoreBoardVsAI();

                if (userContinue == "no")
                {
                    display.OutputToFile("ScoresVsAI.txt");
                    break;
                }

                if (userContinue == "yes")
                {
                    ai.AITurn();
                    player.Player1Input();
                    Console.WriteLine(Environment.NewLine);

                    //rock
                    if (ai.aiChoice == "rock")
                    {
                        if (player.player1Choice == "rock")
                        {
                            Console.WriteLine("The {0} chose {1}", ai.Name, rock.Name);
                            Console.WriteLine("It is a tie.\r\n");
                        }
                        else if (player.player1Choice == "paper")
                        {
                            display.player1Score++;
                            Console.WriteLine("The {0} chose {1}", ai.Name, rock.Name);
                            paper.DisplayWin(player.player1Choice, ai.aiChoice);
                            Console.WriteLine("You win!\r\n");
                        }
                        else if (player.player1Choice == "scissors")
                        {
                            display.aiScore++;
                            Console.WriteLine("The {0} chose {1}", ai.Name, rock.Name);
                            scissors.DisplayLoss(player.player1Choice, ai.aiChoice);
                            Console.WriteLine("{0} wins!\r\n",ai.Name);
                        }
                        else
                        {
                            Console.WriteLine("You must choose Rock, Paper, or Scissors!\r\n");
                        }

                    }
                    //paper
                    else if (ai.aiChoice == "paper")
                    {
                        if (player.player1Choice == "rock")
                        {
                            Console.WriteLine("The {0} chose {1}", ai.Name, rock.Name);
                            rock.DisplayLoss(player.player1Choice, ai.aiChoice);
                            Console.WriteLine("{0} wins!\r\n",ai.Name);
                            display.aiScore++;
                        }
                        else if (player.player1Choice == "paper")
                        {
                            Console.WriteLine("The {0} chose {1}", ai.Name, paper.Name);
                            Console.WriteLine("It is a tie\r\n");                            

                        }
                        else if (player.player1Choice == "scissors")
                        {
                            Console.WriteLine("The {0} chose {1}", ai.Name, paper.Name);
                            scissors.DisplayWin(player.player1Choice, ai.aiChoice);
                            Console.WriteLine("You win!\r\n");
                            display.player1Score++;

                        }
                        else
                        {
                            Console.WriteLine("You must choose Rock, Paper, or Scissors!\r\n");
                        }
                    }

                    //scissors
                    else if (ai.aiChoice == "scissors")
                    {
                        if (player.player1Choice == "rock")
                        {
                            //ai scissors, you rock = win
                            display.player1Score++;
                            Console.WriteLine("The {0} chose {1}", ai.Name, scissors.Name);
                            rock.DisplayWin(player.player1Choice, ai.aiChoice);
                            Console.WriteLine("You win!\r\n");
                        }
                        else if (player.player1Choice == "paper")
                        {
                            //ai scissors, you paper = lose
                            display.aiScore++;
                            Console.WriteLine("The {0} chose {1}", ai.Name, scissors.Name);
                            paper.DisplayLoss(player.player1Choice, ai.aiChoice);
                            Console.WriteLine("{0} wins!\r\n", ai.Name);
                        
                        }
                        else if (player.player1Choice == "scissors")
                        {
                            Console.WriteLine("The {0} chose {1}", ai.Name, scissors.Name);
                            Console.WriteLine("It is a tie\r\n");
                        }
                        else
                        {
                            Console.WriteLine("You must choose Rock, Paper, or Scissors!\r\n");
                        }

                    }
                }
            }
        }
        static void Main(string[] args)
        {
            bool playAgain = true;

            Rock rock = new Rock();
            rock.rockRules();
            Paper paper = new Paper();
            paper.paperRules();
            Scissors scissors = new Scissors();
            scissors.scissorsRules();
            Lizard lizard = new Lizard();
            lizard.lizardRules();
            Spock spock = new Spock();
            spock.spockRules();

            prompts startGame = new prompts();
            startGame.startGame();

                    multiPlayerOptions multiPlayerOptions = new multiPlayerOptions();
                    int selectedPlayers = multiPlayerOptions.setPlayers();

                if (selectedPlayers == 2)
                {
                    playerNames playerNames = new playerNames();
                    string playerOneName = playerNames.playerOneName();
                    string playerTwoName = playerNames.playerTwoName();

                    while (playAgain)
                    {
                    playerOneTurn playerOneChoice = new playerOneTurn();
                    string result1 = playerOneChoice.goPlayerOne(playerOneName);

                    playerTwoTurn playerTwoChoice = new playerTwoTurn();
                    string result2 = playerTwoChoice.goPlayerTwo(playerTwoName);

                    results results = new results();
                    results.gameResults(result1, result2, playerOneName, playerTwoName);

                    Console.WriteLine("Do you want to play again?(y/n)");
                    string loop = Console.ReadLine();
                    if (loop == "y")
                    {
                        playAgain = true;
                        
                    }
                    else if (loop == "n")
                    {
                        playAgain = false;
                    }
                    else
                    {

                    }

                }

                }
                else
                {
                    playerNames playerNames = new playerNames();
                    string playerOneName = playerNames.playerOneName();
                    string cpuName = playerNames.cpuName();

                    while (playAgain)
                    {
                    playerOneTurn playerOneChoice = new playerOneTurn();
                    string result1 = playerOneChoice.goPlayerOne(playerOneName);

                    cpuChoice cpuChoice = new cpuChoice();
                    string result2 = cpuChoice.randomChoice();

                    results results = new results();
                    results.gameResults(result1, result2, playerOneName, cpuName);

                    Console.WriteLine("Do you want to play again?(y/n)");
                    string loop = Console.ReadLine();
                    if (loop == "y")
                    {
                        playAgain = true;
                        Console.Clear();
                    }
                    else if (loop == "n")
                    {
                        playAgain = false;
                    }
                    else
                    {

                    }
                }
                }

        }