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>
157 lines
6.0 KiB
TypeScript
157 lines
6.0 KiB
TypeScript
/**
|
|
* Match-log sentence templates (DUEL_DESIGN.md §8.2). Data only.
|
|
*
|
|
* Tone (BRIEF decision 5, DUEL_DESIGN §8.1): past tense, encyclopedic, deadpan. No adjectives
|
|
* about cards or players, no exclamation marks, never comment on the matchup. Placeholders
|
|
* are filled only with real card and match data. `tests/duel-design-story.test.ts` lints this file.
|
|
*
|
|
* Placeholders: {player} {opponent} {card} {doctrine} {figure} {attacker} {blocker} {source}
|
|
* {target} {token} {a} {b} {reason} {winner} {loser} {n} {count} {p} {t} {life} {turn}.
|
|
*/
|
|
export const LOG_TEMPLATES = {
|
|
deploy: [
|
|
'{player} deployed {card}.',
|
|
'{card} was deployed by {player}.',
|
|
'{player} brought {card} into play.',
|
|
'{card} entered play under {player}.',
|
|
],
|
|
cast: [
|
|
'{player} cited {card}.',
|
|
'{card} was cited by {player}.',
|
|
'{player} invoked {card}.',
|
|
],
|
|
adopt: [
|
|
'{doctrine} was adopted by {figure}, which became a {p}/{t}.',
|
|
'{figure} adopted {doctrine} and became a {p}/{t}.',
|
|
'{player} attached {doctrine} to {figure} ({p}/{t}).',
|
|
],
|
|
attack: [
|
|
'{card} ({p}/{t}) attacked.',
|
|
'{player} sent {card} ({p}/{t}) into combat.',
|
|
'{card} ({p}/{t}) advanced on {opponent}.',
|
|
],
|
|
block: [
|
|
'{blocker} ({p}/{t}) blocked {attacker}.',
|
|
'{attacker} was blocked by {blocker} ({p}/{t}).',
|
|
'{blocker} ({p}/{t}) intercepted {attacker}.',
|
|
],
|
|
playerDamage: [
|
|
'{player} lost {n} Notability ({life} remaining).',
|
|
'{source} dealt {n} damage to {player}, leaving {life} Notability.',
|
|
"{player}'s Notability fell to {life}.",
|
|
],
|
|
lifeGain: [
|
|
'{player} gained {n} Notability from {source} ({life} total).',
|
|
'{source} restored {n} Notability to {player}.',
|
|
"{player}'s Notability rose to {life} ({source}).",
|
|
],
|
|
effectDamage: [
|
|
'{source} dealt {n} damage to {target}.',
|
|
'{target} took {n} damage from {source}.',
|
|
'{source} inflicted {n} damage on {target}.',
|
|
],
|
|
destroyed: [
|
|
'{card} was destroyed.',
|
|
'{card} was moved to Deleted.',
|
|
'{card} was removed from play.',
|
|
'{card} did not survive the turn.',
|
|
],
|
|
tokenCreated: [
|
|
'{source} produced {count} {token}.',
|
|
'{source} brought {count} {token} into play.',
|
|
'{source} created {count} {token}.',
|
|
],
|
|
drawKnown: [
|
|
'{player} drew {card}.',
|
|
'{card} was drawn by {player}.',
|
|
'{player} added {card} to their hand.',
|
|
],
|
|
drawHidden: [
|
|
'{player} drew a card.',
|
|
'{player} drew one card.',
|
|
'{player} added a card to their hand.',
|
|
],
|
|
drawHiddenMany: [
|
|
'{player} drew {count} cards.',
|
|
'{player} added {count} cards to their hand.',
|
|
'{player} took {count} cards into hand.',
|
|
],
|
|
discard: [
|
|
'{player} discarded {card}.',
|
|
'{card} was discarded by {player}.',
|
|
'{player} moved {card} from hand to Deleted.',
|
|
],
|
|
connected: [
|
|
'{a} and {b} were Connected ({reason}).',
|
|
'{a} was Connected to {b} through {reason}.',
|
|
'Records link {a} and {b} ({reason}).',
|
|
],
|
|
rivalry: [
|
|
'{a} and {b} are both listed under {reason}.',
|
|
'{a} and {b} share {reason}.',
|
|
'The two sides were linked through {reason}.',
|
|
],
|
|
gameOverLife: [
|
|
'{loser} was nominated for deletion. The result was **delete**.',
|
|
'{loser} was reduced to 0 Notability. {winner} won.',
|
|
'{winner} won on turn {turn}.',
|
|
],
|
|
gameOverDraw: [
|
|
'Both sides were reduced to 0 Notability. The engagement ended in a draw.',
|
|
'The engagement ended in a draw on turn {turn}.',
|
|
'Neither side retained any Notability. No winner was recorded.',
|
|
],
|
|
gameOverLibrary: [
|
|
'{loser} could not draw a card and lost.',
|
|
'{loser} ran out of cards. {winner} won.',
|
|
"{loser}'s library was exhausted. {winner} won.",
|
|
],
|
|
gameOverConcede: [
|
|
'{loser} withdrew.',
|
|
'{loser} withdrew. {winner} won.',
|
|
'{loser} conceded on turn {turn}.',
|
|
],
|
|
gameOverTimeout: [
|
|
'{loser} did not respond in time and withdrew.',
|
|
'{loser} ran out of time. {winner} won.',
|
|
"{loser}'s clock expired on turn {turn}.",
|
|
],
|
|
gameOverTurnCap: [
|
|
'{winner} won on Notability at the turn limit.',
|
|
'The turn limit was reached. {winner} won on Notability.',
|
|
'The engagement reached the turn limit; {winner} held more Notability.',
|
|
],
|
|
} as const satisfies Record<string, readonly string[]>;
|
|
|
|
export type TemplateKey = keyof typeof LOG_TEMPLATES;
|
|
|
|
/** Words the generator must never emit (critic S7 failure modes). Lowercase; whole words. */
|
|
export const BANNED_WORDS = [
|
|
'brutal', 'brutally', 'heroic', 'heroically', 'humiliating', 'humiliated', 'bloodiest', 'bloody',
|
|
'surprising', 'surprisingly', 'ironically', 'unlikely', 'hilarious', 'tragic', 'tragically', 'sadly',
|
|
'unfortunately', 'poor', 'epic', 'crushed', 'squashed', 'killed', 'murdered', 'destroyed utterly', 'lol',
|
|
];
|
|
|
|
export const FOOTER =
|
|
'This page records a WikiDeck match. Card names refer to Wikipedia articles; the events described are game events.';
|
|
|
|
const NUMBER_WORDS = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven',
|
|
'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty'];
|
|
export function numberWord(n: number): string {
|
|
return Number.isInteger(n) && n >= 0 && n < NUMBER_WORDS.length ? NUMBER_WORDS[n] : String(n);
|
|
}
|
|
const ORDINALS = ['zeroth', 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth',
|
|
'eleventh', 'twelfth', 'thirteenth', 'fourteenth', 'fifteenth', 'sixteenth', 'seventeenth', 'eighteenth', 'nineteenth', 'twentieth'];
|
|
export function ordinalWord(n: number): string {
|
|
if (Number.isInteger(n) && n >= 0 && n < ORDINALS.length) return ORDINALS[n];
|
|
const s = n % 100 >= 11 && n % 100 <= 13 ? 'th' : ({ 1: 'st', 2: 'nd', 3: 'rd' } as Record<number, string>)[n % 10] ?? 'th';
|
|
return `${n}${s}`;
|
|
}
|
|
|
|
export function fill(template: string, values: Record<string, string | number>): string {
|
|
return template.replace(/\{(\w+)\}/g, (whole, key: string) => {
|
|
if (!(key in values)) throw new Error(`story template is missing a value for {${key}}: ${template}`);
|
|
return String(values[key]);
|
|
});
|
|
}
|