private static bool AddShips(BattleShips battleShips, DbContextOptions <ApplicationDbContext> dbOptions) { var wantsToQuit = false; int unAddedShipCount; do { Console.Clear(); var player = battleShips.GetPlayer(true); Console.WriteLine($"{player.Name} choose a ship to add:"); var gameShips = battleShips.GetUnaddedGameShips(); var gameShip = BattleShipsConsoleUi.DrawShipList(gameShips, player.Name); var(x, y) = GetCoordinates( battleShips, gameShip.Size, true); if (x == 100 && y == 100) { SaveGameMenu(battleShips, dbOptions); wantsToQuit = true; break; } var isHorizontal = BattleShipsConsoleUi.IsShipHorizontal; battleShips.AddShips(gameShip, x, y, isHorizontal); unAddedShipCount = battleShips.GetUnaddedGameShips().Count; } while (unAddedShipCount > 0); return(wantsToQuit); }
public static void GameOverUi(BattleShips battleShips) { var exit = true; do { Console.Clear(); DrawBoard(battleShips, (0, 0), false, false, 0); Console.BackgroundColor = ConsoleColor.Red; Console.WriteLine("GAME OVER"); Console.ResetColor(); Console.WriteLine($"{battleShips.GetPlayer(true).Name} won!"); Console.WriteLine("Press Enter to continue.."); var key = Console.ReadKey(); if (key.Key == ConsoleKey.Enter) { exit = false; } } while (exit); }