candycore / candy-mines
Minesweeper TUI — port of maxpaulus43/go-sweep on the SugarCraft stack.
v0.2.0
2026-05-07 01:29 UTC
Requires
- php: >=8.1
- sugarcraft/candy-core: @dev
- sugarcraft/candy-sprinkles: @dev
Requires (Dev)
- phpunit/phpunit: ^10.0
This package is not auto-updated.
Last update: 2026-05-08 01:48:35 UTC
README
CandyMines
Minesweeper on the SugarCraft stack — port of maxpaulus43/go-sweep. Customisable board, recursive flood-fill, win / lose detection, vim-style movement.
Run it
composer install
./bin/candy-mines [width] [height] [mines] # defaults: 10 10 12
Keys
| Key | Action |
|---|---|
↑/↓/←/→ or hjkl |
Move cursor |
Space / Enter |
Reveal cell |
f |
Toggle flag |
r |
Restart with new mines |
q / Esc |
Quit |
Architecture
Three pure-state classes plus the runtime Model and a one-pass renderer:
| File | Role |
|---|---|
Cell |
Value object — mine / revealed / flagged / adjacent count |
Board |
The grid + every transition (reveal, flag, flood-fill). PRNG injected as Closure(int):int for deterministic tests |
Game (Model) |
Cursor + key routing + restart + win/lose gate |
Renderer |
Pure view function. CandySprinkles Style + Border::rounded() |
The first reveal is always safe — mines are placed only after click 1, with the clicked cell's 3×3 neighbourhood excluded so the player gets a non-trivial flood-fill on every game.
Test
composer install vendor/bin/phpunit
