Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            bool playGame = true;

            do
            {
                Game.StartGame();

                // Ask for restart
                Console.WriteLine();
                playGame = DataRequests.RestartMessage();
                Console.Clear();
            } while (playGame == true);
        }
Ejemplo n.º 2
0
        private static void ShipPositions(PlayerInfoModel player)
        {
            ConsoleMessages.PostionMessage(player);
            DisplayShotGrid(player);
            Console.WriteLine();
            Console.WriteLine();

            do
            {
                // Ask player ship-positions
                string shipSpot = DataRequests.AskPlayerShipSpot(player);

                // Store position
                GameLogic.AddShipToGrid(player, shipSpot);
            } while (player.PlayerShipSpot.Count < 5);
        }
Ejemplo n.º 3
0
        private static PlayerInfoModel StartBattle(PlayerInfoModel player, PlayerInfoModel opponent)
        {
            PlayerInfoModel winner = null;

            do
            {
                // DisplayShotGrid(player);
                ConsoleMessages.DisplayPlayerName(player);
                Console.WriteLine();
                DisplayShotGrid(player);
                Console.WriteLine();

                // Ask player shot - validate
                string shot = DataRequests.AskPlayerShotSpot(player);
                Console.WriteLine();


                // Check if it hit a ship or water
                ConsoleMessages.ShowShotResult(player, opponent, shot);

                // Update player shotgrid and opponent ship status
                GameLogic.UpadateGrid(player, opponent, shot);

                // Show opponents remaining ships
                ConsoleMessages.ShowShipsNumber(player, opponent);

                if (GameLogic.RemainingShips(opponent) == 0)
                {
                    winner = player;
                }
                else
                {
                    (player, opponent) = (opponent, player);
                }

                ConsoleMessages.PressAnyKeyMessage();
                Console.Clear();
            } while (winner == null);

            return(winner);
        }