feat(client): GM wall editor, round-1 fields (#73)

Draw, select, edit and delete walls through the GM panel: the four 5.8
presets, raw switches (preset XOR raw, open excluded from wall.update), a
private label, the one-way arrow + flip (sight_dir names the blind side),
the player-marker switch, door open/close through door.set, secret/locked
with the locked hint and one-click unlock, delete and single-step undo.
No thickness, height or position-flip control (ADR-0012).

The pure rules and payload builders live in src/wallEditor.ts; the GM wall
slice (src/slices/walls.ts) owns the server records, selection and undo;
the render module draws on the gm layer and defines the input precedence:
token drag (#72) > armed wall draw > camera pan (#69), with a click (no
movement) selecting the nearest wall.

Shared core edits: client/src/reducer.ts gains the wall-select and
wall-record-undo events (the only new core events); style.css and the
client README document the panel and rules. Unit tests cover the slice,
presets, derived kind, arrow side, snapping, payload XOR, door intent and
undo builders; the e2e draws every preset, edits the fields, flips the
one-way wall, opens/closes a door, deletes and undoes, proves a token drag
still wins over draw mode, and probes the player's fog pixels, with the
player WS leaking no wall data.

Ref #73
This commit is contained in:
2026-11-21 11:26:45 +01:00
parent 2d9548c941
commit 91a51c706d
9 changed files with 2425 additions and 0 deletions
+35
View File
@@ -138,6 +138,41 @@ change them only if a slice needs a new *core* event, and say so in the PR.
so the gate is measured at real CPU and gate (b), the real-phone run (#77), remains authoritative
for phone speed.
## GM wall editor, round-1 fields (T10, #73)
- **State**: `src/slices/walls.ts` is the GM wall slice: `walls` (full snapshot on connect/resync),
`wall` (upsert, doors included) and `wall_gone`, plus the editor's selected id and its single-step
undo descriptor. Wall frames are GM-only, and the slice also ignores them on a player-shaped
session, so a server bug could not quietly turn the client into a wall-data renderer. `hello`
resets it like every slice.
- **Pure rules**: `src/wallEditor.ts` expands the four 5.8 presets (`wall`, `door`, `window`,
`one_way`), derives `kind` in the fixed order (window, one_way, door, wall, else custom), computes
the one-way arrow toward the blind side named by `sight_dir`, snaps to endpoints then the grid,
and builds the exact DESIGN 6.1 payloads. A preset payload carries only `preset` (never a raw
switch, `open:false` included); `wall.update` never carries `open` because opening and closing are
`door.set`. The same module holds the local pre-flight validation so an impossible combination is
shown before an intent leaves the browser.
- **Renderer + input**: `src/render/modules/walls.ts` draws each wall on the `gm` layer (derived-kind
colour, open doors dashed, secret doors dotted, selected endpoints, the one-way arrow and the
marker switch). Input precedence is explicit: token drag (#72) wins first and consumes its
gesture; wall drawing wins next while a preset is armed (the two clicks never pan); otherwise the
camera (#69) pans and a click with no movement selects the nearest wall. A drag that moved is a
pan, not a selection. The canvas publishes `data-walls`, `data-wall-kinds`, `data-wall-selected`,
`data-wall-arrows`, `data-wall-markers`, `data-wall-draw`, `data-wall-preview` and `data-wall-undo`
for the e2e.
- **Panel**: `src/panels/walls.ts` adds `#gm-walls` under `#panels` via the render module (no shared
bootstrap edit): preset buttons arm the draw, then the selected wall exposes its server-derived
kind, label, `player_marker`, door/open/close, `secret`/`locked`, the advanced raw switches (with
`Apply switches`), the one-way flip, delete and Undo. A locked or secret door's open action shows
`locked: unlock first` / `secret: clear secret first` and the one click that clears the block
instead of sending a refused intent. No thickness, height or position control (ADR-0012).
- **Proof**: `test/walls.test.ts` (slice load/upsert/remove/reset, player frames ignored, preset
expansion, derived kind, arrow side, snap, payload XOR rules, `open` excluded from updates, undo
intents, local validation) and `e2e/walls.test.mjs` (real server: draw all four presets, label,
marker, locked hint + one-click unlock, open/close, advanced invalid combination shown, delete +
undo, a token drag still beats draw mode, and the player's fog pixels change for a wall, a one-way
flip, a door open/close and the marker, with no wall data in the player's frames).
## Tokens, labels, statuses and the two lists (T8, #71)
- **State**: `src/slices/tokens.ts` (`token` upsert, `token_gone`, `hello` reset; `tokensOf`),