Files
wikideck/src/game/types.ts
T
claudeandClaude Opus 5.5 a2573129a5 Play: wire the real shared/game engine (DESIGN v1 Edit War)
Replace the mock with an adapter over shared/game/index.ts: Topics with
stats and hidden Portals, home-stat icons and on-topic hints, queued
plays with undo, interleaved reveal log, engine deck validation, loaner
starter decks, interim NFT derivation (cost-capped). Lobby reads the
modes API (self + peers) and links to peer hosts; the account chip uses
the SSO hook; the floating account button hides during a match.
MatchView.engine / UIAction.engine expose engine state for ui-b's bots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 23:25:29 -05:00

87 lines
2.7 KiB
TypeScript

// UI-side view models for the Play section. Screens consume only these; adapter.ts maps the
// shared/game engine (docs/game/ENGINE_API.md) onto them.
import type { Action, GameCard, MatchResult, MatchState, PlayerId, Ruleset, Stat } from '../../shared/game/index.ts';
export type PlayerIndex = PlayerId;
export type { Stat };
/** A card as the deck builder and match screen show it (DESIGN §1.9): cost, power, home icon, trend, one keyword. */
export type UICard = {
id: string; // engine cardId
pageId: number | null;
title: string;
category: string; // faction
image?: string;
cost: number;
power: number; // current lane power on the board, base power elsewhere
basePower: number;
home: Stat;
trend: -1 | 0 | 1;
onTopic?: boolean; // on the board: the Topic's stat matches home (or Disambiguation)
keyword?: { id: string; name: string; text: string };
source: 'starter' | 'nft';
tokenId?: string;
rarity?: string;
game: GameCard;
};
export type LaneView = {
index: number;
name: string; // Topic name
stat: Stat;
modifier?: { name: string; text: string }; // revealed Portal
portalNote?: string; // e.g. "Portal reveals on turn 3"
revealed: boolean;
mine: UICard[];
theirs: UICard[];
staged: UICard[]; // my queued plays this turn, not yet revealed
myPower: number;
theirPower: number;
leader: 'you' | 'opponent' | null;
capacity: number;
};
export type MatchView = {
me: PlayerIndex;
turn: number;
maxTurns: number;
energy: number; // left this turn
maxEnergy: number;
hand: UICard[];
deckCount: number;
oppHandCount: number;
oppDeckCount: number;
oppQueued: number;
lanes: LaneView[];
log: string[]; // newest last, this seat's events only
waitingForOpponent: boolean;
over: boolean;
/** For bots that reuse shared/bots (ui-b): the full state and this seat. Never render it. */
engine?: { state: MatchState; seat: PlayerId };
};
export type UIAction = (
| { type: 'play'; cardId: string; lane: number }
| { type: 'unstage'; cardId: string }
| { type: 'endTurn' }
| { type: 'concede' }
) & { engine?: Action };
export type ResultView = {
winner: PlayerIndex | null; // null = draw
lanes: { name: string; myPower: number; theirPower: number; winner: PlayerIndex | null }[];
turns: number;
reason: MatchResult['reason'];
totalPower: [number, number];
};
export type GameMode = {
id: string;
name: string;
description: string;
host: { kind: 'local' } | { kind: 'peer'; name: string; url: string; self: boolean };
ruleset: Ruleset;
players?: number;
matchesPlayed?: number;
};