From 4daf87eddecbdb73ae04b2a24a1e15dc6410fe92 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 21:36:41 -0500 Subject: [PATCH] duel-core: monotonic attack/block declarations; optional permanent counters Co-Authored-By: Claude Opus 5.5 --- docs/game/DUEL_API.md | 6 +++--- shared/duel/types.ts | 13 ++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/game/DUEL_API.md b/docs/game/DUEL_API.md index 31a5f78..a52fd32 100644 --- a/docs/game/DUEL_API.md +++ b/docs/game/DUEL_API.md @@ -64,12 +64,12 @@ Engine-side keyword meanings (designer §3.4; duel-design owns the wording): |---|---|---| | `mulligan` | each seat not yet ready (seat 0 first) | `keep`, `mulligan` | | `main` | active | `play {uid, target?}` (cost ≤ Citations; Events and permanents), `endPhase` | -| `attack` | active | `toggleAttacker {uid}` (untapped, non-sick Figure), `confirmAttack` | -| `block` | defender | `block {blocker, attacker}`, `unblock {blocker}`, `confirmBlocks` | +| `attack` | active | `toggleAttacker {uid}` (declare an untapped, non-sick Figure not yet declared), `confirmAttack` | +| `block` | defender | `block {blocker, attacker}` (unassigned blocker, unblocked attacker), `confirmBlocks` | | any | either seat | `concede` (not listed; always accepted) | | any | host only | `timeout` for the seat that must act: in `main`/`attack` ends the turn without attacking, in `block` confirms the current blocks, in `mulligan` keeps. It does **not** lose the game; the host decides when a bank is exhausted and may then send `concede`. | -`confirmAttack` with no attackers ends the turn. Attacking taps the attackers. `onAttack` triggers resolve at `confirmAttack`. +Declarations are **monotonic** (no un-declare action), so every turn has a bounded number of actions; UIs stage choices locally and send them on confirm. If the defender has no legal block, combat damage resolves at `confirmAttack` without a block phase. `confirmAttack` with no attackers ends the turn. Attacking taps the attackers. `onAttack` triggers resolve at `confirmAttack`. ## Views and log - `viewFor(state, seat): PlayerView`: your hand, sizes of the opponent's hand and library, both graveyards, the battlefield with **current** power/toughness and Connected badge, combat, `toAct`, `version`, `result`. diff --git a/shared/duel/types.ts b/shared/duel/types.ts index d35ab5a..f1b181c 100644 --- a/shared/duel/types.ts +++ b/shared/duel/types.ts @@ -176,6 +176,12 @@ export interface Permanent extends CardInstance { tempToughness: number; /** Doctrines: uid of the Figure they're attached to. */ attachedTo?: string; + /** Well-sourced: prevention already used this turn. */ + shielded?: boolean; + /** Stub: counters gained from Stub so far (≤ 2). */ + stubCounters?: number; + /** Connected bonus already logged. */ + connectedLogged?: boolean; } export interface PlayerState { @@ -193,6 +199,8 @@ export interface PlayerState { ready: boolean; // kept the opening hand /** Remaining time bank, in seconds (the host decrements it). */ bankSeconds: number; + /** libraryEmpty 'fatigue': damage of the next empty draw minus 1. */ + fatigue?: number; } export interface CombatState { @@ -236,10 +244,9 @@ export type DuelAction = | { type: 'mulligan' } | { type: 'play'; uid: string; target?: TargetRef } | { type: 'endPhase' } // main → attack - | { type: 'toggleAttacker'; uid: string } // attack phase + | { type: 'toggleAttacker'; uid: string } // attack phase: declare one more attacker (monotonic; UIs stage undo locally) | { type: 'confirmAttack' } // no attackers → end turn - | { type: 'block'; blocker: string; attacker: string } // block phase (defender) - | { type: 'unblock'; blocker: string } + | { type: 'block'; blocker: string; attacker: string } // block phase (defender), monotonic | { type: 'confirmBlocks' } // damage, then end of turn | { type: 'concede' } // any time, either seat | { type: 'timeout' }; // host-only, for the seat that must act