minor changes to the rules
This commit is contained in:
parent
bf1ba1ae0e
commit
bbcd7d4fa1
@ -20,6 +20,10 @@ R to restart.
|
|||||||
P to pause.
|
P to pause.
|
||||||
Q to quit.
|
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
|
## Compilation
|
||||||
|
|
||||||
By default, the Makefile compiles in debug mode, so to compile both, use `make both`.
|
By default, the Makefile compiles in debug mode, so to compile both, use `make both`.
|
||||||
|
14
src/main.cpp
14
src/main.cpp
@ -167,6 +167,8 @@ void startGame(Board &board)
|
|||||||
board.revealCellAt(cursorX, cursorY);
|
board.revealCellAt(cursorX, cursorY);
|
||||||
break;
|
break;
|
||||||
case 'x':
|
case 'x':
|
||||||
|
if (board.getCellStateAt(cursorX, cursorY) == Cell::State::Revealed)
|
||||||
|
break;
|
||||||
if (!somethingHasBeenDone)
|
if (!somethingHasBeenDone)
|
||||||
{
|
{
|
||||||
startTime = time(nullptr);
|
startTime = time(nullptr);
|
||||||
@ -202,12 +204,24 @@ void startGame(Board &board)
|
|||||||
isPaused = !isPaused;
|
isPaused = !isPaused;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
|
if (board.getCellStateAt(cursorX, cursorY) != Cell::State::Revealed)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (!somethingHasBeenDone)
|
if (!somethingHasBeenDone)
|
||||||
{
|
{
|
||||||
startTime = time(nullptr);
|
startTime = time(nullptr);
|
||||||
somethingHasBeenDone = true;
|
somethingHasBeenDone = true;
|
||||||
}
|
}
|
||||||
auto neighbors = board.getNeighborsOf(cursorX, cursorY);
|
auto neighbors = board.getNeighborsOf(cursorX, cursorY);
|
||||||
|
int flagCount = 0;
|
||||||
|
for (const Cell &neighbor : neighbors)
|
||||||
|
{
|
||||||
|
if (neighbor.getState() == Cell::State::Flagged)
|
||||||
|
flagCount++;
|
||||||
|
}
|
||||||
|
if (static_cast<int>(board.revealCellAt(cursorX, cursorY).getContent()) > flagCount)
|
||||||
|
break;
|
||||||
for (const Cell &neighbor : neighbors)
|
for (const Cell &neighbor : neighbors)
|
||||||
{
|
{
|
||||||
if (neighbor.getState() == Cell::State::Flagged)
|
if (neighbor.getState() == Cell::State::Flagged)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user