From 4f50f2008f4d7c2a635f7f26861fcfc7f7504423 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Sun, 15 Nov 2026 13:45:21 +0100 Subject: Phase 3: web UI core loop (M3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Browser game UI on top of the Phase 2 protocol: server-driven, input-only clients with per-connection secret visibility. Web (Svelte 5): - Layout: TopBar (element buttons with use/imbue long-press, title, menu), MainList (character/monster/note rows), BottomBar (draw/next-round + level widget with T/H/X/C values). - CharacterRow with the secret initiative input: own value editable, server-masked values render as ??, revealed on draw. - Per-figure StatusMenu: health/max/xp/bless/curse/empower/enfeeble steppers, condition grid, turn-done — all server commands, player-gated. - Menu dialogs: select scenario, add section, add/remove character, set level/difficulty/solo/auto-level, add/remove monster, note row, action log with rollback, settings (style theme + language). - Player vs spectator UI gated on the live seat table; reconnecting banner, error toasts, connection status plumbing. - i18n: English ported, locale store with localStorage persistence. - Design tokens + the three style themes (frosthaven/gloomhaven/original). - Unit tests: level values, game logic (elements/conditions/art/stats), i18n, the reactive player store, the data client (sections keyed by scenario number), plus the existing connection/protocol/state tests. Server: - Serve the engine's data JSON at /data/ and artwork at /images/ so the client menus and rows read the same assets the engine loads. --- web/src/lib/game/conditions.ts | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 web/src/lib/game/conditions.ts (limited to 'web/src/lib/game/conditions.ts') diff --git a/web/src/lib/game/conditions.ts b/web/src/lib/game/conditions.ts new file mode 100644 index 0000000..b7579ac --- /dev/null +++ b/web/src/lib/game/conditions.ts @@ -0,0 +1,57 @@ +/** + * The `Condition` enum (server `lib/core/enums.dart`). The state serializes + * conditions as their index; the wire commands `addCondition` / + * `removeCondition` take the enum *name*. + */ + +export const CONDITIONS = [ + { name: 'stun', label: 'Stunned' }, + { name: 'immobilize', label: 'Immobilized' }, + { name: 'disarm', label: 'Disarmed' }, + { name: 'wound', label: 'Wounded' }, + { name: 'wound2', label: 'Wounded x2' }, + { name: 'muddle', label: 'Muddled' }, + { name: 'poison', label: 'Poisoned' }, + { name: 'poison2', label: 'Poisoned x2' }, + { name: 'poison3', label: 'Poisoned x3' }, + { name: 'poison4', label: 'Poisoned x4' }, + { name: 'bane', label: 'Bane' }, + { name: 'brittle', label: 'Brittle' }, + { name: 'chill', label: 'Chilled' }, + { name: 'infect', label: 'Infected' }, + { name: 'impair', label: 'Impaired' }, + { name: 'rupture', label: 'Ruptured' }, + { name: 'plague', label: 'Plagued' }, + { name: 'strengthen', label: 'Strengthened' }, + { name: 'invisible', label: 'Invisible' }, + { name: 'regenerate', label: 'Regenerating' }, + { name: 'ward', label: 'Warded' }, + { name: 'dodge', label: 'Dodging' }, + { name: 'safeguard', label: 'Safeguard' }, + { name: 'shield', label: 'Shielded' }, + { name: 'retaliate', label: 'Retaliating' }, + // character1..4 are custom per-character slots; they are managed by the + // game data, not the condition menu, so they are excluded here. +] as const; + +export type ConditionName = (typeof CONDITIONS)[number]['name']; + +/** Human label for a condition index (falling back to the index). */ +export function conditionLabel(index: number): string { + const c = CONDITIONS[index]; + return c ? c.label : `condition ${index}`; +} + +/** Wire name for a condition index (falling back to the index). */ +export function conditionName(index: number): string { + const c = CONDITIONS[index]; + return c ? c.name : `condition${index}`; +} + +/** True when [index] is chill or plague (rendered with a coloured chip). */ +export function conditionChipClass(index: number): string { + const name = CONDITIONS[index]?.name; + if (name === 'chill') return 'cond cond--chill'; + if (name === 'plague') return 'cond cond--plague'; + return 'cond'; +} -- cgit v1.3.1