Exemple #1
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(80, 40);
            bool playAgain = true;
            string playersName;
            String[] logo = File.ReadAllLines("Logo.txt");
            StringBuilder logoSB = new StringBuilder();
            foreach (string line in logo)
                logoSB.AppendLine(line);

            while (playAgain)
            {
                Game.winner gameWinner = Game.winner.none;
                bool playersTurn = true;
                Game.resultOfShot shotHit;
                Console.Clear();
                Console.WriteLine(logoSB);

                playersName = PromptForName();
                Game game = new Game(PromptStandardGame());

                while (gameWinner == Game.winner.none)
                {
                    game.DisplayGrids();
                    shotHit = game.NextShot(playersTurn);
                    game.DisplayGrids();
                    DisplayShotMessage(shotHit, playersTurn, playersName);
                    gameWinner = game.SunkAllBattleships();
                    playersTurn = !playersTurn;
                }
                Console.Clear();
                game.DisplayGrids();
                DisplayEndMessage(gameWinner);
                playAgain = PromptPlayAgain();
            }
        }