Skip to content

Disable marking before first reveal#11

Merged
mellonis merged 2 commits into
masterfrom
fix/disable-pre-mark
May 18, 2026
Merged

Disable marking before first reveal#11
mellonis merged 2 commits into
masterfrom
fix/disable-pre-mark

Conversation

@mellonis

Copy link
Copy Markdown
Owner

Summary

  • Minesweeper#mark() is now a no-op until the field is filled. Pre-fill flags could land on non-mine cells (mine placement only excluded the 3×3 around the first click, not pre-marks), blocking the win condition.
  • Drops #preMarks, the replay loop in reveal(), and the pre-fill branch of getSnapShot(). After-game marks were already blocked by the existing #isGameOver guard.
  • Adds src/minesweeper/minesweeper.spec.ts with three cases covering the new behaviour. ts-jest config tweaked so the spec compiles against ES2020.
  • CLAUDE.md updated.

Closes #10.

Test plan

  • npm test — 19/19 passing, including the new minesweeper.spec.ts
  • npm run lint — clean
  • npm run build — clean
  • Manual: right-click before first reveal does nothing (no flag drawn, marksLeft counter still shows 888 because timer hasn't started)
  • Manual: normal flag/unflag after first reveal still works

mellonis added 2 commits May 18, 2026 12:42
A flag placed before the first reveal could land on a non-mine cell —
mine placement only excluded the 3×3 around the first click, not pre-marks.
The bogus flag blocked the win condition: marksLeft hit 0 but the game
stayed in play state until the player guessed to unmark and reveal.

mark() is now a no-op when the field isn't filled yet. Drops the #preMarks
Set, the replay loop in reveal(), and the synthesized pre-fill snapshot
branch. After-game marking was already blocked by the existing
isGameOver guard.

Refs #10
Runs lint+test+build on every pull_request. CD (cd.yml) continues to
handle master pushes and the rsync to the VPS.
@mellonis mellonis merged commit 2739156 into master May 18, 2026
1 check passed
@mellonis mellonis deleted the fix/disable-pre-mark branch May 18, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pre-fill marks on non-mine cells block winning

1 participant