Regenerate the rules file
Goal: refresh docs-site/src/data/rules.json so the reference pages match the code.
-
Change the rule in
prototype/index.htmlfirst. The rules file is generated from it, so never editrules.jsonby hand. -
Make sure Playwright and a Chromium browser are installed (see run the bot simulator). If you use your own browser, set
PW_CHROMIUMto its path. -
From the
docs-sitefolder, run:Terminal window npm run rulesThis runs
node ../tools/extract-rules.js, which loads the prototype in headless Chromium and writessrc/data/rules.json. To write somewhere else, call the script directly with an output path:node ../tools/extract-rules.js /tmp/rules.json. -
Read the last line. It names any constants it could not find (
missing: []means none), any page errors, and the function-valued fields it skipped (today onlyBOARDS.mine). -
Run
git diff docs-site/src/data/rules.jsonto see what changed. -
Rebuild the site with
npm run buildand check the reference pages that use the changed values.
The script copies these constants: the grid size, stages, crew rest, species, zones, mills, buildings, sawmill levels, markets, milestones, settler rules, Reserve rules, crops, Mercantile shelves, contests, the deed target, map layout, neighbors and boards.
What can go wrong
Section titled “What can go wrong”If a new constant is not in the script’s NAMES list, it is not extracted. Add its name to the list in tools/extract-rules.js and rerun.
If a constant was renamed or removed in the prototype, it appears in the missing list and its entry in rules.json becomes an error object. Fix the script or the code.
The script reads prototype/index.html. The page standalone.html is the same game inside a wrapper, so edit the game in index.html only and rebuild the wrapper from it.
Functions are skipped on purpose. Logic still has to be documented by hand.