summaryrefslogtreecommitdiff
path: root/web/src/lib/ui/StatusMenu.svelte
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2026-11-17 23:12:38 +0100
committerJoel Klinghed <the_jk@spawned.biz>2026-11-17 23:12:38 +0100
commitd64cf3514e5ff1ddb1c7f3ddac9a769db3e7dde0 (patch)
tree781ec9f63220f3c15b309658e9b32ad7d9c70b3a /web/src/lib/ui/StatusMenu.svelte
parent94e2850fb73005f3fb30af8489905e5cdfb6fac5 (diff)
Phase 5: campaign meta, notes, special rules (M5)
Web: - Note rows: create/edit menu (text, 12-swatch palette, player/monster link with per-standee selection, delete) with the reference's create-vs-edit commit semantics; row rendering with target-derived gradient colour, link indent + connector, standee N:/All: prefixes, tap-to-edit; whole-list drag-to-reorder (reorderList); quick per-figure note (setFigureNote) from the status menu - Special monsters: Ice Wraith "Switch Form" (deck == "Ice Wraith" gate), summon mark toggle (round-green/summon standee artwork, standee-nr badges, per-owner grayscale), character summon boxes + AddSummonMenu (class summons gated by level and standee cap, item summons from summons.json) - Ally deck show/hide in the main menu (shouldShowAlliesDeck gate); settings "clear unlocked" + Special Unlocks menu - AddSectionMenu parity: search filter, findNrFromScenarioName numeric ordering, added sections greyed + no-op, #Random Dungeon label - gameData.ts: SummonModel, ClassData.summons, summons() fetch Server: - unlock_special_command_test (last command without a test; ally-deck hide and remove-sanctuary were already covered) PLAN.md: Phase 5 boxes checked, M5 progress-log entry
Diffstat (limited to 'web/src/lib/ui/StatusMenu.svelte')
-rw-r--r--web/src/lib/ui/StatusMenu.svelte115
1 files changed, 115 insertions, 0 deletions
diff --git a/web/src/lib/ui/StatusMenu.svelte b/web/src/lib/ui/StatusMenu.svelte
index 46f6325..e968883 100644
--- a/web/src/lib/ui/StatusMenu.svelte
+++ b/web/src/lib/ui/StatusMenu.svelte
@@ -21,7 +21,9 @@
import { isObjectiveOrEscort } from '$lib/data/classInfo';
import { CONDITIONS } from '$lib/game/conditions';
import { t } from '$lib/i18n';
+ import type { CampaignData } from '$lib/data/gameData';
import Menu from './Menu.svelte';
+ import FigureNoteMenu from './menus/FigureNoteMenu.svelte';
export interface FigureRef {
title: string;
@@ -38,10 +40,16 @@
let {
session,
figure,
+ campaignData,
+ onAddNoteRow,
open = $bindable(true)
}: {
session: GameSession;
figure: FigureRef;
+ /** Campaign data (monster model lookup for the Ice Wraith gate). */
+ campaignData?: CampaignData | null;
+ /** Open the note-row editor with a preset link target. */
+ onAddNoteRow: (presetLinkId: string) => void;
open?: boolean;
} = $props();
@@ -131,6 +139,62 @@
if (conditions.includes(index)) cmd('removeCondition', args);
else cmd('addCondition', args);
}
+
+ // --- Phase 5 extras ------------------------------------------------------
+
+ /** The owning monster's model (Ice Wraith gate), for monster figures. */
+ const monsterModel = $derived.by(() => {
+ if (figure.kind !== 'monster' || !campaignData) return null;
+ const owner = liveOwner;
+ if (owner == null || !('monsterInstances' in owner)) return null;
+ return (
+ campaignData.monsters.find(
+ (m) => m.name === owner.type || m.display === owner.type
+ ) ?? null
+ );
+ });
+
+ const isIceWraith = $derived(monsterModel?.deck === 'Ice Wraith');
+ const isElite = $derived(liveStandee?.type === 1);
+
+ function switchForm() {
+ // The command takes the *current* elite state and toggles it.
+ cmd('iceWraithChangeForm', {
+ isElite,
+ ownerId: figure.ownerId ?? '',
+ figureId: figure.figureId
+ });
+ }
+
+ // The summon mark (the reference `StatusMenuSummonButton`).
+ const summonMarked = $derived(liveStandee?.roundSummoned !== -1);
+
+ function toggleSummon() {
+ cmd('setAsSummon', {
+ summoned: !summonMarked,
+ figureId: figure.figureId,
+ ownerId: figure.ownerId ?? ''
+ });
+ }
+
+ // The figure's quick note (characters and monsters; not summons).
+ const noteFigure = $derived.by(() => {
+ if (figure.kind === 'character') return liveCharacter;
+ if (figure.kind === 'monster')
+ return liveOwner && 'note' in liveOwner ? liveOwner : null;
+ return null;
+ });
+
+ let noteOpen = $state(false);
+
+ function openNote() {
+ noteOpen = true;
+ }
+
+ /** The link target preset when adding a note row from here. */
+ function presetLinkTarget(): string {
+ return figure.ownerId ?? figure.figureId;
+ }
</script>
<Menu open={open} title={figure.title}>
@@ -197,6 +261,48 @@
{/each}
</div>
+ <div class="dialog__body" style="padding-top: 8px">
+ {#if isIceWraith}
+ <button
+ class="stepbtn"
+ style="width: 100%; height: 36px"
+ disabled={!canAct}
+ onclick={switchForm}
+ >
+ Switch Form
+ </button>
+ {/if}
+ {#if figure.kind === 'monster' && liveStandee}
+ <button
+ class="stepbtn"
+ class:stepbtn--on={summonMarked}
+ style="width: 100%; height: 36px"
+ disabled={!canAct}
+ onclick={toggleSummon}
+ >
+ {summonMarked ? t('cmdRemoveSummonMark') : t('cmdMarkAsSummon')}
+ </button>
+ {/if}
+ {#if noteFigure}
+ <button
+ class="stepbtn"
+ style="width: 100%; height: 36px"
+ disabled={!canAct}
+ onclick={openNote}
+ >
+ {noteFigure.note || t('characterNoteQuickAdd')}
+ </button>
+ {/if}
+ <button
+ class="stepbtn"
+ style="width: 100%; height: 36px"
+ disabled={!canAct}
+ onclick={() => onAddNoteRow(presetLinkTarget())}
+ >
+ {t('noteRowAddFromMenu')}
+ </button>
+ </div>
+
{#if roundState === 1}
<div class="dialog__body" style="padding-top: 8px">
<button
@@ -213,3 +319,12 @@
</div>
{/if}
</Menu>
+
+{#if noteOpen && noteFigure}
+ <FigureNoteMenu
+ {session}
+ figureId={figure.kind === 'character' ? figure.figureId : (figure.ownerId ?? figure.figureId)}
+ initial={noteFigure.note}
+ bind:open={noteOpen}
+ />
+{/if}