public void Run() { do { //splash screen ASCIIBattleShip.Welcome(); ASCIIBattleShip.Bship(); Console.WriteLine("Hit any key to continue"); Console.ReadKey(); Console.Clear(); //getting players names Console.WriteLine("Battleship is a 2 player HUMAN game."); Player PlayerOne = new Player(); PlayerOne.PlayerName = GameFlowHelper.GetStringFromUser("HUMAN ONE: What is your name?"); Console.Clear(); Console.WriteLine($"Thank you HUMAN {PlayerOne.PlayerName}"); Player PlayerTwo = new Player(); PlayerTwo.PlayerName = GameFlowHelper.GetStringFromUser("HUMAN TWO: What is your name?"); Console.Clear(); Console.WriteLine($"Thank you HUMAN {PlayerTwo.PlayerName}, hand the COMPUTER to HUMAN {PlayerOne.PlayerName} so they may set up their board."); Console.ReadKey(); Console.Clear(); //Setting up the board P1 Console.WriteLine($"HUMAN {PlayerOne.PlayerName} it's time to set up your board!"); PlayerOne.PlayerBoard = PlayerOneBoard.SetupPOneBoard(); Console.WriteLine($"Great! Now press any key and hand the COMPUTER to HUMAN {PlayerTwo.PlayerName}"); Console.ReadKey(); Console.Clear(); //Setting up the board P2 Console.WriteLine($"HUMAN {PlayerTwo.PlayerName} it's time to set up your board!"); PlayerTwo.PlayerBoard = PlayerTwoBoard.SetupPTwoBoard(); //Decides who plays first int whoGoesFirst = GameFlowHelper.WhoGoesFirst(); if (whoGoesFirst == 1) { GameFlowHelper.Turns(PlayerOne, PlayerTwo); } else { GameFlowHelper.Turns(PlayerTwo, PlayerOne); } }while (GameFlowHelper.PlayAgain("Do you want to play agian [Y/N]?")); }
public static void PlaceBattleshipP1(Board playerOneBoard) { ASCIIBattleShip.Bship(); while (true) { int CoorX; int CoorY; ShipDirection DirectionOne; Console.WriteLine("We will set up the Battleship (4 spaces long) ship now."); GameFlowHelper.GetCoorFromUser("What row LETTER (A-J) AND column NUMBER (1-10) would you like to place your ship on?"); CoorX = GameFlowHelper.GetXcoor(); CoorY = GameFlowHelper.GetYCoor(); DirectionOne = GameFlowHelper.GetDirectionFromUser("Great! Now what direction would you like to place your ship? (Up, Down, Left, Right"); var request = new PlaceShipRequest() { Coordinate = new Coordinate(CoorX, CoorY), Direction = DirectionOne, ShipType = ShipType.Battleship }; ShipPlacement help = new ShipPlacement(); help = playerOneBoard.PlaceShip(request); switch (help) { case ShipPlacement.NotEnoughSpace: Console.WriteLine("Not enough space, try again"); continue; case ShipPlacement.Overlap: Console.WriteLine("Ship overlap, try again"); continue; case ShipPlacement.Ok: break; } Console.Clear(); break; } }