Skip to content

A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D

Lint the game's schedules in pnpm check (bevy-ts-devtools lint)

SandroMaglione9cdfdaef79cb
diff --git a/package.json b/package.json
index 44488b2..2f787eb 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,8 @@
"balance:worth": "node scripts/worth.ts",
"balance:furniture": "node scripts/furniture.ts",
"balance:model:check": "node --test test/balance-model.test.ts",
- "check": "pnpm lint && node scripts/check.ts",
+ "lint:game": "bevy-ts-devtools lint src/sim/headless.ts",
+ "check": "pnpm lint && pnpm lint:game && node scripts/check.ts",
"check:browser": "node scripts/check-browser.ts",
"check:phone": "node scripts/check-phone.ts",
"check:models": "node scripts/check-town-models.ts",
@@ -39,6 +40,7 @@
"three": "^0.186.1"
},
"devDependencies": {
+ "@typeonce/bevy-ts-devtools": "^0.5.0",
"@types/node": "25.5.0",
"@types/three": "^0.186.0",
"oxlint": "1.87.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index c49b7ac..1c62ebe 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -33,6 +33,9 @@ importers:
specifier: ^0.186.1
version: 0.186.1
devDependencies:
+ '@typeonce/bevy-ts-devtools':
+ specifier: ^0.5.0
+ version: 0.5.0([email protected])
'@types/node':
specifier: 25.5.0
version: 25.5.0
@@ -277,6 +280,10 @@ packages:
resolution: {integrity: sha512-69IcRugcpq0bfd809RtmuZbJ/11zrcTTJyJ0o5kDDTQWY7RtqNUm1layTTbBqnJYl8rkMXP0Qzzu2Pcypz/2pA==}
engines: {node: '>=20'}
+ '@typeonce/[email protected]':
+ resolution: {integrity: sha512-9N9pTjitHmkQnWy7yYcyr2WD48+yjJ994ZA3ZQK44TtZJ6lRQ5SH+7Dfe/sb5EurSBzktGYOQAh7coJAx6mh7A==}
+ engines: {node: '>=20'}
+
'@typeonce/[email protected]':
resolution: {integrity: sha512-uxeRQ8Yhhrl98KdcUYBNeVTzppOnyVlzXinOlEogkHvV3Gal4ctBYVpP36LY/+3oENK3FMQXr5ESJN+cMKj2fQ==}
engines: {node: '>=20'}
@@ -788,6 +795,12 @@ snapshots:
transitivePeerDependencies:
- typescript
+ dependencies:
+ '@typeonce/bevy-ts': 0.5.0([email protected])
+ transitivePeerDependencies:
+ - typescript
+
dependencies:
'@typeonce/bevy-ts': 0.5.0([email protected])
diff --git a/src/sim/headless.ts b/src/sim/headless.ts
index 86c6fb1..a846bad 100644
--- a/src/sim/headless.ts
+++ b/src/sim/headless.ts
@@ -20,14 +20,36 @@ export interface Snapshot {
machines: Record<string, string>
}
+/** The page's UI state before anything is clicked, with one edit founding the town. */
+const blankUi = (charter: CharterValue, toast: (message: string) => void): UiValue => ({
+ tool: "select", placing: null, upgrading: null, ground: "lawn", prop: "lamp", menu: null, pointer: null, dragFrom: null, selected: null, gestures: [], guide: [],
+ edits: [{ type: "newTown", charter }],
+ preview: emptyPreview(), hits: [], panel: null, centres: new Map(), stats: null, speed: 1, founding: false,
+ view: "none", overlay: { key: "", cells: [] }, tints: new Map(), wanted: new Map(), legend: null, flash: null,
+ toast
+})
+
+const lintCharter: CharterValue = { size: "small", term: 45, land: "fair", seed: 7 }
+
+/**
+ * What `bevy-ts-devtools lint src/sim/headless.ts` checks (`pnpm lint:game`,
+ * part of `pnpm check`): the simulation on a debug runtime, and the page's
+ * `present` schedule described without running (it needs the renderer).
+ */
+export const lintTarget = async () => {
+ // Loaded here only: tests and bots that use `headless` never load the renderer.
+ const { present } = await import("../present.ts")
+ const made = Game.Runtime.make({
+ services: Game.Runtime.services(Game.Runtime.service(Ui, blankUi(lintCharter, () => {})), Game.Runtime.service(Rules, resolveRules())),
+ resources: blankResources(),
+ debug: true
+ })
+ if (!made.ok) throw new Error(`The town could not start: ${JSON.stringify(made.error)}`)
+ return { runtime: made.value, schedules: { simulate }, describe: { present } }
+}
+
export const headless = (charter: CharterValue, options: { readonly toast?: (message: string) => void; readonly rules?: RuleInputs } = {}) => {
- const ui: UiValue = {
- tool: "select", placing: null, upgrading: null, ground: "lawn", prop: "lamp", menu: null, pointer: null, dragFrom: null, selected: null, gestures: [], guide: [],
- edits: [{ type: "newTown", charter }],
- preview: emptyPreview(), hits: [], panel: null, centres: new Map(), stats: null, speed: 1, founding: false,
- view: "none", overlay: { key: "", cells: [] }, tints: new Map(), wanted: new Map(), legend: null, flash: null,
- toast: options.toast ?? (() => {})
- }
+ const ui = blankUi(charter, options.toast ?? (() => {}))
const made = Game.Runtime.make({ services: Game.Runtime.services(Game.Runtime.service(Ui, ui), Game.Runtime.service(Rules, options.rules ?? resolveRules())), resources: blankResources() })
if (!made.ok) throw new Error(`The town could not start: ${JSON.stringify(made.error)}`)
const runtime = made.value