diff --git a/README.md b/README.md index 9da6f38..ea3e751 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,10 @@ R to restart. P to pause. Q to quit. +You can't chord if the number isn't equal to the number of flags it's near. +You can't see the board if you're paused to (help) prevent cheating. +You can't flag already revealed cells. + ## Compilation By default, the Makefile compiles in debug mode, so to compile both, use `make both`. diff --git a/src/main.cpp b/src/main.cpp index 7d952cf..1471eb0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -167,6 +167,8 @@ void startGame(Board &board) board.revealCellAt(cursorX, cursorY); break; case 'x': + if (board.getCellStateAt(cursorX, cursorY) == Cell::State::Revealed) + break; if (!somethingHasBeenDone) { startTime = time(nullptr); @@ -202,12 +204,24 @@ void startGame(Board &board) isPaused = !isPaused; break; case 'c': + if (board.getCellStateAt(cursorX, cursorY) != Cell::State::Revealed) + { + break; + } if (!somethingHasBeenDone) { startTime = time(nullptr); somethingHasBeenDone = true; } auto neighbors = board.getNeighborsOf(cursorX, cursorY); + int flagCount = 0; + for (const Cell &neighbor : neighbors) + { + if (neighbor.getState() == Cell::State::Flagged) + flagCount++; + } + if (static_cast(board.revealCellAt(cursorX, cursorY).getContent()) > flagCount) + break; for (const Cell &neighbor : neighbors) { if (neighbor.getState() == Cell::State::Flagged)