Add action and event discard pile browser
This commit is contained in:
parent
2c112e3e12
commit
460c23868b
5 changed files with 74 additions and 5 deletions
|
|
@ -339,3 +339,5 @@ Viewer 0.1.109 defaults reclaim attempts to the cheapest eligible other city tha
|
|||
Viewer 0.1.110 splits cultural influence into map-only hex selection, a building choice limited to that hex when needed, source selection, and payment. Single eligible buildings skip the second choice. Undo/Back navigates setup locally. Payment has one direct Influence/Arts button per method with its cost and maximum roll boost; same-hex sources show a no-boost warning. Regression checks cover map-only selection, backwards navigation without submission, and desktop/mobile confirmation. Engine remains 0.4.81.
|
||||
|
||||
Viewer 0.1.111 replaces influence payment action text with a numeric action cost and the shared action icon, retaining accessible labels and tooltips. Action details and maximum boost share a row on desktop, with responsive wrapping when space is limited. Engine remains 0.4.81.
|
||||
|
||||
Viewer 0.1.112 adds Hand, Discarded actions and Discarded events tabs to Cards. Discards show engine pile order with the top card first, counts and expandable full rules including battle uses. Verified both piles in the local saved-game preview; Svelte and production build pass. Engine remains 0.4.81.
|
||||
|
|
|
|||
4
web-client/package-lock.json
generated
4
web-client/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.111",
|
||||
"version": "0.1.112",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.111",
|
||||
"version": "0.1.112",
|
||||
"dependencies": {
|
||||
"@boardgamers/protocol": "0.9.0",
|
||||
"lucide-svelte": "^0.577.0",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@boardgamers/clash-web-client",
|
||||
"version": "0.1.111",
|
||||
"version": "0.1.112",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<script lang="ts">
|
||||
import { printedCardName, printedCardText } from './card-names';
|
||||
import { X, Layers, Zap, Swords } from 'lucide-svelte';
|
||||
import { X, Layers, Zap, Swords, Archive, ScrollText, ChevronDown } from 'lucide-svelte';
|
||||
import ResourceText from './ResourceText.svelte';
|
||||
import ResourceAmount from './ResourceAmount.svelte';
|
||||
import type { Controller } from './controller';
|
||||
|
|
@ -8,6 +8,10 @@
|
|||
import { handCardDescription } from './card-text';
|
||||
let { controller }: { controller: Controller } = $props();
|
||||
const session = $derived(controller.session);
|
||||
let tab = $state<'hand' | 'actions' | 'events'>('hand');
|
||||
const actions = $derived([...($session.game?.action_cards_discarded ?? [])].reverse().map(id => ({ id, card: $session.view?.cardCatalog?.find(card => card.id === id) })));
|
||||
const events = $derived([...($session.game?.incidents_discarded ?? [])].reverse().map(id => ({ id, card: $session.view?.eventCatalog?.find(card => card.id === id) })));
|
||||
|
||||
const close = () => controller.patch({ cardsOpen: false });
|
||||
function show(node: HTMLDialogElement) {
|
||||
node.showModal();
|
||||
|
|
@ -29,7 +33,13 @@
|
|||
<button class="close-guide icon-button" aria-label="Close action cards" onclick={close}
|
||||
><X size={20} /></button
|
||||
>
|
||||
<h2 id="action-cards-title"><Layers size={23} />Action cards</h2>
|
||||
<h2 id="action-cards-title"><Layers size={23} />Cards</h2>
|
||||
<nav class="card-tabs" aria-label="Card piles">
|
||||
<button class:chosen={tab === 'hand'} aria-pressed={tab === 'hand'} onclick={() => tab = 'hand'}><Layers size={16} />Hand <span>{$session.view?.actionCards?.length ?? 0}</span></button>
|
||||
<button class:chosen={tab === 'actions'} aria-pressed={tab === 'actions'} onclick={() => tab = 'actions'}><Archive size={16} />Discarded actions <span>{actions.length}</span></button>
|
||||
<button class:chosen={tab === 'events'} aria-pressed={tab === 'events'} onclick={() => tab = 'events'}><ScrollText size={16} />Discarded events <span>{events.length}</span></button>
|
||||
</nav>
|
||||
{#if tab === 'hand'}
|
||||
{#if $session.view?.actionCards?.some((card) => card.tactics)}
|
||||
<p class="card-use-rule">
|
||||
Choose one use, then discard. Battle uses require Tactics: one card per combat round.
|
||||
|
|
@ -67,5 +77,60 @@
|
|||
</section>{/if}
|
||||
</article>
|
||||
{:else}<p>No action cards in hand.</p>{/each}
|
||||
{:else}
|
||||
<p class="pile-hint">Top of the pile first. Select a card to read its rules.</p>
|
||||
<div class="discard-list">
|
||||
{#key tab}
|
||||
{#each (tab === 'actions' ? actions : events) as entry, i}
|
||||
<details class="discard-card">
|
||||
<summary>
|
||||
<span class="pile-number">{i + 1}</span>
|
||||
<span class="discard-name"><strong>{entry.card ? printedCardName(entry.card.name) : `${tab === 'actions' ? 'Action' : 'Event'} card ${entry.id}`}</strong>
|
||||
{#if entry.card && 'tactics' in entry.card && entry.card.tactics}<small><Swords size={12} />{printedCardName(entry.card.tactics.name)}</small>{/if}
|
||||
</span>
|
||||
{#if i === 0}<span class="top-card">Top card</span>{/if}
|
||||
<ChevronDown size={16} />
|
||||
</summary>
|
||||
<div class="discard-rules">
|
||||
<p class="discard-id">{tab === 'actions' ? 'Action' : 'Event'} · {tab === 'actions' ? 'A' : 'E'}{entry.id}</p>
|
||||
{#if entry.card && 'description' in entry.card}
|
||||
<p><ResourceText text={handCardDescription(entry.card.description)} /></p>
|
||||
{#if entry.card.tactics}<section class="card-battle-use">
|
||||
<div class="card-use-label"><Swords size={15} />Battle use</div>
|
||||
<h4>{printedCardName(entry.card.tactics.name)}</h4>
|
||||
<p><ResourceText text={entry.card.tactics.description} /></p>
|
||||
</section>{/if}
|
||||
{:else if entry.card && 'rules' in entry.card}
|
||||
{#each entry.card.rules as rule}<p><ResourceText text={rule} /></p>{/each}
|
||||
{:else}<p>Card details unavailable.</p>{/if}
|
||||
</div>
|
||||
</details>
|
||||
{:else}<p class="empty-pile">No discarded {tab === 'actions' ? 'action' : 'event'} cards.</p>{/each}
|
||||
{/key}
|
||||
</div>
|
||||
{/if}
|
||||
{#if $session.error}<p class="inline-error" role="alert">{$session.error}</p>{/if}
|
||||
</dialog>
|
||||
|
||||
<style>
|
||||
.card-tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 0.75rem; margin: 0.5rem 0 1rem; }
|
||||
.card-tabs button { display: inline-flex; align-items: center; gap: 0.4rem; border: 1px solid transparent; border-radius: 5px; background: transparent; padding: 0.6rem 0.7rem; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
|
||||
.card-tabs button.chosen { background: var(--paper2); color: var(--ink); border-color: var(--gold, #b79351); }
|
||||
.card-tabs button > span { font-size: 11px; padding: 0.1rem 0.35rem; border-radius: 4px; background: var(--paper2); color: var(--ink); }
|
||||
.pile-hint, .empty-pile { color: var(--muted); font-size: 13px; }
|
||||
.discard-list { display: grid; gap: 0.6rem; }
|
||||
.discard-card { background: var(--paper2); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
|
||||
.discard-card summary { display: flex; align-items: center; gap: 0.8rem; cursor: pointer; list-style: none; padding: 0.8rem; }
|
||||
.discard-card summary::-webkit-details-marker { display: none; }
|
||||
.pile-number { color: var(--muted); font-size: 12px; min-width: 1rem; }
|
||||
.discard-name { display: grid; gap: 0.3rem; flex: 1; }
|
||||
.discard-name strong { font-size: 14px; }
|
||||
.discard-name small { display: flex; align-items: center; gap: 0.3rem; color: var(--muted); font-size: 12px; }
|
||||
.top-card { color: var(--ink); border: 1px solid var(--line); border-radius: 4px; padding: 0.2rem 0.4rem; font-size: 10px; white-space: nowrap; }
|
||||
.discard-card[open] summary { border-bottom: 1px solid var(--line); }
|
||||
.discard-card[open] summary > :global(svg:last-child) { transform: rotate(180deg); }
|
||||
.discard-rules { padding: 0.2rem 1rem 1rem; font-size: 14px; line-height: 1.6; }
|
||||
.discard-id { color: var(--muted); font-size: 11px; }
|
||||
.discard-rules .card-battle-use { margin-bottom: 0; }
|
||||
@media (max-width: 600px) { .card-tabs { gap: 0.15rem; } .card-tabs button { padding: 0.5rem 0.35rem; font-size: 11px; gap: 0.25rem; } }
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ export interface Playback {
|
|||
animate: boolean;
|
||||
}
|
||||
export interface Game {
|
||||
action_cards_discarded?: number[];
|
||||
incidents_discarded?: number[];
|
||||
successful_cultural_influence?: boolean;
|
||||
options?: { length?: 'Standard' | 'Epic'; variant?: 'Standard' | 'Builder' };
|
||||
permanent_effects?: unknown[];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue