Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Regenerate the rules file

Goal: refresh docs-site/src/data/rules.json so the reference pages match the code.

  1. Change the rule in prototype/index.html first. The rules file is generated from it, so never edit rules.json by hand.

  2. Make sure Playwright and a Chromium browser are installed (see run the bot simulator). If you use your own browser, set PW_CHROMIUM to its path.

  3. From the docs-site folder, run:

    Terminal window
    npm run rules

    This runs node ../tools/extract-rules.js, which loads the prototype in headless Chromium and writes src/data/rules.json. To write somewhere else, call the script directly with an output path: node ../tools/extract-rules.js /tmp/rules.json.

  4. 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 only BOARDS.mine).

  5. Run git diff docs-site/src/data/rules.json to see what changed.

  6. Rebuild the site with npm run build and 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.

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.