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 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 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(); }
public void VsComputerHard() { display = new Display(); player = new Player(); ai = new AI("AI"); rock = new Rock("Rock"); paper = new Paper("Paper"); scissors = new Scissors("Scissors"); lizard = new Lizard("Lizard"); spock = new Spock("Spock"); bool gameActive = true; while (gameActive == true) { display.OutputToFile("ScoresVsHardAI.txt"); Console.WriteLine("New game? yes/no"); string userContinue = Console.ReadLine().ToLower(); Console.Clear(); display.DisplayScoreBoardVsAI(); if (userContinue == "no") { display.OutputToFile("ScoresVsHardAI.txt"); break; } if (userContinue == "yes") { ai.HardAITurn(); player.Player1InputHard(); Console.WriteLine(Environment.NewLine); //rock if (ai.aiChoice == "rock") { if (player.player1Choice == "rock") { Console.WriteLine("The {0} chose Rock", ai.Name); Console.WriteLine("It is a tie\r\n"); } else if (player.player1Choice == "paper") { display.player1Score++; Console.WriteLine("The {0} chose Rock", ai.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 Rock", ai.Name); scissors.DisplayLoss(player.player1Choice, ai.aiChoice); Console.WriteLine("{0} wins!", ai.Name); } else if (player.player1Choice == "lizard") { display.aiScore++; Console.WriteLine("The {0} chose Rock", ai.Name); lizard.DisplayLoss(player.player1Choice, ai.aiChoice); Console.WriteLine("{0} wins!\r\n", ai.Name); } else if (player.player1Choice == "spock") { display.player1Score++; Console.WriteLine("The {0} chose Rock", ai.Name); spock.DisplayWin(player.player1Choice, ai.aiChoice); Console.WriteLine("You win!\r\n"); } else { Console.WriteLine("You must choose Rock, Paper, Scissors, Lizard, or Spock!\r\n"); } } //paper else if (ai.aiChoice == "paper") { if (player.player1Choice == "rock") { Console.WriteLine("The {0} chose Paper", ai.Name); rock.DisplayLoss(player.player1Choice, ai.aiChoice); display.aiScore++; Console.WriteLine("{0} wins!\r\n", ai.Name); } else if (player.player1Choice == "paper") { Console.WriteLine("The {0} chose Paper",ai.Name); Console.WriteLine("It is a tie\r\n"); } else if (player.player1Choice == "scissors") { Console.WriteLine("The {0} chose Paper", ai.Name); scissors.DisplayWin(player.player1Choice, ai.aiChoice); display.player1Score++; Console.WriteLine("You win!\r\n"); } else if (player.player1Choice == "lizard") { Console.WriteLine("The {0} chose Paper",ai.Name); lizard.DisplayWin(player.player1Choice, ai.aiChoice); display.player1Score++; Console.WriteLine("You win!\r\n"); } else if (player.player1Choice == "spock") { Console.WriteLine("The {0} chose Paper", ai.Name); spock.DisplayLoss(player.player1Choice, ai.aiChoice); display.aiScore++; Console.WriteLine("{0} wins!\r\n", ai.Name); } else { Console.WriteLine("You must choose Rock, Paper, Scissors, Lizard, or Spock!\r\n"); } } //scissors else if (ai.aiChoice == "scissors") { if (player.player1Choice == "rock") { //ai scissors, you rock = win display.player1Score++; Console.WriteLine("The {0} chose Scissors", ai.Name); rock.DisplayLoss(player.player1Choice, ai.aiChoice); Console.WriteLine("{0} wins!\r\n", ai.Name); } else if (player.player1Choice == "paper") { //ai scissors, you paper = lose display.aiScore++; Console.WriteLine("This {0} chose scissors",ai.Name); paper.DisplayLoss(player.player1Choice, ai.aiChoice); Console.WriteLine("{0} wins!\r\n", ai.Name); } else if (player.player1Choice == "scissors") { Console.WriteLine("This {0} chose scissors",ai.Name); Console.WriteLine("It is a tie\r\n"); } else if (player.player1Choice == "lizard") { Console.WriteLine("This {0} chose scissors", ai.Name); lizard.DisplayLoss(player.player1Choice, ai.aiChoice); display.aiScore++; Console.WriteLine("{0} wins!\r\n", ai.Name); } else if (player.player1Choice == "spock") { Console.WriteLine("This {0} chose scissors",ai.Name); spock.DisplayWin(player.player1Choice, ai.aiChoice); display.player1Score++; Console.WriteLine("You win!\r\n"); } else { Console.WriteLine("You must choose Rock, Paper, Scissors, Lizard, or Spock!\r\n"); } } else if (ai.aiChoice == "lizard") { if (player.player1Choice == "rock") { Console.WriteLine("The {0} chose Lizard",ai.Name); rock.DisplayWin(player.player1Choice, ai.aiChoice); display.player1Score++; Console.WriteLine("You win!\r\n"); } else if (player.player1Choice == "paper") { display.player1Score++; Console.WriteLine("The {0} chose Lizard",ai.Name); paper.DisplayLoss(player.player1Choice, ai.aiChoice); display.aiScore++; Console.WriteLine("{0} wins!\r\n", ai.Name); } else if (player.player1Choice == "scissors") { display.aiScore++; Console.WriteLine("The {0} chose Lizard", ai.Name); scissors.DisplayWin(player.player1Choice, ai.aiChoice); display.player1Score++; Console.WriteLine("You win!\r\n"); } else if (player.player1Choice == "lizard") { Console.WriteLine("The {0} chose Lizard",ai.Name); Console.WriteLine("It is a tie."); Console.WriteLine(Environment.NewLine); } else if (player.player1Choice == "spock") { Console.WriteLine("The {0} chose Lizard",ai.Name); spock.DisplayLoss(player.player1Choice, ai.aiChoice); display.aiScore++; Console.WriteLine("{0} wins!\r\n", ai.Name); } else { Console.WriteLine("You must choose Rock, Paper, Scissors, Lizard, or Spock!\r\n"); } } else if (ai.aiChoice == "spock") { if (player.player1Choice == "rock") { Console.WriteLine("The {0} chose Spock",ai.Name); rock.DisplayLoss(player.player1Choice, ai.aiChoice); display.aiScore++; Console.WriteLine("{0} wins!\r\n", ai.Name); } else if (player.player1Choice == "paper") { display.player1Score++; Console.WriteLine("The {0} chose Spock",ai.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 Spock",ai.Name); scissors.DisplayLoss(player.player1Choice, ai.aiChoice); Console.WriteLine("{0} wins!\r\n", ai.Name); } else if (player.player1Choice == "lizard") { display.player1Score++; Console.WriteLine("The {0} chose Spock",ai.Name); lizard.DisplayWin(player.player1Choice, ai.aiChoice); Console.WriteLine("You win!\r\n"); } else if (player.player1Choice == "spock") { Console.WriteLine("The {0} chose Spock",ai.Name); Console.WriteLine("It is a tie.\r\n"); } else { Console.WriteLine("You must choose Rock, Paper, Scissors, Lizard, or Spock!\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 { } } } }