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/ui/menus/RemoveMonsterMenu.svelte | |
| 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/ui/menus/RemoveMonsterMenu.svelte')
| -rw-r--r-- | web/src/lib/ui/menus/RemoveMonsterMenu.svelte | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/web/src/lib/ui/menus/RemoveMonsterMenu.svelte b/web/src/lib/ui/menus/RemoveMonsterMenu.svelte new file mode 100644 index 0000000..f995abd --- /dev/null +++ b/web/src/lib/ui/menus/RemoveMonsterMenu.svelte @@ -0,0 +1,81 @@ +<!-- + Remove Monsters (the reference `RemoveMonsterMenu`): checkbox list of the + current monsters; "Remove All" clears everything. +--> +<script lang="ts"> + import type { GameSession } from '$lib/state/session'; + import { isMonster } from '$lib/protocol/types'; + import { t } from '$lib/i18n'; + import Menu from '../Menu.svelte'; + + let { + session, + open = $bindable(true) + }: { + session: GameSession; + open?: boolean; + } = $props(); + + const gameState = session.state; + const player = session.player; + + let selected = $state<Set<string>>(new Set()); + + $effect(() => { + if (!open) return; + const ids = ($gameState?.currentList ?? []).filter(isMonster).map((m) => m.id); + selected = new Set(ids); + }); + + const monsters = $derived(($gameState?.currentList ?? []).filter(isMonster)); + + function toggle(id: string) { + const next = new Set(selected); + if (next.has(id)) next.delete(id); + else next.add(id); + selected = next; + } + + function remove() { + if (!$player || selected.size === 0) return; + session.command('removeMonster', { ids: [...selected] }); + open = false; + } + + function removeAll() { + if (!$player || monsters.length === 0) return; + session.command('removeMonster', { ids: monsters.map((m) => m.id) }); + open = false; + } +</script> + +<Menu open={open} title={t('menuRemoveMonsters')}> + {#if monsters.length === 0} + <p style="padding: 12px; opacity: 0.7">{t('noResultsFound')}</p> + {:else} + <ul class="menulist"> + {#each monsters as m (m.id)} + <li> + <label class="menulist__item" style="cursor: pointer"> + <input type="checkbox" checked={selected.has(m.id)} onchange={() => toggle(m.id)} /> + {m.id} ({m.monsterInstances.length}) + </label> + </li> + {/each} + </ul> + + <div style="display: flex; gap: 8px; justify-content: flex-end; padding: 8px 4px"> + <button class="stepbtn" style="border-radius: 6px" disabled={!$player} onclick={removeAll}> + {t('removeAll')} + </button> + <button + class="stepbtn" + style="border-radius: 6px; background: #7a1f1f" + disabled={!$player || selected.size === 0} + onclick={remove} + > + {t('menuRemoveMonsters')} ({selected.size}) + </button> + </div> + {/if} +</Menu> |
