feat(client): tokens, BitmapText labels, statuses and lists (#71)
- slices/tokens.ts: token upsert, token_gone, hello reset; status names only. - slices/characters.ts + slices/encountered.ts: own characters, encountered list with grey entries; the GM's per-player copies are ignored. - render/tokenBoard.ts (pure): event -> entered/updated/left patches, so one changed token costs one container; seeds from the reducer on mount. - render/modules/tokens.ts: pooled world-coordinate nodes on the tokens layer, one shared unit-circle context per kind, BitmapText from one pre-installed BitmapFont assigned only on a name change, stuck/squeezed badges, canvas dataset instrumentation for the "only changed entities" criterion. - panels/lists.ts + render/modules/lists.ts: #lists under #panels, textContent only, greyed encountered rows; mounted by a render module so no shared bootstrap file changed.
This commit is contained in:
@@ -99,3 +99,39 @@ change them only if a slice needs a new *core* event, and say so in the PR.
|
||||
`e2e/session.test.mjs` kills and restarts the real server under a live page, drops the browser
|
||||
network with `context.setOffline`, asserts the badge transitions and the full resync frames, and
|
||||
runs two pages on one key.
|
||||
|
||||
## Tokens, labels, statuses and the two lists (T8, #71)
|
||||
|
||||
- **State**: `src/slices/tokens.ts` (`token` upsert, `token_gone`, `hello` reset; `tokensOf`),
|
||||
`src/slices/characters.ts` (`character`/`character_gone`, `ownCharactersOf`) and
|
||||
`src/slices/encountered.ts` (`full` replace, `set`/`del` diff, grey flag; the GM's per-player
|
||||
copies are ignored). All three are append-only slice files: the registry and `main.ts` are
|
||||
untouched.
|
||||
- **Renderer**: `src/render/tokenBoard.ts` is the pure half. It turns the store's *events* into the
|
||||
exact nodes to touch — `entered`, `updated`, `left`, or a `hello` reset — and keeps the view it
|
||||
last drew, so a frame that moves one token updates one container and nothing else (DESIGN 7.2).
|
||||
It also seeds itself from the reducer on mount, because `app.init()` is async and the resync can
|
||||
beat the stage. `src/render/modules/tokens.ts` is the Pixi half: pooled containers on the
|
||||
`tokens` layer **in world coordinates** (the camera from #69 transforms the layer's parent, never
|
||||
a token), one shared unit-circle `GraphicsContext` per kind scaled to the effective radius, and
|
||||
`BitmapText` labels from one pre-installed `BitmapFont` (`fff-token-label`: Latin, accented Latin
|
||||
and ASCII) assigned only when the name actually changed. `stuck` and `squeezed` are drawn badges
|
||||
(barred ring, inward brackets); the cause is never drawn because a player never receives it.
|
||||
- **Instrumentation** for the "only changed entities touched" acceptance criterion lives on the
|
||||
canvas dataset: `data-tokens`, `data-token-entered`, `data-token-updated`, `data-token-left`,
|
||||
`data-token-labels`, `data-token-ids`, `data-token-statuses`. It is updated only when a patch did
|
||||
something, and `e2e/tokens.test.mjs` reads it against the real server.
|
||||
- **Lists panel**: `src/panels/lists.ts` (`#lists` under the shell's `#panels`: `#characters`,
|
||||
`#encountered`, rows with `data-character`/`data-token` and `data-grey`, `textContent` only) is
|
||||
mounted by `src/render/modules/lists.ts`, a render module, so the panel's lifetime is the live
|
||||
stage's and no shared bootstrap file had to change. Greyed rows carry both `data-grey="true"` and
|
||||
the `grey` class, plus an "out of sight" label so the state is not colour-only.
|
||||
- **Drag seam (#72)**: `applyView(node, view, stats, at?)` already takes the position to draw, so a
|
||||
drag module can pass its optimistic position for the node under the pointer and let the
|
||||
authoritative view resume on ack/rollback. The reducer's token view stays the server's word.
|
||||
- **Proof**: `test/tokens.test.ts` (enter/update/leave, status names without `source`, GM fields,
|
||||
malformed frames), `test/lists.test.ts` (own characters, encountered full/diff/grey, GM copies),
|
||||
`test/token-board.test.ts` (one changed entity per frame, no phantom enter+leave, reset on
|
||||
`hello`, seeding) and `e2e/tokens.test.mjs` (real server: player and GM token sets, a `gm_only`
|
||||
token the player never receives, the stuck badge, both lists, `token_gone` plus the grey flip,
|
||||
and one-entity updates with unchanged label builds).
|
||||
|
||||
Reference in New Issue
Block a user