forked from WikiDeck/wikideck
Night 2 (2026-11-17), from the `claude/wikideck` fork's `night/2026-11-17` branch. It follows Night 1 (#22).
## What's in it
- **Duel engine** (fork #72, #80): 40-card decks of cards you own, Notability/Citations, keywords, effects T1–T12, Connected, a hidden-information-safe `viewFor`/`logFor`, and replay. Balance v1 tuning (#84) gives the first player about 51%.
- **Card profiles** (#70, #82): Figure, Location, Event, Institution or Doctrine, plus stats, keywords and rules text, all derived from real article data. Templates only.
- **Design and story** (#66, #69, #83): DUEL_DESIGN.md, plus the match log and the encyclopedic "Battle of X (2026)" recap.
- **PvP** (#74, #77, #81, #76, #85):
- The server checks ownership, and 40-card eligibility is enforced.
- Modes: Classic (ranked), Draft and Trending.
- Invites, quick match, Elo, a ladder and recap pages. Online matches render on the duel board.
- **Duel board UI** (#79): MTG-style card faces and combat declaration, built for 360 px first.
- **Polite Wikimedia client** (#73, #75): throttled, cached and identified requests, the mint-path fix, and a prefetch pool.
- **Android mining** (#78): native RandomX, as a sideload build. The emulator mined a testnet block.
- **Testnet ops** (#67, #68).
PR numbers refer to `claude/wikideck`.
## Status
- **Tests:** 423, of which 422 pass, 0 fail and 1 is skipped. The build is OK (`node:24-alpine`, `--network none`).
- **Testnet:** running this commit (036489c) on r350.
- **Untouched:** no changes to `server/testnet/consensus.ts`, `randomx.ts`, `native/` or the mainnet compose.
- **Review:** night-review reviewed fork #66–#79. #80–#85 came from the agents' unfinished branches and were not reviewed.
- **Known gaps:**
- The PvP end-to-end test hasn't been run (it needs two eom.dev accounts).
- Bot matches aren't reachable from Play.
- Card identity pre-bake hasn't been done.
- The RandomX verifier latch (`server/testnet/randomx.ts:140`) is still open.
This PR is for Eric to merge.
🤖 Generated with [Claude Code](https://claude.com/claude-code)Reviewed-on: WikiDeck/wikideck#23
Co-authored-by: Claude <claude@eom.dev>
41 lines
2.3 KiB
TypeScript
41 lines
2.3 KiB
TypeScript
/**
|
|
* WikiDeck Duel public API. Spec: docs/game/DUEL_API.md.
|
|
* Contracts PR: types and ruleset only. engine.ts (createDuel, legalActions,
|
|
* applyAction, viewFor, logFor, replay, ...) lands in the engine alpha PR and
|
|
* implements DuelEngineApi below; build against that interface until then.
|
|
*/
|
|
export * from './types.ts';
|
|
export * from './ruleset.ts';
|
|
export * from './engine.ts';
|
|
|
|
import type { DuelAction, DuelCard, DuelResult, DuelRuleset, DuelState, LogEvent, PlayerView, Seat } from './types.ts';
|
|
|
|
/** The engine's function surface (implemented by shared/duel/engine.ts). All pure; inputs are never mutated. */
|
|
export interface DuelEngineApi {
|
|
/** Throws if the deck is illegal: size ≠ deckSize, duplicate cardId, > maxCopiesPerPage of one pageId, bad stats, > maxKeywords. */
|
|
validateDeck(rules: DuelRuleset, cards: DuelCard[]): void;
|
|
/** Shuffle both decks from `seed`, deal opening hands, phase 'mulligan'. */
|
|
createDuel(rules: DuelRuleset, decks: [DuelCard[], DuelCard[]], seed: string): DuelState;
|
|
/** Atomic legal actions for `seat`; [] if `seat` is not the one to act (concede is always accepted by applyAction but not listed). */
|
|
legalActions(state: DuelState, seat: Seat): DuelAction[];
|
|
/** Returns a new state. Throws on an illegal action. */
|
|
applyAction(state: DuelState, seat: Seat, action: DuelAction): DuelState;
|
|
/** Seat that must act now, or null when over. Mulligan: the lowest seat not yet ready. */
|
|
toAct(state: DuelState): Seat | null;
|
|
isOver(state: DuelState): boolean;
|
|
result(state: DuelState): DuelResult | null;
|
|
viewFor(state: DuelState, seat: Seat): PlayerView;
|
|
/** Per-seat log: the opponent's draws (and other hidden-zone cards) are masked. */
|
|
logFor(state: DuelState, seat: Seat): LogEvent[];
|
|
/** Deterministic: same inputs → identical state (and log). */
|
|
replay(rules: DuelRuleset, decks: [DuelCard[], DuelCard[]], seed: string, actions: { seat: Seat; action: DuelAction }[]): DuelState;
|
|
serialize(state: DuelState): string;
|
|
deserialize(text: string): DuelState;
|
|
/** Current power/toughness of a permanent after counters, buffs, statics and Connected. */
|
|
statsOf(state: DuelState, uid: string): { power: number; toughness: number };
|
|
}
|
|
|
|
import * as engine from './engine.ts';
|
|
/** Compile-time check that engine.ts implements the contract. */
|
|
export const duelEngine: DuelEngineApi = engine;
|