Files
systemic-game-design-course/course/05-assemble/reference/ts
Lucas WintherandClaude Opus 5.5 372c99c306 feat: replacement effects in Module 4 (Armor absorption, Bolf Ramshield redirect)
Applying a Damage to one target now runs DAMAGE_STEPS = [redirect, armor]
first. A damageRedirect aura (Bolf Ramshield, fetched from the wiki) sends
damage meant for its owner's hero to the oldest such minion; Armor absorbs
damage to a hero before Health, logged as the new ArmorLost{player, amount}
just before a full-amount Damaged. Four new Module 4 tests; propagated to the
references of Modules 4-10 in both tracks; card schema, catalog, card JSON,
harness.md, Lessons 2, 4 and 5 updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 10:44:06 +01:00
..
2026-10-29 03:17:21 +01:00
2026-10-29 03:17:21 +01:00
2026-10-29 03:17:21 +01:00
2026-10-29 03:17:21 +01:00
2026-10-29 03:17:21 +01:00
2026-10-29 03:17:21 +01:00
2026-10-29 03:17:21 +01:00

Module 5 reference engine (TypeScript)

The course's own engine as of the end of Module 5. Every card is now data: a JSON file in the course's card format (course/schema/card.schema.json), and the functions that were card effects in Modules 2–4 are gone. One interpreter turns effects into actions. Assemble builds a new card by replacing half of one card's text with the same half of another's. Module 4's reference was the starting point, so a diff between the two shows what this module adds.

  • cards/ (at the package root; not in this directory): the card data. It is a copy of course/cards/, the single source: tools/verify-references.mjs stages it next to the package, and tools/start-module.mjs copies it into a learner's workspace.
  • src/engine/: generic machinery. Names no cards.
    • card.ts: the card format as TypeScript types (CardDef, Clause, Effect, Target, Aura), and the library. Registering a definition compiles its clauses into triggers, auras and a spell's effects, and marks whether Assemble may offer it (minions with text that were not themselves assembled). TriggerOn gains endOfTurn, which card data may name (Drakkari Enchanter's aura does); the course has no turns, so nothing fires it.
    • effect.ts: the interpreter: one effect plus its context in, actions out. The only code that knows what dealDamage, draw, summon, assemble, buffHand, ... mean.
    • assemble.ts: assemble(base, donor, half) (list surgery on text at split; throws AssembleError if the text is unchanged), and the assemble effect, which asks the chooser for a base from the filtered pool, a donor and a half.
    • queue.ts: as in Module 4, plus two actions (assemble, buff). An ability's effects are interpreted and performed one at a time, in printed order.
    • world.ts: as in Module 4, plus card registration, cost, the chooser, and buff.
    • aura.ts, death.ts, event.ts: unchanged from Module 4.
  • src/content/index.ts: imports every .json file in cards/ with Vite's import.meta.glob. No card is named in TypeScript any more.
  • src/harness.ts: the adapter the course tests call. Module 5 adds registerCards, assemble, cost and setChooser.

Run it with the module's tests: node tools/verify-references.mjs 05 from the course repository. npm test in this directory alone fails: there is no cards/ here.