Headless, data-driven core (no DOM, no eval): loader with one-pass validation, verb-coin interaction resolution, polygon walkables with Dijkstra pathfinding, branching dialogue with mid-conversation saves, declarative JSON conditions/effects, versioned JSON saves. Thin integration layer: asset manifest with graceful placeholders, WebAudio music loop points (midi-playlist convention), canvas renderer (hotspot boxes drawn where hitTest clicks), HUD model. Web harness (web/) + skeleton example game exercising every feature. 69 tests (node --test), tools/run_all.sh gate, docs/SPEC.md design spec. Verified end-to-end in a real browser: intro scene, walking, look/take, room exits, dialogue choices.
33 lines
1.1 KiB
JavaScript
33 lines
1.1 KiB
JavaScript
#!/usr/bin/env node
|
|
// validate_game.js — CLI front door: check a game spec, print every problem
|
|
// at once. Exit 0 = valid (warnings allowed), 1 = invalid.
|
|
//
|
|
// node tools/validate_game.js example/game.json
|
|
|
|
import { readFileSync } from "node:fs";
|
|
import { validate } from "../src/core/loader.js";
|
|
|
|
const file = process.argv[2];
|
|
if (!file) {
|
|
console.error("usage: node tools/validate_game.js <game.json>");
|
|
process.exit(2);
|
|
}
|
|
let spec;
|
|
try {
|
|
spec = JSON.parse(readFileSync(file, "utf8"));
|
|
} catch (e) {
|
|
console.error(`ERROR: ${file} is not valid JSON: ${e.message}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
const { errors, warnings } = validate(spec);
|
|
for (const w of warnings) console.warn("WARNING:", w);
|
|
if (errors.length) {
|
|
console.error(`ERROR: ${file}: spec invalid:`);
|
|
for (const e of errors) console.error(" - " + e);
|
|
process.exit(1);
|
|
}
|
|
console.log(`OK: ${file} (${spec.rooms.length} rooms, ${spec.objects?.length ?? 0} objects, ` +
|
|
`${spec.characters.length} characters, ${spec.interactions?.length ?? 0} interactions, ` +
|
|
`${Object.keys(spec.dialogues ?? {}).length} dialogues, ${Object.keys(spec.scenes ?? {}).length} scenes)`);
|