コード例 #1
0
ファイル: Program.cs プロジェクト: nicholaskevs/Battleship
        private static void PlayGame()
        {
            string      commandPlay;
            bool        stop = false;
            GameTracker game = new GameTracker();

            PrintPlayHelp();

            while (!stop)
            {
                Console.WriteLine("What to do:");
                commandPlay = Console.ReadLine();
                Console.WriteLine();

                if (commandPlay == "s")
                {
                    game.StartGame();
                }
                else if (commandPlay.Length > 1 && CheckAttackInput(commandPlay))
                {
                    game.PlayerAttack(commandPlay);
                }
                else if (commandPlay == "h")
                {
                    PrintPlayHelp();
                }
                else if (commandPlay == "x")
                {
                    stop = true;
                    Console.WriteLine("Quitting game");
                }
                else
                {
                    Console.WriteLine("ERROR - Invalid Command");
                }
            }
        }