Ejemplo n.º 1
0
        private PlayerMove RunGame(PlayerMove userInputMove, IGameGrid currentGameGrid, bool runAtGameStart)
        {
            var cellUpdater      = Factory.NewCellUpdater();
            var mineUpdater      = MineFactory.NewMineChecker();
            var mineGeneration   = MineFactory.NewMineLocations();
            var gameGridDisplay  = GridFactory.NewDisplayGrid();
            var convertUserInput = Factory.NewUserInputConverter();

            if (runAtGameStart)
            {
                mineUpdater.UpdateCellWithMineStatus(mineGeneration.MineLocations(currentGameGrid.Size), currentGameGrid);
                cellUpdater.UpdateAdjacentMineTotalAtGameStart(currentGameGrid);
            }

            do
            {
                Console.Clear();
                Console.WriteLine(gameGridDisplay.GenerateGameDisplay(currentGameGrid));

                var inputMove = _gameMessageDisplay.ShowUserInputMessage(currentGameGrid.Size);

                userInputMove = convertUserInput.ConvertInputToUserMove(inputMove);
            } while (_userInputValidation.IsCellRevealed(currentGameGrid, userInputMove));

            cellUpdater.UpdateDisplayStatusAfterUserMove(userInputMove, currentGameGrid);

            return(userInputMove);
        }