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/test/protocol.test.ts | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'web/test/protocol.test.ts') diff --git a/web/test/protocol.test.ts b/web/test/protocol.test.ts index c804d8b..e12df4e 100644 --- a/web/test/protocol.test.ts +++ b/web/test/protocol.test.ts @@ -1,8 +1,39 @@ import { describe, expect, it } from 'vitest'; -import { buildHello } from '$lib/protocol/connection'; +import { + claimMessage, + commandMessage, + helloMessage, + pingMessage +} from '$lib/protocol/types'; -describe('wire protocol', () => { +describe('wire protocol builders', () => { it('builds the hello handshake message', () => { - expect(buildHello()).toEqual({ t: 'hello', v: 1 }); + expect(helloMessage()).toEqual({ t: 'hello', v: 1 }); + }); + + it('builds a command message with default empty args', () => { + expect(commandMessage('draw')).toEqual({ + t: 'cmd', + name: 'draw', + args: {} + }); + }); + + it('builds a command message with args', () => { + expect( + commandMessage('addCharacter', { id: 'Berserker', edition: 'x' }) + ).toEqual({ + t: 'cmd', + name: 'addCharacter', + args: { id: 'Berserker', edition: 'x' } + }); + }); + + it('builds claim, ping messages', () => { + expect(claimMessage('Berserker')).toEqual({ + t: 'claim', + characterId: 'Berserker' + }); + expect(pingMessage()).toEqual({ t: 'ping' }); }); }); -- cgit v1.3.1