Example #1
0
        public void Start()
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.WriteLine("Lets play battleship!");

            do
            {
                Grid playerGrid, enemyGrid;

                var gameType = RequestEnum <GameType>("Do you want to play a standard or custom game?");
                switch (gameType)
                {
                case GameType.Standard:
                    playerGrid = _gridService.Create();
                    enemyGrid  = _gridService.Create();

                    SetUpStandardGame(playerGrid, enemyGrid);
                    break;

                case GameType.Custom:
                    int width  = RequestInt("Please enter grid width:");
                    int height = RequestInt("Please enter grid height:");

                    playerGrid = _gridService.Create(width, height);
                    enemyGrid  = _gridService.Create(width, height);

                    SetUpCustomGame(playerGrid, enemyGrid);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                PlayGame(playerGrid, enemyGrid);
            } while (RequestBool("Do you want to play again?"));

            Console.WriteLine();
            Console.WriteLine("Thanks for playing!");
            Console.ReadLine();
        }