Exemplo n.º 1
0
        public void Play()
        {
            while (BoardIsNotRevealed())
            {
                var newLocation = CreateLocationBasedOnInput();

                RevealTheSquareIfLocationIsOnBoard(newLocation);

                if (WinLoseChecker.IsLosingConditionWhenOneMineIsRevealed(Board))
                {
                    _output.Write(GameInstruction.GameOverMessage);
                    Board.RevealAllSquares();
                    State = GameState.Lose;
                    _output.Write(GameInstruction.ResultMessage + State);
                }
                else if (WinLoseChecker.IsWinningConditionWhenAllHintsAreRevealed(Board))
                {
                    _output.Write(GameInstruction.GameOverMessage);
                    Board.RevealAllSquares();
                    State = GameState.Win;
                    _output.Write(GameInstruction.ResultMessage + State);
                }

                _output.Write(GameInstruction.DisplayCurrentBoardMessage);
                DisplayBoard();
            }
        }
Exemplo n.º 2
0
        public void IsWinningConditionShould_ReturnFalse_WhenOneHintsOnBoardIsRevealed()
        {
            var board         = Board.CreateEmptyBoard(2);
            var mineGenerator = new MockMinesGenerator();

            mineGenerator.PlaceMines(2, board);
            var bottomLeft = new Location(1, 0);
            var hintOne    = board.GetSquare(bottomLeft);

            hintOne.Reveal();
            var result = WinLoseChecker.IsWinningConditionWhenAllHintsAreRevealed(board);

            Assert.False(result);
        }