Files
wikideck/src/game/types.ts
T
claudeandClaude Opus 5.5 c4636530ef Play: bots see only viewFor output (MatchView.engine = { view, seat })
Per night-lead's rule on #5 the adapter no longer exposes MatchState to
bots; a test checks no RNG state, seed or deck order leaks.

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

90 lines
2.9 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, PlayerId, PlayerView, 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 engine-level bots (ui-b): this seat's hidden-information view only (night-lead: never the full MatchState). */
engine?: { view: PlayerView; seat: PlayerId };
};
export type UIAction = (
| { type: 'play'; cardId: string; lane: number }
| { type: 'unstage'; cardId: string }
| { type: 'endTurn' }
| { type: 'concede' }
) & { engine?: Action };
/** Always from the viewer's side: 0 = you, 1 = your opponent, null = draw. */
export type ResultView = {
winner: PlayerIndex | null;
lanes: { name: string; myPower: number; theirPower: number; winner: PlayerIndex | null }[];
turns: number;
reason: MatchResult['reason'];
totalPower: [number, number];
};
export type GameMode = {
id: string;
/** The host's own mode id (for /api/game/modes/:id/...). */
remoteId?: string;
name: string;
description: string;
host: { kind: 'local' } | { kind: 'peer'; name: string; url: string; self: boolean };
ruleset: Ruleset;
players?: number;
matchesPlayed?: number;
};