Files
systemic-game-design-course/course/11-conditions/reference/ts/src/content/index.ts
T
Lucas WintherandClaude Opus 5.5 34c655c1a4 feat: Module 11, Conditions (NOUN ON NOUN IS ..., checked per object at use; NEAR as the Expansion Drop)
Adds course/11-conditions: lesson, scenarios, nine test_11 tests in both
tracks, the cumulative reference (Module 10's plus conditions) and the NEAR
drop. The engine learns a condition role, rules carry conditions, and
Level.hasProperty and conversion evaluate content's condition checks against
the board whenever a rule is used. Resolution pairs only rules with the same
conditions. Catalog, harness contract, research notes and the diff-tracks
generator follow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 13:00:26 +01:00

51 lines
2.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Content: the cards and the Baba Is You words. Only this directory (and the card
// data in `cards/`) may name specific cards, or specific Baba Is You nouns.
//
// From Module 5 every card is a JSON file in `cards/` at the package root, in the
// course's card format (`course/schema/card.schema.json`). The functions that were
// card effects in Modules 2–4 are gone: the engine interprets the data.
// `start-module` copies the course's card files into `cards/`; add your own there.
//
// Module 10: the cards are read with Node's file system, not Vite's `import.meta.glob`,
// so the SpellGrid command line (`npx tsx src/cli.ts`), which runs without Vite, reads
// the same cards as the tests.
import { readdirSync, readFileSync } from "node:fs";
import type { CardDef, puzzle, SeamWords } from "../engine";
import seamWords from "./seams.json";
import wordList from "./words.json";
export { conditions } from "./conditions";
export { hazards } from "./hazards";
export { responses as movement } from "./movement";
const CARDS = new URL("../../cards/", import.meta.url);
let loaded: CardDef[] | undefined;
/** Every card in `cards/`, in file-name order. Read once. */
export function cards(): CardDef[] {
loaded ??= readdirSync(CARDS)
.filter((file) => file.endsWith(".json"))
.sort()
.map((file) => JSON.parse(readFileSync(new URL(file, CARDS), "utf8")) as CardDef);
return loaded;
}
/**
* Part II: the words of Baba Is You the parser can read, besides the engine's own
* (`IS`, `AND`, `NOT`, `TEXT`). Nouns and properties are data: a new word is one
* more entry in `words.json` in this directory. A condition word (Module 11) also
* needs its check in `conditions.ts`.
*/
export function words(): puzzle.WordDef[] {
return wordList as puzzle.WordDef[];
}
/**
* Part III: the words that cross between the engines (`seams.json`). A noun that
* names a trigger, and a property that multiplies one: `DEATHRATTLE IS DOUBLE`.
*/
export function seams(): SeamWords {
return seamWords as SeamWords;
}