diff options
Diffstat (limited to 'web/src/lib/ui/StatusMenu.svelte')
| -rw-r--r-- | web/src/lib/ui/StatusMenu.svelte | 115 |
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} |
