コード例 #1
0
        public static void PlayGame()
        {
            Player p1 = new Player();
            Player p2 = new Player();
            string player1;
            string player2;


            ConsoleOutput.DisplayTitle();
            player1 = ConsoleInput.GetPlayerOneName();
            p1.SetName(player1);
            player2 = ConsoleInput.GetPlayerTwoName();
            p2.SetName(player2);

            Console.Clear();
            p1.PlaceShipOnBoard();
            Console.Clear();
            p2.PlaceShipOnBoard();

            int whoseTurn = _rng.Next(1, 3);

            do
            {
                if (whoseTurn == 1)
                {
                    Console.Clear();
                    p2.DisplayBoard(p1);
                    p2.FireShotAtBoard(p1);
                    whoseTurn = 2;
                }
                else
                {
                    Console.Clear();
                    p1.DisplayBoard(p2);
                    p1.FireShotAtBoard(p2);
                    whoseTurn = 1;
                }
                Console.ReadLine();
            } while (!p1.GetWonGame() && !p2.GetWonGame());
        }