static void Main(string[] args) { string playAgain; Console.ForegroundColor = ConsoleColor.DarkRed; //Print the game title Console.WriteLine(gameTitle); do { Console.Write("New Game? y/n :"); playAgain = Console.ReadLine(); switch (playAgain) { case "y": case "Y": startNewGame newGame = new startNewGame(); Console.WriteLine("The game has started..."); newGame.newGame(); break; case "n": case "N": Console.WriteLine(""); break; default: Console.WriteLine("{0} is not a valid choice", playAgain); break; } }while(playAgain != "n" && playAgain != "N"); //Exit the application }
static void Main(string[] args) { string playAgain; Console.ForegroundColor = ConsoleColor.DarkRed; //Print the game title Console.WriteLine(gameTitle); do { Console.Write("New Game? y/n :"); playAgain = Console.ReadLine(); switch (playAgain) { case "y": case "Y": startNewGame newGame = new startNewGame(); Console.WriteLine("The game has started..."); newGame.newGame(); break; case "n": case "N": Console.WriteLine(""); break; default: Console.WriteLine("{0} is not a valid choice", playAgain); break; } }while(playAgain != "n" && playAgain != "N"); //Exit the application }
public void newGame() { string myChoice; int numberOfchambers; int bulletChamber; int chamber; startNewGame theGame = new startNewGame(); numberOfchambers = 6; bulletChamber = theGame.setBulletChamber(numberOfchambers); chamber = theGame.setChamber(numberOfchambers); do { //Get the player choice myChoice = theGame.playerChoice(); switch (myChoice) { //Spin case "1": Console.WriteLine("\r\nYou spin the barrel\r\n"); //Reset odds bulletChamber = theGame.setBulletChamber(numberOfchambers); break; //Shoot case "2": if (bulletChamber == chamber) { Console.WriteLine("\r\nBang! You're dead!"); theGame.thePlayer = 0; } else { Console.WriteLine("\r\nYou live.... This time.\r\n"); if (chamber < 5) { chamber = ++chamber; } else { chamber = 0; } } break; //Shoot captor in the face case "3": Console.WriteLine("With shaky hand you aim your gun at your captor....\r\n"); Console.WriteLine("Press enter to continue.."); Console.ReadLine(); if (bulletChamber == chamber) { Console.WriteLine("You pull the trigger and BAM! You kablowed your captors head clear off!\r\n"); Console.WriteLine("Congradulations! You won!"); theGame.thePlayer = 2; } else { Console.WriteLine("You pull the trigger... and click, Your captor knows you tried to kill him and kablow your head esploded!\r\n"); Console.WriteLine("You loser, you lost the game!"); theGame.thePlayer = 0; } break; } }while(theGame.thePlayer != 0 && theGame.thePlayer != 2); }
public void newGame() { string myChoice; int numberOfchambers; int bulletChamber; int chamber; startNewGame theGame = new startNewGame(); numberOfchambers = 6; bulletChamber = theGame.setBulletChamber(numberOfchambers); chamber = theGame.setChamber(numberOfchambers); do { //Get the player choice myChoice = theGame.playerChoice(); switch (myChoice) { //Spin case "1": Console.WriteLine("\r\nYou spin the barrel\r\n"); //Reset odds bulletChamber = theGame.setBulletChamber(numberOfchambers); break; //Shoot case "2": if (bulletChamber == chamber) { Console.WriteLine("\r\nBang! You're dead!"); theGame.thePlayer = 0; } else { Console.WriteLine("\r\nYou live.... This time.\r\n"); if (chamber < 5) { chamber = ++chamber; } else { chamber = 0; } } break; //Shoot captor in the face case "3": Console.WriteLine("With shaky hand you aim your gun at your captor....\r\n"); Console.WriteLine("Press enter to continue.."); Console.ReadLine(); if (bulletChamber == chamber) { Console.WriteLine("You pull the trigger and BAM! You kablowed your captors head clear off!\r\n"); Console.WriteLine("Congradulations! You won!"); theGame.thePlayer = 2; } else { Console.WriteLine("You pull the trigger... and click, Your captor knows you tried to kill him and kablow your head esploded!\r\n"); Console.WriteLine("You loser, you lost the game!"); theGame.thePlayer = 0; } break; } }while(theGame.thePlayer != 0 && theGame.thePlayer != 2); }