feat: ship 100 Microban levels with overhauled UI and modular core

Replace the 3 hand-crafted JSON levels with the full Microban set (100 solvable
puzzles by David W. Skinner) stored as XSB text and parsed at runtime. Rework
the game into kebab-case modules under a 200-LOC budget:

- core/level-parser: XSB parse with flood-fill interior detection
- core/board-model: pure move/undo/win logic, Phaser-free
- core/progress-store: localStorage persistence with graceful fallback
- core/theme: Nord palette, fonts, responsive tile sizer
- ui/button-factory: one rounded button impl with hover/press
- ui/board-renderer: animated tile/wall/goal/box/player drawing
- scenes: menu, paginated level select (5x4 grid, 5 pages), game

Add WASD movement, U/Z undo, R restart, Esc to menu, live move counter,
best-move tracking per level, win overlay with next/levels actions, and a
radial-gradient CSS backdrop.

Drop the dead Arcade Physics wiring, the broken manual shutdown/destroy code,
the unused main.js self-import, and the hardcoded 3-level registry state.

Add docs/ and refresh README.
This commit is contained in:
tiennm99 committed 2026-04-11 21:58:00 +07:00
1 parent a61d5a2410
commit 1d2fff6bf8
27 files changed
+1866 -881

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
# Code Standards
## Language & Toolchain
- ES modules, modern JS (no TypeScript).
- Phaser 3.88+.
- Vite as build tool. Dev: `npm run dev`. Prod: `npm run build`.
## Naming
- Files: **kebab-case** with descriptive names (`board-renderer.js`, `progress-store.js`).
- Classes: PascalCase (`BoardModel`, `BoardRenderer`).
- Functions and variables: camelCase.
- Constants: UPPER_SNAKE for module-level tuning knobs (`KEY_REPEAT_MS`, `PER_PAGE`).
## File size
- Code files must stay under 200 lines of code.
- Pure-data files (levels, palettes) are exempt.
## Architecture rules
- **Scenes** own lifecycle + layout; they delegate drawing to renderers and logic to models.
- **Core** (`core/`) is pure JS — no Phaser imports. Anything that can be unit-tested without a canvas lives here.
- **UI** (`ui/`) is Phaser-specific but scene-agnostic — reusable widgets and renderers.
- No new dependencies without updating this doc.
## Style
- Prefer composition over inheritance.
- Fail loudly during development (console.error on unexpected state), fail gracefully at runtime (try/catch around level parsing, progress store).
- Comments: short, explain *why*, not *what*. File headers give a one-sentence purpose.
## Git / commits
- Conventional commits (`feat:`, `fix:`, `refactor:`, `docs:`, `chore:`).
- Never commit dotenv, keys, or build artifacts.
- Run `npm run build-nolog` before pushing to catch compile errors.
## Testing strategy (current)
No automated tests yet. Manual smoke test: load menu → play level 1 → complete → verify progress saved in localStorage → reload page → verify completion persists.
Future: unit tests for `level-parser.js` and `board-model.js` (both Phaser-free).