feat: implement game-like LU trainer and companion map

This commit is contained in:
nyan404 committed 2026-11-17 16:24:02 +03:00
1 parent 87d5a6720f
commit 74c8504d52
21 files changed
+1160 -14

No files matched your search

@@ -0,0 +1,18 @@
# LU trainer implementation plan
Spec: ../specs/2026-11-17-lu-trainer.md and root LU_TRAINER_PROJECT.md (owner requested implementation).
- [x] T1: Pure training engine and deterministic acceptance
goal: preserve documented training rules and hide unknown facts in public snapshots.
files: web/lu-trainer/engine.js, tests/lu-trainer/engine.test.mjs
acceptance: node --test tests/lu-trainer/engine.test.mjs
- [x] T2: Game screen, original art and synchronized companion map
goal: implement three-column forest training with accessible compact controls and dialogs.
files: web/lu-trainer.html, web/lu-trainer/style.css, web/lu-trainer/ui.js, web/lu-trainer/assets
acceptance: browser interaction suite and inspected renders at all four specified sizes, zoom, reduced motion, broken images.
- [x] T3: Routing, documentation and final review
goal: make page available through Python and gateway, document scope and checks, commit without push.
files: app/main.py, nginx.conf, web/index.html, tests/test_lu_trainer.py, tests/browser/lu-trainer.cjs, README.md, AGENTS.md, MEMORY.md, structure_and_data.md, project_mind_map.md, LU_TRAINER_PROJECT.md
acceptance: targeted HTTP tests, Nginx syntax/serving, JS syntax, diff check, spec/diff review; temporary environments cleaned.
Final review: approved root scope implemented. Spec compliance/consistency review resolved temporary hint disclosure and terminal controls. Source/diff review found and fixed overlapping hint expiry and result-inspection timer advancement. JS syntax, Python source compilation, 9 engine tests, 5 focused HTTP/calculator-page tests, Chromium acceptance and isolated Nginx syntax/alias/MIME checks passed. No runtime dependency, API, storage or production change. Check record and environment limits: root structure_and_data.md.
@@ -0,0 +1,14 @@
# LU trainer implementation
Authorization: the owner requested implementation of root `LU_TRAINER_PROJECT.md` on 2026-11-17. That existing design is the approved specification; this file records implementation choices within its scope.
contract: standalone `/lu-trainer` and `/lu-trainer/`, shared HTML/CSS/ES-module assets served by Python and Nginx. No new runtime dependency or storage. Gateway serves the page with `try_files`; assets use the existing static serving.
convention: native buttons/radios/dialogs, CSS tokens, Verdana/Georgia, Russian copy, DOM-independent ES-module engine, no upstream code or asset copying.
state: engine owns 60 cells, hazards, opened set, marks set, last successful position, ready/playing/won/lost status and action log. A public snapshot omits hidden hazards/values. UI owns selection, action mode, map visibility and mark projection.
invariant: 6x10, entrance (5,0), exit (3,9); transition cells do not count toward victory and cannot be opened/marked. Top-row first 5/3 cells are safe and initially available; any other cell requires an opened neighbor. Eight-neighbor counts; safe path connects entrance, base and exit. Preserve documented hazard formula and 0/10/20/30% hint probabilities. Win by all non-transition safe cells or all and only hazards marked; loss ends actions. Repeat safe visits produce feedback and may hint. The character tracks the last successful non-transition visit.
invariant: one click produces one action; map selection never jumps; marks are separate from facts. Projection only changes scene rendering. Confirm clear marks and restart, including settings restart. Ending/restarting cancels hint and timer callbacks. At completion reveal the whole board, including incorrect notes.
contract: desktop direct cell action; compact/coarse-pointer overview selects only and uses >=44px confirm controls. Arrow/Home/End navigation and Enter/Space work. Screen-reader live status excludes timer ticks. Map/history mobile panels restore focus. Native dialogs support Escape/cancel. Failed images leave cells and character fallback usable.
test: deterministic Node tests for generator safety/reachability/counts, all settings combinations, adjacency, transition exclusion, notes, win/loss, hints and public snapshots. HTTP test for aliases and asset MIME/containment. Browser checks at 1920x1080,1366x768,768x1024,390x844; two grids, logs, marks, confirmations, focus, keyboard/touch, reduced motion, 200% layout and image failures. Review real screenshots. Nginx syntax/serving check in isolated container if Docker available; no deployment.
deferred: verification of real CatWar rules, multiple saved maps, audio, server accounts, deployment. Generated original art provenance and prompts live in assets/README.md.
Review: spec-compliance/consistency review closed the hint and terminal-action gaps. Hints intentionally return a temporary hazard ID in action results only (not hidden snapshot values), last 2000 ms and retain their coordinate in the readable message log. Only unmarked neighboring hazards are candidates. At completion marking/clearing are disabled; selection remains available for inspection. Defaults: height 1, LU 5, growth 12, season 0; growth accepts 12/15/18/22/25 and season -3/0/5.