diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-11-17 23:12:38 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-11-17 23:12:38 +0100 |
| commit | d64cf3514e5ff1ddb1c7f3ddac9a769db3e7dde0 (patch) | |
| tree | 781ec9f63220f3c15b309658e9b32ad7d9c70b3a /web/src/lib/ui/menus/AddSummonMenu.svelte | |
| parent | 94e2850fb73005f3fb30af8489905e5cdfb6fac5 (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/menus/AddSummonMenu.svelte')
| -rw-r--r-- | web/src/lib/ui/menus/AddSummonMenu.svelte | 261 |
1 files changed, 261 insertions, 0 deletions
diff --git a/web/src/lib/ui/menus/AddSummonMenu.svelte b/web/src/lib/ui/menus/AddSummonMenu.svelte new file mode 100644 index 0000000..a60cb42 --- /dev/null +++ b/web/src/lib/ui/menus/AddSummonMenu.svelte @@ -0,0 +1,261 @@ +<!-- + Add Summon (the reference `AddSummonMenu`): choose a standee colour and + number, then pick from the character's class summons (filtered by level + and standee cap) or the generic item summons. Adding sends `addStandee` + with `type: 3` (summon) and `addAsSummon: true`. +--> +<script lang="ts"> + import type { GameSession } from '$lib/state/session'; + import type { CharacterItem } from '$lib/protocol/types'; + import { gameData, type SummonModel } from '$lib/data/gameData'; + import { summonImage } from '$lib/game/art'; + import Menu from '../Menu.svelte'; + + const COLORS = ['blue', 'green', 'yellow', 'orange', 'white', 'purple', 'pink', 'red']; + const MIN_STANDEES_FOR_NR = 2; + const NUMBERS = [1, 2, 3, 4, 5, 6, 7, 8]; + + let { + session, + character, + open = $bindable(true) + }: { + session: GameSession; + character: CharacterItem; + open?: boolean; + } = $props(); + + const player = session.player; + const gameState = session.state; + + let chosenGfx = $state('blue'); + let chosenNr = $state(1); + + // The class's summonable figures (the reference filters by level and the + // number of standees already out; item summons are always listed). + let classSummons = $state<SummonModel[] | null>(null); + let itemSummons = $state<SummonModel[] | null>(null); + + $effect(() => { + if (!open) return; + let alive = true; + classSummons = null; + itemSummons = null; + gameData + .loadCampaign(character.edition) + .then((c) => { + const cls = c.classes.find( + (x) => x.name === character.characterClass || x.id === character.characterClass + ); + if (!alive || !cls) return; + const level = character.characterState.level; + classSummons = cls.summons + .filter((s) => s.level <= level) + .filter((s) => { + const out = character.characterState.summonList.filter( + (x) => x.name === s.name + ).length; + return out < s.standees; + }); + }) + .catch(() => {}); + gameData + .summons() + .then((list) => { + if (alive) itemSummons = list; + }) + .catch(() => {}); + return () => { + alive = false; + }; + }); + + /** The entries to list (class summons first, then item summons). */ + const entries = $derived.by(() => { + const out: SummonModel[] = []; + if (classSummons) out.push(...classSummons); + if (itemSummons) out.push(...itemSummons); + return out; + }); + + function entryGfx(model: SummonModel): string { + return model.gfx || chosenGfx; + } + + /** The standee number shown for a model (hidden for fixed-art, single-standee). */ + function entryNr(model: SummonModel): number { + if (model.gfx && model.standees < MIN_STANDEES_FOR_NR) return 0; + return chosenNr; + } + + function add(model: SummonModel) { + if (!$player) return; + const gfx = entryGfx(model); + const nr = entryNr(model); + session.command('addStandee', { + nr, + summon: { + standeeNr: nr, + name: model.name, + health: model.health, + move: model.move, + attack: model.attack, + range: model.range, + gfx + }, + ownerId: character.id, + type: 3, + addAsSummon: true + }); + open = false; + } +</script> + +<Menu {open} title="Add Summon"> + <div class="swatches" role="radiogroup" aria-label="standee colour"> + {#each COLORS as c (c)} + <button + class="swatch" + class:swatch--selected={c === chosenGfx} + disabled={!$player} + aria-label={c} + onclick={() => (chosenGfx = c)} + > + <img src={summonImage(c)} alt="" /> + </button> + {/each} + </div> + + <div class="numbers" role="radiogroup" aria-label="standee number"> + {#each NUMBERS as n (n)} + <button + class="numbtn" + class:numbtn--selected={n === chosenNr} + disabled={!$player} + onclick={() => (chosenNr = n)} + > + {n} + </button> + {/each} + </div> + + {#if $gameState} + <ul class="summonlist"> + {#each entries as model (model.name + model.gfx)} + <li> + <button + class="summonlist__item" + disabled={!$player} + onclick={() => add(model)} + > + <span class="summonlist__art"> + <img src={summonImage(entryGfx(model))} alt="" /> + {#if entryNr(model) > 0} + <span class="summonlist__nr">{entryNr(model)}</span> + {/if} + </span> + <span class="summonlist__name">{model.name}</span> + </button> + </li> + {/each} + </ul> + {/if} +</Menu> + +<style> + .swatches { + display: flex; + flex-wrap: wrap; + gap: 6px; + margin-bottom: 10px; + justify-content: center; + } + .swatch { + width: 40px; + height: 40px; + padding: 3px; + border-radius: 4px; + border: 1px solid rgba(255, 255, 255, 0.25); + background: rgba(0, 0, 0, 0.3); + cursor: pointer; + } + .swatch--selected { + border: 2px solid #7ec8ff; + } + .swatch img { + width: 100%; + height: 100%; + object-fit: contain; + } + .numbers { + display: grid; + grid-template-columns: repeat(4, 1fr); + gap: 6px; + margin-bottom: 12px; + } + .numbtn { + height: 32px; + font-size: 13px; + border: 1px solid rgba(255, 255, 255, 0.25); + border-radius: 4px; + background: rgba(0, 0, 0, 0.3); + color: inherit; + cursor: pointer; + } + .numbtn--selected { + border: 2px solid #7ec8ff; + font-weight: 700; + } + .summonlist { + list-style: none; + margin: 0; + padding: 0; + max-height: 40vh; + overflow-y: auto; + } + .summonlist__item { + display: flex; + align-items: center; + gap: 10px; + width: 100%; + padding: 6px 8px; + border: none; + border-radius: 4px; + background: none; + color: inherit; + font-size: 13px; + text-align: left; + cursor: pointer; + } + .summonlist__item:hover { + background: rgba(255, 255, 255, 0.1); + } + .summonlist__art { + position: relative; + width: 32px; + height: 32px; + flex: 0 0 auto; + } + .summonlist__art img { + width: 100%; + height: 100%; + object-fit: contain; + } + .summonlist__nr { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: center; + font-size: 14px; + font-weight: 700; + color: #fff; + text-shadow: 0 0 3px #000, 0 1px 2px #000; + } + .summonlist__name { + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } +</style> |
