summaryrefslogtreecommitdiff
path: root/PLAN.md
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2026-11-16 22:19:39 +0100
committerJoel Klinghed <the_jk@spawned.biz>2026-11-16 22:19:39 +0100
commit94e2850fb73005f3fb30af8489905e5cdfb6fac5 (patch)
tree1aea8e7e6683af770f0c57c0fb654003778c9f16 /PLAN.md
parent4f50f2008f4d7c2a635f7f26861fcfc7f7504423 (diff)
Phase 4: cards and decks (M4)
Full card play in the browser: ability-line rendering, monster ability decks, the full modifier-deck (AMD) suite, and the loot deck — all server commands, faithful to the reference flows and layout. Web (Svelte 5): - Line renderer + in-game translations: $lib/game/line/ renders the reference line_builder output (emphasis, range markers, element styling); gameI18n.ts loads the /i18n/ in-game ability-text tables (the client-side TranslationService equivalent) - Card components: stat cards, monster ability cards (OG + FH styles, rendered lines, element/flying tokens), modifier cards (gfx resolver incl. P<n> perk graphics), loot cards (party-size value rules, owner, enhancements) - Monster ability decks: AbilityCardSlot in each monster row (front of the current card while active in playTurns, else the back with the draw-pile count); AbilityCardsMenu (reveal top cards, draw extra, extra shuffle, activate/inactivate, drag-reorder, remove); card zoom - Modifier decks: ModifierDeckWidget (tap to draw, face-up revealed top card, empty-box class icon for the current character's own deck, discard stack); ModifierDeckHeader (bad omen, corrosive spew, ±1/−2/+0, imbue 1/2, reveal with the Cassandra 8-button cap, save/don't-save revealed cards, removed count, Hail perk, CS sanctuary/party cards, faction icons, bless/curse and the empower/enfeeble counters); ModifierDeckMenu (draw-pile drag-reorder + send-to-bottom/shuffle/remove, discard remove/return-top, removed pile with return, faction grid with gray-out, perks menu with the Frosthaven opt-in); card zoom - Loot deck: LootDeckWidget (player-gated draw, current-character icon, discard stack, hidden when both piles empty); LootCardsMenu (set owner, per-character loot totals, add card, enhance with the reference material/herb/coin splits, special cards 1418/1419, return top/bottom) - Bottom DeckArea: loot deck left; the Character Decks toggle with the reference open-state cycling (oneOpen/allOpen/noOpen per round state; one-deck view for the current character during playTurns); ally deck behind shouldShowAlliesDeck; global deck - Pure helper modules ported from the reference: rules.ts (FH card styling, inactive-for-rule, ally-deck gate, deck resolution), modifierDeck.ts (pile derivations, faction cards), perks.ts (active perk set, card-text tokens, descriptions, add/remove gating), cards/lootCard.ts (values + per-character totals) - App wiring: campaign data loaded on currentCampaign change (guarded against out-of-order fetches); ability/AMD/loot menus and zooms driven by live-derived state so open menus track pile changes; Escape closes every dialog Server: - /i18n/ static mount: the in-game ability-text translation files the card renderer resolves (the reference TranslationService data) - Loot deck JSON gains pools (pool card ids per pool — the client derives card gfx from pool key + index and reads the enhancements map; ids only, since pool cards are the same live instances that mutate in the piles) - Modifier deck JSON gains removables (the counter totals the header reads) plus load-time round-trip for saves written before the field existed Docs: - PLAN.md: Phase 3 and Phase 4 marked complete (corrected the 'character ability decks' mislabel — ability decks are monster-only), progress log entries for M3 and M4 svelte-check 0 errors; web tests 177/177; build OK; dart analyze 0 errors; dart test 592/592; scripts/ci.sh green.
Diffstat (limited to 'PLAN.md')
-rw-r--r--PLAN.md53
1 files changed, 31 insertions, 22 deletions
diff --git a/PLAN.md b/PLAN.md
index c9b768c..a6ff1fb 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -1,7 +1,7 @@
# X-Haven Web — Implementation Plan
**Status:** APPROVED — implementation in progress (Phase 0 started 2026-11-08).
-**Last updated:** 2026-11-12
+**Last updated:** 2026-11-16
Progress is tracked in this file: mark steps `- [x]` as they are completed and record
milestones in §6. The reference app (`FrosthavenAssistant/`) is read-only; all new code
@@ -226,38 +226,45 @@ Port of the complete engine — all of it, so later phases are UI-only:
**Milestone M2** — complete multiplayer + server-gated secrets + persistence over WS, no UI.
-### Phase 3 — Web UI: core loop
+### Phase 3 — Web UI: core loop ✅ (2026-11-15)
-- [ ] Theme/design tokens matching the app's look (dark base, the three style themes)
-- [ ] Page layout: TopBar (campaign/scenario/round info), MainList, BottomBar (draw button)
-- [ ] MainList rows: CharacterRow (art, HP bar, conditions, initiative input), MonsterRow
+- [x] Theme/design tokens matching the app's look (dark base, the three style themes)
+- [x] Page layout: TopBar (campaign/scenario/round info), MainList, BottomBar (draw button)
+- [x] MainList rows: CharacterRow (art, HP bar, conditions, initiative input), MonsterRow
(art, HP, standees, state), placeholder for NoteRow
-- [ ] Initiative widget: shows own value while entering, `??` for others, reveals on draw;
+- [x] Initiative widget: shows own value while entering, `??` for others, reveals on draw;
input enabled only on the owning player's screen
-- [ ] Menus (dialogs, faithful flows): select scenario (campaign → scenario → level/
+- [x] Menus (dialogs, faithful flows): select scenario (campaign → scenario → level/
difficulty), add/remove character, character level, stat changes (health, max, xp,
bless/curse/empower/enfeeble), conditions, elements (use/imbue), turn done
-- [ ] Room sections: add-section menu, auto-add standees
-- [ ] Player vs spectator UI: inputs only for owned characters; spectator view read-only
-- [ ] Connection UX: connecting/reconnecting banner, auto-resync, offline indicator
-- [ ] UI i18n: English first (ported from the app's `.arb` files); locale plumbing in place
-- [ ] Client unit tests: protocol client, state stores
+- [x] Room sections: add-section menu, auto-add standees
+- [x] Player vs spectator UI: inputs only for owned characters; spectator view read-only
+- [x] Connection UX: connecting/reconnecting banner, auto-resync, offline indicator
+- [x] UI i18n: English first (ported from the app's `.arb` files); locale plumbing in place
+- [x] Client unit tests: protocol client, state stores
**Milestone M3** — playable in a browser: setup, secret initiative, draw, turns, stat
changes, room sections, spectator view. *First end-to-end moment.*
-### Phase 4 — Cards and decks
+### Phase 4 — Cards and decks ✅ (2026-11-16)
-- [ ] Ability-line rendering (line_builder output: tokens, emphasis, range markers) with
+- [x] Ability-line rendering (line_builder output: tokens, emphasis, range markers) with
in-game translations (client-side equivalent of `TranslationService`)
-- [ ] Character ability decks: draw/shuffle/reorder; per-character decks
-- [ ] Monster ability decks: per-monster draw/discard piles, `lastRoundDrawn`
-- [ ] Modifier decks: monster/ally/per-character decks; AMD rules (imbue, +1/−1, reveal,
- special commands)
-- [ ] Loot deck: draw/return/enhance, ownership, special pile, add/remove loot
-- [ ] Card UI: faithful stat cards / ability cards / modifier cards / loot cards (images +
- rendered text), deck widgets
-- [ ] Server: registry entries for all deck/loot/modifier commands + ported tests
+- [x] Monster ability decks (monsters only — the reference has no character ability
+ decks): per-monster draw/discard piles + `lastRoundDrawn`, card slot in the
+ monster row, deck menu (reveal top cards, draw extra, shuffle, activate/inactivate,
+ drag-reorder, remove), card zoom
+- [x] Modifier decks: party (monster) / ally / per-character decks; full AMD rules
+ (imbue 1/2, ±1/−2/+0, reveal, bad omen, corrosive spew, faction cards, perks,
+ Hail/Cassandra specials, CS sanctuary/party cards), deck widget + menu + zoom
+- [x] Loot deck: draw/return/enhance, ownership, special cards 1418/1419, add cards,
+ per-character loot totals, enhancement menu
+- [x] Card UI: faithful stat cards / ability cards / modifier cards / loot cards (images +
+ rendered text), deck widgets, bottom deck area (loot deck left; character-deck
+ toggle with the reference open-state cycling; ally + global decks)
+- [x] Server: registry entries for all deck/loot/modifier commands (built in Phases
+ 1–2) + tests (server `modifier_deck_test.dart` / command tests; client helper tests
+ in `web/test/deckHelpers.test.ts`)
**Milestone M4** — full card play in the browser.
@@ -322,6 +329,8 @@ changes, room sections, spectator view. *First end-to-end moment.*
| 2026-11-08 | **Phase 0 complete** — server package (shelf + WS, hello/welcome handshake, smoke tests 5/5), web app (Svelte 5 + TS, protocol client, svelte-check clean, build OK), assets copied (73 MB), AGPL license, README, .gitignore, CI script passing end-to-end. |
| 2026-11-12 | **Phase 1 complete / M1 reached** — full engine ported to `server/lib/core/` (models, state + 18 part files, 7 methods classes, game_methods, 79 command files, enums, card_stack, stat_calculator, action_handler, disk-based game_data, l10n, minimal line_builder per conventions §8b). Command registry: 82 entries (wire name ↔ constructor + arg validation; enum/object args resolved against live state). Ported test suite: 81 test files, **562 tests green** (command tests 1:1 with the reference; resource/action-handler/stat-calculator/modifier-deck tests; registry smoke tests). New headless integration test drives a full round (setup → characters + standee → initiative gate → draw → every figure's turn incl. undo/redo → next round → round 2 → round 3). `dart analyze` warning-free. Porting conventions in `server/PORTING.md`. Notable porting fix found by tests: removable-card physical sync had to stay gated to the ten initial counters (reference listener semantics). |
| 2026-11-12 | **Phase 2 complete / M2 reached** — networking, sessions, and server-gated secrets over WebSocket, no UI. New `server/lib/net/`: `protocol.dart` (JSON wire protocol, v1: `hello`/`welcome`/`update`/`seats`/`error`/`pong` + `claim`/`cmd`/`undo`/`redo`/`ping`), `sessions.dart` (32-hex session ids; role derived from seat ownership; `resolve()` adopts a well-formed cookie id so a browser keeps its seat across restarts), `seat_store.dart` (seat table in `saves/seats.json`, next to the state snapshot), `visibility.dart` (per-connection state serialization; the initiative rule masks every non-owned character's initiative to `null` until the round is drawn — **the server never sends a secret to a non-owner**), `game_server.dart` (the command execution path: role check → game-rule guard → registry build → execute → per-connection `update` broadcast; seat assign/claim/release + `seats` broadcasts; heartbeat sweep), `ws_upgrade.dart` (custom upgrade handler so the server can read the `x-haven-session` cookie — `shelf_web_socket` hides the `Request`), `app.dart` (shelf composition). `bin/main.dart` wires it together. Notable decisions: a server-side `_guard` replaces the reference app's 300 ms draw-button lockout (sequential execution makes a duplicate draw deterministically lose, the loser gets a clear `error`); the session that adds a character owns it and becomes a player; spectators may only `claim`/`addCharacter`; the command index resets to −1 on restart (the snapshot carries state, not undo history); dead-connection sweep defaults 20 s / 90 s. **Persistence bug found & fixed by the kill −9 test:** both file stores did fire-and-forget async `writeAsString`, so a write could land after the reboot's read — made `FileSaveStore.write`/`FileSeatStore.write` synchronous (`writeAsStringSync`) so "written through on every change" is actually on disk when `write` returns. Tests: **34 new network tests** (sessions 9, visibility 5, app 9, multiplayer 9, persistence 2) using a real WS stack on an ephemeral port — secret initiative never reaches non-owners, reveal on draw, reconnect resync, rejected duplicate draw, claim/lose/re-claim seat, undo/redo broadcast to every screen, dead-connection cleanup with seat release, snapshot + seat file restored across a restart. Full suite **591 tests green**; `dart analyze` warning-free; web typecheck/tests/build unaffected (Phase 2 is server-only). |
+| 2026-11-15 | **Phase 3 complete / M3 reached** — the web UI core loop: theme tokens + the three style themes, TopBar/MainList/BottomBar layout, character/monster/note rows, the secret-initiative widget (server-masked `null` → `??`), all figure menus (scenario, characters, level, stats, conditions, elements, turn done), room sections, player/spectator input gating, connection banner, English i18n, client tests (connection, protocol, state, level values). |
+| 2026-11-16 | **Phase 4 complete / M4 reached** — full card play in the browser. Client: the line renderer + in-game translations (`$lib/game/line/`, `gameI18n.ts`), card components (stat / monster-ability / modifier / loot, `ModifierCard` gfx resolver incl. `P<n>` perk graphics), monster ability decks (row card slot, deck menu — reveal top cards, draw extra, extra shuffle, activate/inactivate, drag-reorder, remove — and card zoom), the full AMD suite (`ModifierDeckWidget` + `ModifierDeckHeader` + `ModifierDeckMenu` with the six submenus — send-to-bottom, remove AMD, removed pile, faction cards, perks, plus zoom; imbue 1/2, ±1/−2/+0, reveal with the Cassandra 8-button cap, bad omen, corrosive spew, Hail/Cassandra specials, faction unlock, CS sanctuary/party cards), the loot deck (widget, cards menu — set owner, per-character loot totals, add card, enhance with the reference material/herb/coin splits, special cards 1418/1419, return top/bottom), and the bottom `DeckArea` (loot deck left; character-deck toggle with the reference open-state cycling; ally deck behind `shouldShowAlliesDeck`; global deck). Pure helper modules (`rules.ts`, `modifierDeck.ts`, `perks.ts`, `cards/lootCard.ts`) ported from the reference with unit tests. Server: all deck/loot/modifier/ability commands were already registered and tested in Phases 1–2 (592 tests green). `svelte-check` 0 errors; web build OK; 177 client tests green. |
## 7. Risks and open items