diff options
Diffstat (limited to 'web/src/lib/ui/CharacterRow.svelte')
| -rw-r--r-- | web/src/lib/ui/CharacterRow.svelte | 112 |
1 files changed, 106 insertions, 6 deletions
diff --git a/web/src/lib/ui/CharacterRow.svelte b/web/src/lib/ui/CharacterRow.svelte index f4fdd76..043c225 100644 --- a/web/src/lib/ui/CharacterRow.svelte +++ b/web/src/lib/ui/CharacterRow.svelte @@ -15,20 +15,24 @@ --> <script lang="ts"> import type { GameSession } from '$lib/state/session'; - import type { CharacterItem } from '$lib/protocol/types'; + import type { CharacterItem, MonsterInstance } from '$lib/protocol/types'; import { classInfo, isObjectiveOrEscort, type ClassData } from '$lib/data/classInfo'; - import { classColor, classIcon } from '$lib/game/art'; + import { classColor, classIcon, summonImage } from '$lib/game/art'; import { conditionChipClass, conditionLabel } from '$lib/game/conditions'; + import { standeeFigureId } from '$lib/game/stats'; import type { FigureRef } from './StatusMenu.svelte'; let { session, item, - onOpenMenu + onOpenMenu, + onAddSummon }: { session: GameSession; item: CharacterItem; onOpenMenu: (figure: FigureRef) => void; + /** Open the add-summon menu for this character. */ + onAddSummon: () => void; } = $props(); const seats = session.seats; @@ -106,8 +110,42 @@ rowId: item.id, isObjective }); + + /** A figure ref for one of the character's summon standees. */ + function summonFigureFor(s: MonsterInstance): FigureRef { + return { + title: s.name || cs.display, + figureId: standeeFigureId(s), + ownerId: item.id, + kind: 'summon', + rowId: item.id, + isObjective: false + }; + } </script> +{#if !isObjective} + <div class="summons"> + {#each cs.summonList as s (standeeFigureId(s))} + <button + class="summon__box" + class:summon__box--dead={s.health <= 0} + onclick={() => onOpenMenu(summonFigureFor(s))} + aria-label={s.name || 'summon'} + > + <img src={summonImage(s.gfx)} alt="" loading="lazy" /> + {#if s.standeeNr > 0} + <span class="summon__box-nr">{s.standeeNr}</span> + {/if} + <span class="summon__box-hp">{s.health}</span> + </button> + {/each} + <button class="summon__add" onclick={onAddSummon} aria-label="Add Summon"> + ⚔+ + </button> + </div> +{/if} + <div class="row row--character" class:row--current={currentTurn} @@ -172,9 +210,6 @@ <span class="row__xp">XP {cs.xp}</span> {/if} <span class="row__level">{cs.level}</span> - {#if cs.summonList.length > 0} - <span class="row__summon">⚔ {cs.summonList.length}</span> - {/if} <!-- Right-hand tap zone: initiative focus / turn done (reference). --> <div @@ -193,3 +228,68 @@ {#if unclaimed} <button class="chip chip--claim" onclick={() => session.claim(item.id)}>Claim</button> {/if} + +<style> + /* The summon standees sit above the row, like the reference. */ + .summons { + display: flex; + align-items: stretch; + gap: 4px; + width: calc(100% - 6px); + margin: 2px 3px 0; + } + .summon__box { + position: relative; + width: 34px; + height: 44px; + padding: 0; + border: 1px solid #2196f3; + border-radius: 4px; + background: rgba(0, 0, 0, 0.45); + overflow: hidden; + cursor: pointer; + } + .summon__box:focus-visible { + outline: 2px solid #7ec8ff; + } + .summon__box img { + width: 100%; + height: 100%; + object-fit: cover; + } + .summon__box--dead { + filter: grayscale(1); + opacity: 0.6; + } + .summon__box-hp { + position: absolute; + right: 2px; + bottom: 1px; + font-size: 11px; + font-weight: 700; + color: #fff; + text-shadow: 0 0 2px #000; + } + .summon__box-nr { + position: absolute; + left: 2px; + top: 1px; + font-size: 10px; + font-weight: 700; + color: #fff; + text-shadow: 0 0 2px #000; + } + .summon__add { + width: 34px; + height: 44px; + border: 1px dashed rgba(255, 255, 255, 0.4); + border-radius: 4px; + background: rgba(0, 0, 0, 0.3); + color: inherit; + font-size: 12px; + cursor: pointer; + } + .summon__add:hover { + background: rgba(255, 255, 255, 0.12); + } +</style> |
