Files
systemic-game-design-course/course/01-handles/reference/ts/src/engine/card.ts
T
2026-10-29 00:17:31 +01:00

22 lines
626 B
TypeScript

// Card definitions as the engine sees them. The definitions themselves live in `content`.
/** What the engine needs to know about a card. Module 1: only its name. */
export interface CardDef {
name: string;
}
/** Every card the game can create, looked up by name. */
export class CardLibrary {
private readonly cards = new Map<string, CardDef>();
constructor(defs: CardDef[]) {
for (const def of defs) this.cards.set(def.name, def);
}
get(name: string): CardDef {
const def = this.cards.get(name);
if (!def) throw new Error(`unknown card "${name}": define it in src/content`);
return def;
}
}