Files
wikideck/shared/duel/story/templates.ts

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]);
});
}