diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-11-15 13:45:21 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-11-15 13:45:21 +0100 |
| commit | 4f50f2008f4d7c2a635f7f26861fcfc7f7504423 (patch) | |
| tree | 94e6286e7e22e0467a61b99c18b9ab582fbbe656 /web/src/lib/game/elements.ts | |
| parent | 3ebbdf6ffa16f751c82e3bd2e74294f4fe843155 (diff) | |
Phase 3: web UI core loop (M3)
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.
Diffstat (limited to 'web/src/lib/game/elements.ts')
| -rw-r--r-- | web/src/lib/game/elements.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/web/src/lib/game/elements.ts b/web/src/lib/game/elements.ts new file mode 100644 index 0000000..61ecde3 --- /dev/null +++ b/web/src/lib/game/elements.ts @@ -0,0 +1,29 @@ +/** + * The six elemental abilities. The indices match the server's `Elements` + * enum (the state serializes `elementState` as element-index → + * state-index), and the wire commands `useElement` / `imbueElement` take + * the enum *name*. + */ + +export const ELEMENTS = [ + { name: 'fire', label: 'Fire', color: 'var(--el-fire)', icon: '/images/psd/element-fire.png' }, + { name: 'ice', label: 'Ice', color: 'var(--el-ice)', icon: '/images/psd/element-ice.png' }, + { name: 'air', label: 'Air', color: 'var(--el-air)', icon: '/images/psd/element-air.png' }, + { name: 'earth', label: 'Earth', color: 'var(--el-earth)', icon: '/images/psd/element-earth.png' }, + { name: 'light', label: 'Light', color: 'var(--el-light)', icon: '/images/psd/element-light.png' }, + { name: 'dark', label: 'Dark', color: 'var(--el-dark)', icon: '/images/psd/element-dark.png' }, +] as const; + +/** ElementState index: 0 full, 1 half, 2 inert. */ +export type ElementState = 0 | 1 | 2; + +/** + * The element's fill state from the game state (absent → inert), matching + * the reference `ElementButton`: a tap uses the element when it is active, + * imbues it (full) when inert; a long press imbues the half (advanced) + * amount. + */ +export function elementState(state: Record<string, number>, index: number): ElementState { + const value = state[String(index)]; + return value === 0 || value === 1 || value === 2 ? value : 2; +} |
