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>
51 lines
2.0 KiB
TypeScript
51 lines
2.0 KiB
TypeScript
// 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;
|
||
}
|