public static bool Tutorial() { while (true) { Console.Clear(); Console.Write("Would you like a quick tutorial? (Y or N) : "); var tutorialInput = Console.ReadLine(); if (tutorialInput == "y" || tutorialInput == "Y") { Console.Clear(); Console.WriteLine("\n***************************************************************************************************************"); Console.WriteLine("The Game is simple, you will be prompted to select a point on a 10 x 10 grid."); Console.WriteLine("The point is made up of an X-value and a Y-value that represent one square of the grid...Please see below"); Console.WriteLine("\n"); GameGrid.PrintGrid(); Console.WriteLine("\n"); Console.WriteLine("Once the point is selected you will be prompted with a hit or miss."); Console.WriteLine("You will be given a total of 8 guesses. If you do not destroy the enemy vessel..."); Console.WriteLine("You are probably a fit for the 1588 spanish armada and lose the game."); Console.WriteLine("However if you annihalate the enemy which takes up 5 grid spaces you win!"); Console.WriteLine("After which you can gloat to your friends and family, and garner the respect of your peers"); Console.WriteLine("***************************************************************************************************************"); Console.WriteLine("\nPress any key and lets fire up the boilers and ship off!"); Console.ReadLine(); return(true); } else if (tutorialInput == "n" || tutorialInput == "N") { Console.Write("\nLooks like we got ourselves a hero! Press Enter and lets see what you got!"); Console.ReadLine(); return(true); } else { Console.Write("Incorrect Input ensign! Press Enter to resume!"); Console.ReadLine(); } } }
public GameLogic(GameGrid gameGrid) { _gameGrid = gameGrid; }
public static void PlayBattleShip() { int shotsFired = 0; int NumberOfHits = 0; int NumberOfMisses = 0; int XValue; int YValue; while (true) { Console.Clear(); Console.Write("Shots Remaining = " + (8 - shotsFired)); Console.Write(" Hits = " + NumberOfHits); Console.Write(" Misses = " + NumberOfMisses + "\n"); GameGrid.PrintGrid(); Console.Write("\n(X-axis) - Select a spot [1-10] to fire upon : "); while (!int.TryParse(Console.ReadLine(), out XValue)) { Console.Clear(); Console.WriteLine("---------Input needs to be a number!!---------\n"); Console.Write("Shots Remaining = " + (8 - shotsFired)); Console.Write(" Hits = " + NumberOfHits); Console.Write(" Misses = " + NumberOfMisses + "\n"); GameGrid.PrintGrid(); Console.Write("\n(X-axis) - Select a spot [1-10] to fire upon : "); } Console.Write("\n(Y-axis) - Select a spot [1-10] to fire upon : "); while (!int.TryParse(Console.ReadLine(), out YValue)) { Console.Clear(); Console.WriteLine("---------Input needs to be a number!!---------\n"); Console.Write("Shots Remaining = " + (8 - shotsFired)); Console.Write(" Hits = " + NumberOfHits); Console.Write(" Misses = " + NumberOfMisses + "\n"); GameGrid.PrintGrid(); Console.Write("\n(X-axis) - Select a spot [1-10] to fire upon : " + XValue + "\n"); Console.Write("\n(Y-axis) - Select a spot [1-10] to fire upon : "); } if (!GameDecision.InputValidation(XValue, YValue)) { Console.Clear(); Console.WriteLine("\nIncorrect Input ensign! Numbers from 1 - 10!!!! Press Enter to resume!\n"); Console.ReadLine(); } else { if (GameDecision.DetermineIfGuessed(XValue, YValue, shotsFired)) { Console.Write("\nRookie mistake ensign! Choose a spot you haven't already shot at! Press Enter to resume!"); Console.ReadLine(); Console.Clear(); } else { if (GameDecision.DetermineHit(XValue, YValue)) { NumberOfHits++; Console.WriteLine("\nHit!\n"); Console.Write("Press Enter to resume!"); Console.ReadLine(); } else { NumberOfMisses++; Console.WriteLine("\nMiss!\n"); Console.Write("Press Enter to resume!"); Console.ReadLine(); } GameGrid.EditGrid(XValue, YValue, GameDecision.DetermineHit(XValue, YValue)); shotsFired++; } } if (NumberOfHits == 5) { PlayAgain = false; Console.Clear(); GameGrid.PrintGrid(); Console.WriteLine("\nCongratulations!! Youve Sunk the Battleship!"); break; } else if (shotsFired == 8) { PlayAgain = false; Console.Clear(); Console.Write("Shots Remaining = " + (8 - shotsFired)); Console.Write(" Hits = " + NumberOfHits); Console.Write(" Misses = " + NumberOfMisses + "\n"); GameGrid.PrintGrid(); Console.WriteLine("\nYou Lost!"); Console.WriteLine("Better Luck Next Time!"); break; } else if (shotsFired == 4 && NumberOfMisses == 4) { bool restart = false; while (true) { Console.Clear(); Console.Write("\nListen kid, I'm going to be real with you..."); Console.Write("You're not going to win. Do you just want to restart? (Y or N) : "); var PlayerInput = Console.ReadLine(); if (PlayerInput == "y" || PlayerInput == "Y") { restart = true; break; } else if (PlayerInput == "n" || PlayerInput == "N") { restart = false; break; } else { Console.Write("\nIncorrect Input press Enter to resume."); Console.ReadLine(); } } if (restart) { PlayAgain = true; break; } } } }
public Prompts(GameGrid gameGrid) { _gameGrid = gameGrid; }