A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D
Saves: snapshot() is a Result, and snapshot format 3 (save version 11)
SandroMaglionef79628eedfdf
diff --git a/scripts/check-browser.ts b/scripts/check-browser.tsindex 37b5461..e0a97c2 100644--- a/scripts/check-browser.ts+++ b/scripts/check-browser.ts@@ -14,7 +14,7 @@ import type { Snapshot } from "../src/game/headless.ts"declare global {interface Window {- town:{interaction:Interaction;shown:Shown;edits:EditQueue;view:GameScene;advance:(seconds:number)=>void;runtime:{snapshot:()=>Snapshot}}+ town:{interaction:Interaction;shown:Shown;edits:EditQueue;view:GameScene;advance:(seconds:number)=>void;snapshot:()=>Snapshot}}}const executable=process.env.BROWSER_EXECUTABLE_PATH??["/Applications/Brave Browser.app/Contents/MacOS/Brave Browser","/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"].find(existsSync)@@ -27,7 +27,7 @@ const output="output/inkline-3d/game-check"await mkdir(output,{recursive:true})const facts:Record<string,unknown>={}const frames=async()=>page.waitForFunction(()=>window.town?.view.stats().frames>3)-const snapshot=()=>page.evaluate(()=>window.town.runtime.snapshot())+const snapshot=()=>page.evaluate(()=>window.town.snapshot())const entities=async(kind:string)=>(await snapshot()).entities.filter(e=>kind in e.components)const point=async(x:number,y:number,z=0)=>page.evaluate(([x,y,z])=>window.town.view.project(x!,y!,z!),[x,y,z])const clickGrid=async(x:number,y:number,z=0)=>{const p=await point(x,y,z);await page.mouse.click(p.x,p.y)}@@ -55,16 +55,16 @@ try {facts.rotatedSelection=trueawait tool("road")await dragGrid([tile.x+4.5,tile.y+1.5],[tile.x+8.5,tile.y+1.5])- await page.waitForFunction(([x,y])=>[4,5,6,7,8].every(dx=>window.town.runtime.snapshot().entities.some(e=>e.components["Town/Road"]&&e.components["Town/Tile"].x===x!+dx&&e.components["Town/Tile"].y===y!+1)),[tile.x,tile.y])+ await page.waitForFunction(([x,y])=>[4,5,6,7,8].every(dx=>window.town.snapshot().entities.some(e=>e.components["Town/Road"]&&e.components["Town/Tile"].x===x!+dx&&e.components["Town/Tile"].y===y!+1)),[tile.x,tile.y])facts.rotatedRoadDrag=trueawait tool("homes")await dragGrid([tile.x+5.5,tile.y+2.5],[tile.x+8.5,tile.y+2.5])- await page.waitForFunction(()=>window.town.runtime.snapshot().entities.filter(e=>e.components["Town/House"]).length===4)+ await page.waitForFunction(()=>window.town.snapshot().entities.filter(e=>e.components["Town/House"]).length===4)facts.rotatedHomeDrag=trueawait tool("build")await page.locator(".panel .option").filter({has:page.locator(".name",{hasText:"lumberjack"})}).click()await clickGrid(tile.x+7,tile.y)- await page.waitForFunction(()=>window.town.runtime.snapshot().entities.some(e=>e.components["Town/Building"]?.kind==="lumberjack"))+ await page.waitForFunction(()=>window.town.snapshot().entities.some(e=>e.components["Town/Building"]?.kind==="lumberjack"))const lumber=(await entities("Town/Building")).find(e=>e.components["Town/Building"].kind==="lumberjack")!assert.deepEqual(lumber.components["Town/Tile"],{x:tile.x+6,y:tile.y-1,size:2})facts.rotatedBuildingPlacement=true@@ -80,20 +80,20 @@ try {await page.waitForFunction(id=>window.town.interaction.selected===id,lumber.id)const pauseWork=page.getByRole("button",{name:"Pause work",exact:true})await pauseWork.click()- await page.waitForFunction(id=>!!window.town.runtime.snapshot().entities.find(e=>e.id===id)?.components["Town/Paused"],lumber.id)+ await page.waitForFunction(id=>!!window.town.snapshot().entities.find(e=>e.id===id)?.components["Town/Paused"],lumber.id)await page.getByRole("button",{name:"Resume work",exact:true}).click()- await page.waitForFunction(id=>!("Town/Paused" in window.town.runtime.snapshot().entities.find(e=>e.id===id)!.components),lumber.id)+ await page.waitForFunction(id=>!("Town/Paused" in window.town.snapshot().entities.find(e=>e.id===id)!.components),lumber.id)facts.buildingPauseResume=trueawait page.locator(".panel .close").click()await page.getByRole("button",{name:"save",exact:true}).click()const saved=await page.evaluate(()=>JSON.parse(localStorage.getItem("inkline-town/save/manual")!))await tool("bulldoze")await clickGrid(lt.x+1,lt.y+1,16)- await page.waitForFunction(id=>!window.town.runtime.snapshot().entities.some(e=>e.id===id),lumber.id)+ await page.waitForFunction(id=>!window.town.snapshot().entities.some(e=>e.id===id),lumber.id)facts.rotatedBulldozing=trueawait page.getByRole("button",{name:"load",exact:true}).click()await page.getByRole("button",{name:"Load without saving",exact:true}).click()- await page.waitForFunction(id=>window.town.runtime.snapshot().entities.some(e=>e.id===id),lumber.id)+ await page.waitForFunction(id=>window.town.snapshot().entities.some(e=>e.id===id),lumber.id)await page.waitForFunction(()=>window.town.view.stats().nodes>0)assert.deepEqual(await snapshot(),saved.world)facts.saveLoadUnchangedFormat=true@@ -127,7 +127,7 @@ try {await page.waitForFunction(()=>window.town.shown.town.stats!.settlers>100)// The guide puts away what the bot's town has already done (as edits, kept on the next frame without a step of time); the rest loads exactly as saved.const withoutGuide=(w:Snapshot)=>({...w,resources:{...w.resources,"Town/Guide":null}})- await page.waitForFunction(()=>window.town.runtime.snapshot().resources["Town/Guide"].done.length>0)+ await page.waitForFunction(()=>window.town.snapshot().resources["Town/Guide"].done.length>0)const loaded=await snapshot()assert.deepEqual(withoutGuide(loaded),withoutGuide(grown.world))assert.ok(["homes","fishery","market"].every(id=>loaded.resources["Town/Guide"].done.includes(id)),"The guide puts away what the town has done")@@ -151,7 +151,7 @@ try {await page.getByRole("button",{name:"4×",exact:true}).click()const before=await snapshot()const positions=await page.evaluate(()=>[...window.town.view.nodes].filter(n=>n.constructor.name==="WalkerView").map(n=>n.group.position.toArray()))- await page.waitForFunction(t=>window.town.runtime.snapshot().resources["Town/Time"].step>t+30,before.resources["Town/Time"].step)+ await page.waitForFunction(t=>window.town.snapshot().resources["Town/Time"].step>t+30,before.resources["Town/Time"].step)await page.locator(".toolbar .pause").click()const paused=await snapshot(),pf=await page.evaluate(()=>window.town.view.stats().frames)await page.waitForFunction(f=>window.town.view.stats().frames>f+10,pf)@@ -214,7 +214,7 @@ try {visitor.on("pageerror",e=>errors.push(`visitor: ${e.message}`))await visitor.goto(url)await visitor.waitForFunction(()=>document.body.classList.contains("visiting"),undefined,{timeout:60000})- const visited=await visitor.evaluate(()=>window.town.runtime.snapshot())+ const visited=await visitor.evaluate(()=>window.town.snapshot())assert.deepEqual(visited.entities,sharedWorld.entities,"The visitor sees the town as it was shared")assert.deepEqual(visited.resources,sharedWorld.resources)assert.ok(await visitor.locator(".toolbar").isHidden(),"A visitor's building tools are put away")diff --git a/scripts/look-readme.ts b/scripts/look-readme.tsindex 21671bc..d79a3c5 100644--- a/scripts/look-readme.ts+++ b/scripts/look-readme.ts@@ -56,7 +56,7 @@ const camera = (c: Camera) => page.evaluate((c) => {v.camera.zoom = c.zoom; v.camera.updateProjectionMatrix()v.focus(c.x, c.y)}, c)-const town = () => page.evaluate(() => (window as any).town.runtime.snapshot()) as Promise<any>+const town = () => page.evaluate(() => (window as any).town.snapshot()) as Promise<any>const hall = (await town()).entities.find((e: any) => e.components["Town/TownHall"]).components["Town/Tile"]console.log(JSON.stringify({ hall }))@@ -143,7 +143,7 @@ if (mode === "stills") {if (process.env.RECKON) {await page.evaluate(() => {const { runtime } = (window as any).town- const s = runtime.snapshot()+ const s = (window as any).town.snapshot()return s.resources["Town/Time"]}).then((t) => console.log(JSON.stringify({ time: t })))for (let i = 0; i < 40 && !(await page.locator(".dialog.open").count()); i++) {diff --git a/scripts/look-ui.ts b/scripts/look-ui.tsindex d2c0912..7f7fae8 100644--- a/scripts/look-ui.ts+++ b/scripts/look-ui.ts@@ -23,7 +23,7 @@ const save = await readFile(process.env.SAVE, "utf8")const errors: Array<string> = []type Tile = { x: number; y: number; size: number }-const town = (page: Page) => page.evaluate(() => (window as any).town.runtime.snapshot()) as Promise<any>+const town = (page: Page) => page.evaluate(() => (window as any).town.snapshot()) as Promise<any>const find = async (page: Page, test: (e: any) => boolean) => (await town(page)).entities.find(test) as anyfor (const [name, width, height, phone] of [["desktop", 1440, 1000, false], ["phone", 390, 844, true]] as const) {@@ -71,7 +71,7 @@ for (const [name, width, height, phone] of [["desktop", 1440, 1000, false], ["phconst f: Tile = fishery.components["Town/Tile"]await page.evaluate((f) => {const { runtime } = (window as any).town- const s = runtime.snapshot(), tick = s.resources["Town/Time"].step+ const s = (window as any).town.snapshot(), tick = s.resources["Town/Time"].stepfor (const e of s.entities) {const t = e.components["Town/Tile"], w = e.components["Town/Water"]if (w && Math.abs(t.x - f.x) <= 3 && Math.abs(t.y - f.y) <= 3) e.components["Town/Water"] = { fished: tick }@@ -100,7 +100,7 @@ for (const [name, width, height, phone] of [["desktop", 1440, 1000, false], ["ph// 3. The upgrades the town can begin now, as gold arrows over the buildings; then the town hall's panel.await page.evaluate(() => {const { runtime } = (window as any).town- const s = runtime.snapshot()+ const s = (window as any).town.snapshot()s.resources["Town/Fate"].rank = Math.max(s.resources["Town/Fate"].rank, 2)s.resources["Town/Treasury"].coins = 5000const restored = runtime.restore(s)@@ -120,7 +120,7 @@ for (const [name, width, height, phone] of [["desktop", 1440, 1000, false], ["phif (!phone) {await page.evaluate(() => {const { runtime } = (window as any).town- const s = runtime.snapshot()+ const s = (window as any).town.snapshot()s.resources["Town/Treasury"].coins = 20000for (const e of s.entities) {const inv = e.components["Town/Inventory"]diff --git a/scripts/look-upgrades.ts b/scripts/look-upgrades.tsindex 337fcc3..01f8e95 100644--- a/scripts/look-upgrades.ts+++ b/scripts/look-upgrades.ts@@ -28,7 +28,7 @@ try {// A town that has reached the town rank, with coins and materials to spare.await page.evaluate(() => {const { runtime } = (window as any).town- const s = runtime.snapshot()+ const s = (window as any).town.snapshot()s.resources["Town/Fate"].rank = 2s.resources["Town/Treasury"].coins = 5000const hall = s.entities.find((e: any) => e.components["Town/TownHall"])@@ -37,7 +37,7 @@ try {if (!restored.ok) throw new Error(`The changed town did not load: ${JSON.stringify(restored.error)}`)})await page.evaluate(() => (window as any).town.advance(1))- const hall = await page.evaluate(() => (window as any).town.runtime.snapshot().entities.find((e: any) => e.components["Town/TownHall"]).components["Town/Tile"])+ const hall = await page.evaluate(() => (window as any).town.snapshot().entities.find((e: any) => e.components["Town/TownHall"]).components["Town/Tile"])await page.evaluate(([x, y]) => { const v = (window as any).town.view; v.focus(x, y); v.camera.zoom = 2.2; v.camera.updateProjectionMatrix() }, [hall.x + 1.5, hall.y + 1.5])// The gold arrow over the town hall; then its panel, the upgrade first under its status, begun from its button.await page.waitForTimeout(600)@@ -56,10 +56,10 @@ try {await page.evaluate(() => (window as any).town.advance(90))await page.waitForTimeout(300)await page.screenshot({ path: `${out}/4-guildhall.png` })- assert.equal(await page.evaluate(() => (window as any).town.runtime.snapshot().entities.find((e: any) => e.components["Town/TownHall"]).components["Town/Upgraded"]?.level), 1)+ assert.equal(await page.evaluate(() => (window as any).town.snapshot().entities.find((e: any) => e.components["Town/TownHall"]).components["Town/Upgraded"]?.level), 1)// Complete the next civic milestone through the actual upgrade command too.await page.evaluate(() => {- const t=(window as any).town,s=t.runtime.snapshot()+ const t=(window as any).town,s=t.snapshot()const hall=s.entities.find((e:any)=>e.components["Town/TownHall"])Object.assign(hall.components["Town/Inventory"].stock,{planks:120,stone:120,tools:40,cloth:40})s.resources["Town/Treasury"].coins=5000@@ -72,7 +72,7 @@ try {await page.screenshot({path:`${out}/5-cityhall-works.png`})await page.evaluate(()=>(window as any).town.advance(240))await page.waitForTimeout(300)- assert.equal(await page.evaluate(()=>(window as any).town.runtime.snapshot().entities.find((e:any)=>e.components["Town/TownHall"]).components["Town/Upgraded"]?.level),2)+ assert.equal(await page.evaluate(()=>(window as any).town.snapshot().entities.find((e:any)=>e.components["Town/TownHall"]).components["Town/Upgraded"]?.level),2)await page.screenshot({path:`${out}/5-cityhall.png`})// The new workshop's actual model portrait and upgrade choices must fit a phone.await page.setViewportSize({ width: 390, height: 844 })@@ -85,7 +85,7 @@ try {assert.equal(await page.locator(".panel h3").filter({ hasText: /^upgrades$/i }).count(), 0, "upgrades are begun from a building's panel, not the build menu")assert.ok(await page.evaluate(() => document.documentElement.scrollWidth <= innerWidth), "The build menu fits the phone")assert.deepEqual(errors, [])- console.log(JSON.stringify({ errors, upgraded: await page.evaluate(() => (window as any).town.runtime.snapshot().entities.find((e: any) => e.components["Town/TownHall"]).components["Town/Upgraded"] ?? null) }))+ console.log(JSON.stringify({ errors, upgraded: await page.evaluate(() => (window as any).town.snapshot().entities.find((e: any) => e.components["Town/TownHall"]).components["Town/Upgraded"] ?? null) }))} finally {await browser.close()}diff --git a/src/app/browser.ts b/src/app/browser.tsindex 62676d9..c8174e9 100644--- a/src/app/browser.ts+++ b/src/app/browser.ts@@ -114,7 +114,7 @@ const start = async () => {Game.Runtime.service(RuinNodes, ruinNodes)),resources: blankResources(),- // Dev builds carry the debug handle, for the monitor and the replay recorder.+ // Dev builds carry the debug handle, for the replay recorder.debug: import.meta.env.DEV ? { hostClock } : undefined})if (!made.ok) {@@ -124,7 +124,7 @@ const start = async () => {}const runtime = made.value// In development, the page's console can reach the town: `town.edits.push(...)`, `town.interaction`, `town.shown`,- // `town.runtime.snapshot()`, and `town.advance(seconds)` to fast-forward the simulation.+ // `town.snapshot()` (the world as plain data), and `town.advance(seconds)` to fast-forward the simulation.if (import.meta.env.DEV) {const advance = (seconds: number) => {for (let i = 0; i < Math.round(seconds / step.dt); i++) {@@ -132,11 +132,16 @@ const start = async () => {if (!stepped.ok) throw new Error(`A step failed: ${JSON.stringify(stepped.error)}`)}}- Object.assign(window, { town: { interaction, shown, edits, runtime, advance, view: stage } })+ const snapshot = () => {+ const saved = runtime.snapshot()+ if (!saved.ok) throw new Error(`The town could not be saved: ${JSON.stringify(saved.error)}`)+ return saved.value+ }+ Object.assign(window, { town: { interaction, shown, edits, runtime, snapshot, advance, view: stage } })if (runtime.debug !== undefined) {// Loaded in dev only: the production bundle never includes devtools.const { attachDevtools } = await import("./devtools.ts")- attachDevtools({ runtime: { ...runtime, debug: runtime.debug }, mount: document.body, fetch: (url, init) => fetch(url, init), wallClock: HostClock.standard, host: window, demo: new URLSearchParams(location.search).has("replay-demo") })+ attachDevtools({ runtime: { ...runtime, debug: runtime.debug }, fetch: (url, init) => fetch(url, init), wallClock: HostClock.standard, host: window, demo: new URLSearchParams(location.search).has("replay-demo") })}}diff --git a/src/game/headless.ts b/src/game/headless.tsindex 131f041..1ceeb1d 100644--- a/src/game/headless.ts+++ b/src/game/headless.ts@@ -16,11 +16,12 @@ import { blankResources, simulate } from "./schedule.ts"/** A saved world, as plain data. */export interface Snapshot {version: number+ gameVersion: numbernextEntity: numberentities: Array<{ id: number; components: Record<string, any> }>relations: Record<string, Array<[number, Array<number>]>>resources: Record<string, any>- machines: Record<string, string>+ machines: Record<string, unknown>}/** The edit queue of a town about to be founded: one edit founds it on the first step. */@@ -75,7 +76,11 @@ export const headless = (charter: CharterValue, options: { readonly toast?: (mesedits.push(...queued)},/** The world as plain data (a copy: changing it changes nothing until it is restored). */- snapshot: (): Snapshot => JSON.parse(JSON.stringify(runtime.snapshot())),+ snapshot: (): Snapshot => {+ const saved = runtime.snapshot()+ if (!saved.ok) throw new Error(`The town could not be saved: ${JSON.stringify(saved.error)}`)+ return JSON.parse(JSON.stringify(saved.value))+ },/** Loads a world, validating everything in it. */restore: (snapshot: unknown) => {const restored = runtime.restore(snapshot)diff --git a/src/platform/save.ts b/src/platform/save.tsindex 1be80fa..b388454 100644--- a/src/platform/save.ts+++ b/src/platform/save.ts@@ -18,14 +18,15 @@ export const SAVE_FORMAT = "inkline-town/save"* winters). 4: parks and patrols. 5: the grudge over taxes, and where each piece of news happened.* 6: how much of each good may be traded at a collection. 7: the mayor's guide. 8: terms that follow one* another, the town's rank, and upgraded buildings.- * 10: fixed-step Clock values and runtime snapshot format 2.- * Version 4 to 9 saves are carried forward (see `carry`); older ones cannot be loaded.+ * 10: fixed-step Clock values and runtime snapshot format 2. 11: runtime snapshot format 3 (Ritmo 0.13).+ * Version 4 to 10 saves are carried forward (see `carry`); older ones cannot be loaded.*/-export const SAVE_VERSION = 10+export const SAVE_VERSION = 11/*** Fills in what a save from an earlier version lacks, so a town in progress- * survives an update: from 4, the mood's grudge (none yet) and the news's+ * survives an update: from 10, the runtime's snapshot format 3, which+ * changed only how state machines are saved, and the town has none; from 4, the mood's grudge (none yet) and the news's* places (unknown); from 5, trade at full loads, as it was; from 6, the* guide from its start (it puts away at once what the town has already* done); from 7, its first term, and its rank: a town that was complete@@ -36,18 +37,20 @@ export const SAVE_VERSION = 10* Anything else is left to the world's own validation.*/const carry = (version: number, world: unknown): unknown | null => {- if (version < 4 || version > 9 || typeof world !== "object" || world === null) return null+ if (version < 4 || version > 10 || typeof world !== "object" || world === null) return nullconst w = world as { version?: number; scopes?: Record<string, unknown>; resources?: Record<string, unknown>; entities?: Array<{ components?: Record<string, unknown> }> }const r = w.resourcesif (!r || typeof r !== "object") return null// Town never used entity scopes before this format. Its old clock counted// the same 60 Hz steps under `tick`; preserve that count exactly.if (w.version === 1) { w.version = 2; w.scopes = {} }+ // Format 3 saves a state machine with its fields; the town has no machines, so a format 2 world is the same.+ if (w.version === 2) w.version = 3const time = r["Town/Time"]if (typeof time === "object" && time !== null && "tick" in time && typeof time.tick === "number") {r["Town/Time"] = { step: time.tick, hz: 60, dt: time.tick > 0 ? 1 / 60 : 0 }}- if (version === 9) return w+ if (version === 9 || version === 10) return w// From 8, water that was never fished, and an upgraded building upgraded once.for (const e of Array.isArray(w.entities) ? w.entities : []) {const water = e.components?.["Town/Water"]@@ -135,11 +138,13 @@ export class Unreadable extends Schema.TaggedError<Unreadable>()("Unreadable", {export class WrongVersion extends Schema.TaggedError<WrongVersion>()("WrongVersion", { slot: Schema.String, version: Schema.Number }) {}export class Rejected extends Schema.TaggedError<Rejected>()("Rejected", { slot: Schema.String, reason: Schema.String }) {}export class StorageFailed extends Schema.TaggedError<StorageFailed>()("StorageFailed", { slot: Schema.String, reason: Schema.String }) {}+/** The world refused to be saved: a value its schema could not encode. */+export class Unsaveable extends Schema.TaggedError<Unsaveable>()("Unsaveable", { slot: Schema.String, reason: Schema.String }) {}export type LoadError = NothingSaved | Unreadable | WrongVersion | Rejected | StorageFailed/** What to tell the mayor. */-export const describe = (error: LoadError | StorageFailed): string => {+export const describe = (error: LoadError | StorageFailed | Unsaveable): string => {switch (error._tag) {case "NothingSaved":return error.slot === "auto" ? "No autosave yet" : "Nothing saved yet"@@ -151,6 +156,8 @@ export const describe = (error: LoadError | StorageFailed): string => {return `The save does not fit this game: ${error.reason}`case "StorageFailed":return `Could not save: ${error.reason}`+ case "Unsaveable":+ return `Could not save the town: ${error.reason}`}}@@ -164,7 +171,8 @@ export class Storage extends Context.Service<Storage, {/** The town being saved and loaded. */export class World extends Context.Service<World, {- readonly snapshot: () => unknown+ /** The world as plain data, or why it could not be saved (Ritmo's `runtime.snapshot()` result). */+ readonly snapshot: () => { readonly ok: true; readonly value: unknown } | { readonly ok: false; readonly error: unknown }/** Restores a world, or says why it will not. */readonly restore: (world: unknown) => string | null/** The town in a line, for a save's title. */@@ -192,13 +200,15 @@ export const memoryStorage = (files = new Map<string, string>()): Storage["Serviexport const fileOf = (slot: Slot) =>Effect.gen(function* () {const world = yield* World+ const snapshot = world.snapshot()+ if (!snapshot.ok) return yield* new Unsaveable({ slot, reason: JSON.stringify(snapshot.error) })const file: SaveFile = {format: SAVE_FORMAT,version: SAVE_VERSION,slot,savedAt: yield* Clock.currentTimeMillis,title: world.title(),- world: world.snapshot()+ world: snapshot.value}return file})diff --git a/test/clock-migration.test.ts b/test/clock-migration.test.tsindex 977b829..e25810b 100644--- a/test/clock-migration.test.ts+++ b/test/clock-migration.test.ts@@ -7,7 +7,7 @@ import { load, memoryStorage, SAVE_FORMAT, SAVE_VERSION, Storage, World } from "import { headless } from "../src/game/headless.ts"import { simulate } from "../src/game/schedule.ts"-test("version 9 saves retain the exact 60 Hz step count and load as snapshot format 2", () => {+test("version 9 saves retain the exact 60 Hz step count and load as the current snapshot format", () => {const town = headless({ size: "small", term: 45, land: "fair", seed: 7 })town.run(1)const current = town.snapshot()@@ -17,14 +17,14 @@ test("version 9 saves retain the exact 60 Hz step count and load as snapshot fortown.run(1)const result = Effect.runSync(Effect.result(load("manual").pipe(Effect.provideService(Storage, storage),- Effect.provideService(World, { snapshot: () => town.snapshot(), title: () => "town", restore: (value) => {+ Effect.provideService(World, { snapshot: () => ({ ok: true, value: town.snapshot() }), title: () => "town", restore: (value) => {try { town.restore(value); return null } catch (error) { return String(error) }} }))))assert.equal(result._tag, "Success")if (result._tag === "Success") assert.equal(result.success.version, SAVE_VERSION)assert.deepEqual(town.snapshot().resources["Town/Time"], { step: count, hz: 60, dt: 1 / 60 })- assert.equal(town.snapshot().version, 2)+ assert.equal(town.snapshot().version, 3)})test("the full town simulation repeats from fresh scripted input", () => {diff --git a/test/fixtures/save-v10-ritmo-0.9.json b/test/fixtures/save-v10-ritmo-0.9.jsonnew file mode 100644index 0000000..5785915--- /dev/null+++ b/test/fixtures/save-v10-ritmo-0.9.json@@ -0,0 +1 @@+{"format":"inkline-town/save","version":10,"slot":"manual","savedAt":0,"title":"a town saved by Ritmo 0.9.0","world":{"version":2,"gameVersion":0,"nextEntity":174,"entities":[{"id":1,"components":{"Town/Tile":{"x":39,"y":38,"size":1},"Town/Water":{"fished":-1000000}}},{"id":2,"components":{"Town/Tile":{"x":40,"y":38,"size":1},"Town/Water":{"fished":-1000000}}},{"id":3,"components":{"Town/Tile":{"x":41,"y":38,"size":1},"Town/Water":{"fished":-1000000}}},{"id":4,"components":{"Town/Tile":{"x":42,"y":38,"size":1},"Town/Water":{"fished":-1000000}}},{"id":5,"components":{"Town/Tile":{"x":38,"y":39,"size":1},"Town/Water":{"fished":-1000000}}},{"id":6,"components":{"Town/Tile":{"x":39,"y":39,"size":1},"Town/Water":{"fished":-1000000}}},{"id":7,"components":{"Town/Tile":{"x":40,"y":39,"size":1},"Town/Water":{"fished":-1000000}}},{"id":8,"components":{"Town/Tile":{"x":41,"y":39,"size":1},"Town/Water":{"fished":-1000000}}},{"id":9,"components":{"Town/Tile":{"x":42,"y":39,"size":1},"Town/Water":{"fished":-1000000}}},{"id":10,"components":{"Town/Tile":{"x":39,"y":40,"size":1},"Town/Water":{"fished":-1000000}}},{"id":11,"components":{"Town/Tile":{"x":40,"y":40,"size":1},"Town/Water":{"fished":-1000000}}},{"id":12,"components":{"Town/Tile":{"x":41,"y":40,"size":1},"Town/Water":{"fished":-1000000}}},{"id":13,"components":{"Town/Tile":{"x":42,"y":40,"size":1},"Town/Water":{"fished":-1000000}}},{"id":14,"components":{"Town/Tile":{"x":41,"y":41,"size":1},"Town/Water":{"fished":-1000000}}},{"id":15,"components":{"Town/Tile":{"x":33,"y":48,"size":1},"Town/Water":{"fished":-1000000}}},{"id":16,"components":{"Town/Tile":{"x":34,"y":48,"size":1},"Town/Water":{"fished":-1000000}}},{"id":17,"components":{"Town/Tile":{"x":35,"y":48,"size":1},"Town/Water":{"fished":-1000000}}},{"id":18,"components":{"Town/Tile":{"x":33,"y":49,"size":1},"Town/Water":{"fished":-1000000}}},{"id":19,"components":{"Town/Tile":{"x":34,"y":49,"size":1},"Town/Water":{"fished":-1000000}}},{"id":20,"components":{"Town/Tile":{"x":35,"y":49,"size":1},"Town/Water":{"fished":-1000000}}},{"id":21,"components":{"Town/Tile":{"x":33,"y":50,"size":1},"Town/Water":{"fished":-1000000}}},{"id":22,"components":{"Town/Tile":{"x":34,"y":50,"size":1},"Town/Water":{"fished":-1000000}}},{"id":23,"components":{"Town/Tile":{"x":35,"y":50,"size":1},"Town/Water":{"fished":-1000000}}},{"id":24,"components":{"Town/Tile":{"x":36,"y":50,"size":1},"Town/Water":{"fished":-1000000}}},{"id":25,"components":{"Town/Tile":{"x":33,"y":51,"size":1},"Town/Water":{"fished":-1000000}}},{"id":26,"components":{"Town/Tile":{"x":34,"y":51,"size":1},"Town/Water":{"fished":-1000000}}},{"id":27,"components":{"Town/Tile":{"x":35,"y":51,"size":1},"Town/Water":{"fished":-1000000}}},{"id":28,"components":{"Town/Tile":{"x":47,"y":32,"size":1},"Town/Tree":{"growth":2400}}},{"id":29,"components":{"Town/Tile":{"x":48,"y":34,"size":1},"Town/Tree":{"growth":2400}}},{"id":30,"components":{"Town/Tile":{"x":49,"y":33,"size":1},"Town/Tree":{"growth":2400}}},{"id":31,"components":{"Town/Tile":{"x":46,"y":35,"size":1},"Town/Tree":{"growth":2400}}},{"id":32,"components":{"Town/Tile":{"x":47,"y":31,"size":1},"Town/Tree":{"growth":2400}}},{"id":33,"components":{"Town/Tile":{"x":45,"y":33,"size":1},"Town/Tree":{"growth":2400}}},{"id":34,"components":{"Town/Tile":{"x":47,"y":34,"size":1},"Town/Tree":{"growth":2400}}},{"id":35,"components":{"Town/Tile":{"x":48,"y":33,"size":1},"Town/Tree":{"growth":2400}}},{"id":36,"components":{"Town/Tile":{"x":49,"y":34,"size":1},"Town/Tree":{"growth":2400}}},{"id":37,"components":{"Town/Tile":{"x":46,"y":33,"size":1},"Town/Tree":{"growth":2400}}},{"id":38,"components":{"Town/Tile":{"x":21,"y":26,"size":1},"Town/Tree":{"growth":2400}}},{"id":39,"components":{"Town/Tile":{"x":22,"y":23,"size":1},"Town/Tree":{"growth":2400}}},{"id":40,"components":{"Town/Tile":{"x":18,"y":27,"size":1},"Town/Tree":{"growth":2400}}},{"id":41,"components":{"Town/Tile":{"x":20,"y":24,"size":1},"Town/Tree":{"growth":2400}}},{"id":42,"components":{"Town/Tile":{"x":23,"y":27,"size":1},"Town/Tree":{"growth":2400}}},{"id":43,"components":{"Town/Tile":{"x":22,"y":25,"size":1},"Town/Tree":{"growth":2400}}},{"id":44,"components":{"Town/Tile":{"x":21,"y":24,"size":1},"Town/Tree":{"growth":2400}}},{"id":45,"components":{"Town/Tile":{"x":21,"y":27,"size":1},"Town/Tree":{"growth":2400}}},{"id":46,"components":{"Town/Tile":{"x":20,"y":27,"size":1},"Town/Tree":{"growth":2400}}},{"id":47,"components":{"Town/Tile":{"x":20,"y":25,"size":1},"Town/Tree":{"growth":2400}}},{"id":48,"components":{"Town/Tile":{"x":19,"y":27,"size":1},"Town/Tree":{"growth":2400}}},{"id":49,"components":{"Town/Tile":{"x":22,"y":24,"size":1},"Town/Tree":{"growth":2400}}},{"id":50,"components":{"Town/Tile":{"x":22,"y":26,"size":1},"Town/Tree":{"growth":2400}}},{"id":51,"components":{"Town/Tile":{"x":22,"y":27,"size":1},"Town/Tree":{"growth":2400}}},{"id":52,"components":{"Town/Tile":{"x":24,"y":26,"size":1},"Town/Tree":{"growth":2400}}},{"id":53,"components":{"Town/Tile":{"x":21,"y":23,"size":1},"Town/Tree":{"growth":2400}}},{"id":54,"components":{"Town/Tile":{"x":19,"y":28,"size":1},"Town/Tree":{"growth":2400}}},{"id":55,"components":{"Town/Tile":{"x":23,"y":24,"size":1},"Town/Tree":{"growth":2400}}},{"id":56,"components":{"Town/Tile":{"x":19,"y":25,"size":1},"Town/Tree":{"growth":2400}}},{"id":57,"components":{"Town/Tile":{"x":22,"y":29,"size":1},"Town/Tree":{"growth":2400}}},{"id":58,"components":{"Town/Tile":{"x":21,"y":30,"size":1},"Town/Tree":{"growth":2400}}},{"id":59,"components":{"Town/Tile":{"x":19,"y":29,"size":1},"Town/Tree":{"growth":2400}}},{"id":60,"components":{"Town/Tile":{"x":19,"y":26,"size":1},"Town/Tree":{"growth":2400}}},{"id":61,"components":{"Town/Tile":{"x":23,"y":26,"size":1},"Town/Tree":{"growth":2400}}},{"id":62,"components":{"Town/Tile":{"x":21,"y":29,"size":1},"Town/Tree":{"growth":2400}}},{"id":63,"components":{"Town/Tile":{"x":18,"y":28,"size":1},"Town/Tree":{"growth":2400}}},{"id":64,"components":{"Town/Tile":{"x":29,"y":16,"size":1},"Town/Tree":{"growth":2400}}},{"id":65,"components":{"Town/Tile":{"x":32,"y":14,"size":1},"Town/Tree":{"growth":2400}}},{"id":66,"components":{"Town/Tile":{"x":35,"y":19,"size":1},"Town/Tree":{"growth":2400}}},{"id":67,"components":{"Town/Tile":{"x":31,"y":18,"size":1},"Town/Tree":{"growth":2400}}},{"id":68,"components":{"Town/Tile":{"x":32,"y":20,"size":1},"Town/Tree":{"growth":2400}}},{"id":69,"components":{"Town/Tile":{"x":29,"y":17,"size":1},"Town/Tree":{"growth":2400}}},{"id":70,"components":{"Town/Tile":{"x":33,"y":19,"size":1},"Town/Tree":{"growth":2400}}},{"id":71,"components":{"Town/Tile":{"x":31,"y":20,"size":1},"Town/Tree":{"growth":2400}}},{"id":72,"components":{"Town/Tile":{"x":31,"y":15,"size":1},"Town/Tree":{"growth":2400}}},{"id":73,"components":{"Town/Tile":{"x":35,"y":17,"size":1},"Town/Tree":{"growth":2400}}},{"id":74,"components":{"Town/Tile":{"x":34,"y":14,"size":1},"Town/Tree":{"growth":2400}}},{"id":75,"components":{"Town/Tile":{"x":30,"y":19,"size":1},"Town/Tree":{"growth":2400}}},{"id":76,"components":{"Town/Tile":{"x":31,"y":16,"size":1},"Town/Tree":{"growth":2400}}},{"id":77,"components":{"Town/Tile":{"x":35,"y":16,"size":1},"Town/Tree":{"growth":2400}}},{"id":78,"components":{"Town/Tile":{"x":35,"y":18,"size":1},"Town/Tree":{"growth":2400}}},{"id":79,"components":{"Town/Tile":{"x":31,"y":14,"size":1},"Town/Tree":{"growth":2400}}},{"id":80,"components":{"Town/Tile":{"x":33,"y":13,"size":1},"Town/Tree":{"growth":2400}}},{"id":81,"components":{"Town/Tile":{"x":30,"y":17,"size":1},"Town/Tree":{"growth":2400}}},{"id":82,"components":{"Town/Tile":{"x":32,"y":16,"size":1},"Town/Tree":{"growth":2400}}},{"id":83,"components":{"Town/Tile":{"x":33,"y":17,"size":1},"Town/Tree":{"growth":2400}}},{"id":84,"components":{"Town/Tile":{"x":34,"y":45,"size":1},"Town/Tree":{"growth":2400}}},{"id":85,"components":{"Town/Tile":{"x":33,"y":45,"size":1},"Town/Tree":{"growth":2400}}},{"id":86,"components":{"Town/Tile":{"x":29,"y":48,"size":1},"Town/Tree":{"growth":2400}}},{"id":87,"components":{"Town/Tile":{"x":32,"y":48,"size":1},"Town/Tree":{"growth":2400}}},{"id":88,"components":{"Town/Tile":{"x":34,"y":43,"size":1},"Town/Tree":{"growth":2400}}},{"id":89,"components":{"Town/Tile":{"x":31,"y":46,"size":1},"Town/Tree":{"growth":2400}}},{"id":90,"components":{"Town/Tile":{"x":30,"y":43,"size":1},"Town/Tree":{"growth":2400}}},{"id":91,"components":{"Town/Tile":{"x":33,"y":47,"size":1},"Town/Tree":{"growth":2400}}},{"id":92,"components":{"Town/Tile":{"x":32,"y":42,"size":1},"Town/Tree":{"growth":2400}}},{"id":93,"components":{"Town/Tile":{"x":35,"y":44,"size":1},"Town/Tree":{"growth":2400}}},{"id":94,"components":{"Town/Tile":{"x":30,"y":48,"size":1},"Town/Tree":{"growth":2400}}},{"id":95,"components":{"Town/Tile":{"x":32,"y":49,"size":1},"Town/Tree":{"growth":2400}}},{"id":96,"components":{"Town/Tile":{"x":32,"y":45,"size":1},"Town/Tree":{"growth":2400}}},{"id":97,"components":{"Town/Tile":{"x":29,"y":44,"size":1},"Town/Tree":{"growth":2400}}},{"id":98,"components":{"Town/Tile":{"x":31,"y":48,"size":1},"Town/Tree":{"growth":2400}}},{"id":99,"components":{"Town/Tile":{"x":28,"y":46,"size":1},"Town/Tree":{"growth":2400}}},{"id":100,"components":{"Town/Tile":{"x":34,"y":44,"size":1},"Town/Tree":{"growth":2400}}},{"id":101,"components":{"Town/Tile":{"x":35,"y":47,"size":1},"Town/Tree":{"growth":2400}}},{"id":102,"components":{"Town/Tile":{"x":29,"y":47,"size":1},"Town/Tree":{"growth":2400}}},{"id":103,"components":{"Town/Tile":{"x":30,"y":45,"size":1},"Town/Tree":{"growth":2400}}},{"id":104,"components":{"Town/Tile":{"x":30,"y":46,"size":1},"Town/Tree":{"growth":2400}}},{"id":105,"components":{"Town/Tile":{"x":33,"y":46,"size":1},"Town/Tree":{"growth":2400}}},{"id":106,"components":{"Town/Tile":{"x":32,"y":44,"size":1},"Town/Tree":{"growth":2400}}},{"id":107,"components":{"Town/Tile":{"x":31,"y":43,"size":1},"Town/Tree":{"growth":2400}}},{"id":108,"components":{"Town/Tile":{"x":31,"y":44,"size":1},"Town/Tree":{"growth":2400}}},{"id":109,"components":{"Town/Tile":{"x":33,"y":44,"size":1},"Town/Tree":{"growth":2400}}},{"id":110,"components":{"Town/Tile":{"x":31,"y":47,"size":1},"Town/Tree":{"growth":2400}}},{"id":111,"components":{"Town/Tile":{"x":28,"y":40,"size":1},"Town/Tree":{"growth":2400}}},{"id":112,"components":{"Town/Tile":{"x":32,"y":15,"size":1},"Town/Rock":{"ore":false,"amount":32}}},{"id":113,"components":{"Town/Tile":{"x":34,"y":16,"size":1},"Town/Rock":{"ore":false,"amount":32}}},{"id":114,"components":{"Town/Tile":{"x":33,"y":15,"size":1},"Town/Rock":{"ore":false,"amount":32}}},{"id":115,"components":{"Town/Tile":{"x":34,"y":15,"size":1},"Town/Rock":{"ore":false,"amount":32}}},{"id":116,"components":{"Town/Tile":{"x":37,"y":23,"size":1},"Town/Rock":{"ore":false,"amount":32}}},{"id":117,"components":{"Town/Tile":{"x":36,"y":22,"size":1},"Town/Rock":{"ore":false,"amount":32}}},{"id":118,"components":{"Town/Tile":{"x":35,"y":23,"size":1},"Town/Rock":{"ore":false,"amount":32}}},{"id":119,"components":{"Town/Tile":{"x":35,"y":24,"size":1},"Town/Rock":{"ore":false,"amount":32}}},{"id":120,"components":{"Town/Tile":{"x":42,"y":28,"size":1},"Town/Rock":{"ore":true,"amount":32}}},{"id":121,"components":{"Town/Tile":{"x":42,"y":29,"size":1},"Town/Rock":{"ore":true,"amount":32}}},{"id":122,"components":{"Town/Tile":{"x":41,"y":29,"size":1},"Town/Rock":{"ore":true,"amount":32}}},{"id":123,"components":{"Town/Tile":{"x":41,"y":30,"size":1},"Town/Rock":{"ore":true,"amount":32}}},{"id":124,"components":{"Town/Tile":{"x":40,"y":30,"size":1},"Town/Rock":{"ore":true,"amount":32}}},{"id":125,"components":{"Town/Tile":{"x":20,"y":37,"size":1},"Town/Rock":{"ore":true,"amount":32}}},{"id":126,"components":{"Town/Tile":{"x":22,"y":35,"size":1},"Town/Rock":{"ore":true,"amount":32}}},{"id":127,"components":{"Town/Tile":{"x":21,"y":35,"size":1},"Town/Rock":{"ore":true,"amount":32}}},{"id":128,"components":{"Town/Tile":{"x":29,"y":29,"size":1},"Town/Road":{}}},{"id":129,"components":{"Town/Tile":{"x":29,"y":30,"size":1},"Town/Road":{}}},{"id":130,"components":{"Town/Tile":{"x":29,"y":31,"size":1},"Town/Road":{}}},{"id":131,"components":{"Town/Tile":{"x":29,"y":32,"size":1},"Town/Road":{}}},{"id":132,"components":{"Town/Tile":{"x":29,"y":33,"size":1},"Town/Road":{}}},{"id":133,"components":{"Town/Tile":{"x":30,"y":29,"size":1},"Town/Road":{}}},{"id":134,"components":{"Town/Tile":{"x":30,"y":33,"size":1},"Town/Road":{}}},{"id":135,"components":{"Town/Tile":{"x":31,"y":29,"size":1},"Town/Road":{}}},{"id":136,"components":{"Town/Tile":{"x":31,"y":33,"size":1},"Town/Road":{}}},{"id":137,"components":{"Town/Tile":{"x":32,"y":29,"size":1},"Town/Road":{}}},{"id":138,"components":{"Town/Tile":{"x":32,"y":33,"size":1},"Town/Road":{}}},{"id":139,"components":{"Town/Tile":{"x":33,"y":29,"size":1},"Town/Road":{}}},{"id":140,"components":{"Town/Tile":{"x":33,"y":30,"size":1},"Town/Road":{}}},{"id":141,"components":{"Town/Tile":{"x":33,"y":31,"size":1},"Town/Road":{}}},{"id":142,"components":{"Town/Tile":{"x":33,"y":32,"size":1},"Town/Road":{}}},{"id":143,"components":{"Town/Tile":{"x":33,"y":33,"size":1},"Town/Road":{}}},{"id":144,"components":{"Town/Tile":{"x":30,"y":30,"size":3},"Town/Building":{"kind":"townhall"},"Town/TownHall":{},"Town/Status":"idle","Town/Staff":{"needed":0,"assigned":0,"apprentices":0,"nearby":0},"Town/Inventory":{"stock":{"wood":10,"planks":40,"stone":16,"ore":0,"tools":10,"fish":13,"smoked":0,"wheat":0,"flour":0,"bread":0,"wool":0,"cloth":0,"furniture":0},"accepts":["wood","planks","stone","ore","tools","fish","smoked","wheat","flour","bread","wool","cloth","furniture"],"cap":100},"Town/Storage":{},"Town/Carriers":{"count":6},"Town/Service":{"service":"goods","interval":480,"cooldown":0,"range":20}}},{"id":145,"components":{"Town/Tile":{"x":30,"y":47,"size":1},"Town/Tree":{"growth":2400}}},{"id":146,"components":{"Town/Tile":{"x":34,"y":19,"size":1},"Town/Tree":{"growth":2400}}},{"id":147,"components":{"Town/Tile":{"x":21,"y":28,"size":1},"Town/Tree":{"growth":2400}}},{"id":148,"components":{"Town/Tile":{"x":33,"y":16,"size":1},"Town/Tree":{"growth":2400}}},{"id":149,"components":{"Town/Tile":{"x":28,"y":47,"size":1},"Town/Tree":{"growth":2400}}},{"id":150,"components":{"Town/Tile":{"x":31,"y":42,"size":1},"Town/Tree":{"growth":2400}}},{"id":151,"components":{"Town/Tile":{"x":31,"y":49,"size":1},"Town/Tree":{"growth":2400}}},{"id":152,"components":{"Town/Tile":{"x":20,"y":26,"size":1},"Town/Tree":{"growth":2400}}},{"id":153,"components":{"Town/Tile":{"x":47,"y":33,"size":1},"Town/Tree":{"growth":2400}}},{"id":154,"components":{"Town/Tile":{"x":32,"y":47,"size":1},"Town/Tree":{"growth":2400}}},{"id":155,"components":{"Town/Tile":{"x":20,"y":28,"size":1},"Town/Tree":{"growth":2400}}},{"id":156,"components":{"Town/Tile":{"x":34,"y":47,"size":1},"Town/Tree":{"growth":2400}}},{"id":157,"components":{"Town/Tile":{"x":32,"y":17,"size":1},"Town/Tree":{"growth":2400}}},{"id":158,"components":{"Town/Tile":{"x":30,"y":18,"size":1},"Town/Tree":{"growth":2400}}},{"id":159,"components":{"Town/Tile":{"x":35,"y":45,"size":1},"Town/Tree":{"growth":2400}}},{"id":160,"components":{"Town/Tile":{"x":32,"y":43,"size":1},"Town/Tree":{"growth":2400}}},{"id":161,"components":{"Town/Tile":{"x":22,"y":28,"size":1},"Town/Tree":{"growth":2400}}},{"id":162,"components":{"Town/Tile":{"x":23,"y":28,"size":1},"Town/Tree":{"growth":2400}}},{"id":163,"components":{"Town/Tile":{"x":28,"y":48,"size":1},"Town/Tree":{"growth":2340}}},{"id":164,"components":{"Town/Tile":{"x":48,"y":32,"size":1},"Town/Tree":{"growth":2250}}},{"id":165,"components":{"Town/Tile":{"x":33,"y":14,"size":1},"Town/Tree":{"growth":2160}}},{"id":166,"components":{"Town/Tile":{"x":30,"y":16,"size":1},"Town/Tree":{"growth":1800}}},{"id":167,"components":{"Town/Tile":{"x":31,"y":17,"size":1},"Town/Tree":{"growth":1710}}},{"id":168,"components":{"Town/Tile":{"x":21,"y":25,"size":1},"Town/Tree":{"growth":1530}}},{"id":169,"components":{"Town/Tile":{"x":32,"y":46,"size":1},"Town/Tree":{"growth":990}}},{"id":170,"components":{"Town/Tile":{"x":46,"y":34,"size":1},"Town/Tree":{"growth":900}}},{"id":171,"components":{"Town/Tile":{"x":31,"y":45,"size":1},"Town/Tree":{"growth":450}}},{"id":172,"components":{"Town/Tile":{"x":29,"y":18,"size":1},"Town/Tree":{"growth":270}}},{"id":173,"components":{"Town/Tile":{"x":33,"y":18,"size":1},"Town/Tree":{"growth":180}}}],"relations":{"Town/WalkerOf":[],"Town/FieldOf":[]},"resources":{"Town/Time":{"step":5401,"hz":60,"dt":0.016666666666666666},"Town/Rng":2640072479,"Town/Treasury":{"coins":1100},"Town/Ledger":{"taxes":0,"trade":0,"upkeep":0,"admin":0},"Town/Census":{"homes":0,"settlers":0,"citizens":0,"burghers":0,"jobs":0,"employed":0,"food":0,"bread":0,"cloth":0,"faith":0,"furniture":0,"sick":0,"burning":0},"Town/Policy":{"settlers":100,"citizens":100,"sells":[],"buys":[],"reserve":25,"loads":{"wood":12,"planks":12,"stone":12,"ore":12,"tools":12,"fish":12,"smoked":12,"wheat":12,"flour":12,"bread":12,"wool":12,"cloth":12,"furniture":12}},"Town/Charter":{"size":"small","term":45,"land":"fair","seed":5,"founded":1,"winters":["none","mild","normal","hard","mild","normal"]},"Town/Land":{"mask":"0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000110000000000000000000000000000000000000000000000000000000000000111000000000000000000000000000000000000000000000000000000000000111110000000000000000000000000000000000000000000000000000000000011111000000000000000000000000000000000000000000000000000000000001111110000000000000000000000000000000000000000000000000000000001111111000000000000000000000000000000000000000000000000000000000111111110000000000000000000000000000000000000000000000000011111111111111000000000000000000000000000000000000000000000000001111111111111111000000000000000000000000000000000000000000000000111111111111111100000000000000000000000000000000000000000000000111111111111111110000000000000000000000000000000000000000000000111111111111111111111000000000000000000000000000000000000000000011111111111111111111110000000000000000000000000000000000000000011111111111111111111111000000000000000000000000000000000000000011111111111111111111111111000000000000000000000000000000000000001111111111111111111111111100000000000000000000000000000000000001111111111111111111111111110000000000000000000000000000000000000111111111111111111111111111000000000000000000000000000000000000001111111111111111111111111100000000000000000000000000000000000000111111111111111111111111111100000000000000000000000000000000000011111111111111111111111111111000000000000000000000000000000000001111111111111111111111111111110000000000000000000000000000000000011111111111111111111111111111100000000000000000000000000000000001111111111111111111111111111110000000000000000000000000000000000111111111111111111111111111000000000000000000000000000000000000011111111111111111111111000000000000000000000000000000000000000001111111111111111111111100000000000000000000000000000000000000000111111111111111111111110000000000000000000000000000000000000000001111111111111111111111000000000000000000000000000000000000000000111111111111111111111100000000000000000000000000000000000000000011111111111111111111100000000000000000000000000000000000000000000111111111111111111110000000000000000000000000000000000000000000001111111111111111111000000000000000000000000000000000000000000000011111111111111111100000000000000000000000000000000000000000000001111111111111111110000000000000000000000000000000000000000000000111111111111111100000000000000000000000000000000000000000000000011111111111111110000000000000000000000000000000000000000000000001111111111111110000000000000000000000000000000000000000000000000111110011111110000000000000000000000000000000000000000000000000011111000011110000000000000000000000000000000000000000000000000000011000001111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","cells":754},"Town/Market":{"prices":{"wood":100,"planks":100,"stone":100,"ore":100,"tools":100,"fish":100,"smoked":100,"wheat":100,"flour":100,"bread":100,"wool":100,"cloth":100,"furniture":100}},"Town/Mood":{"approval":8,"target":8,"base":10,"needs":-2,"taxes":0,"debt":0,"crown":0,"winter":0,"grudge":0,"memory":0},"Town/Crown":{"open":false,"good":"wood","amount":0,"issued":0,"due":0,"reward":0,"next":16200,"met":0,"missed":0,"streak":0,"snubs":[]},"Town/Fate":{"state":"playing","reason":"","at":0,"term":1,"began":0,"rank":0,"debtSince":-1,"revoltSince":-1,"goalSince":-1,"peak":0,"score":0},"Town/History":{"samples":[{"tick":900,"coins":1100,"residents":0,"citizens":0,"approval":8,"net":0},{"tick":1800,"coins":1100,"residents":0,"citizens":0,"approval":8,"net":0},{"tick":2700,"coins":1100,"residents":0,"citizens":0,"approval":8,"net":0},{"tick":3600,"coins":1100,"residents":0,"citizens":0,"approval":8,"net":0},{"tick":4500,"coins":1100,"residents":0,"citizens":0,"approval":8,"net":0},{"tick":5400,"coins":1100,"residents":0,"citizens":0,"approval":8,"net":0}]},"Town/Chronicle":{"lines":[{"tick":0,"text":"Founded on small, fair land, for a term of 45 minutes.","alarm":false,"at":null}]},"Town/Guide":{"done":[],"off":false},"Town/Appeal":{"cells":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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{}}}\ No newline at end of filediff --git a/test/model.test.ts b/test/model.test.tsindex 78ab2eb..2c90ab9 100644--- a/test/model.test.ts+++ b/test/model.test.ts@@ -219,7 +219,7 @@ const apply = (town: Headless, command: Command): string | null => {case "SaveAndLoad": {// Through the page's own saving and loading: a save loads back to exactly what was saved.const world: World["Service"] = {- snapshot: () => town.snapshot(),+ snapshot: () => ({ ok: true, value: town.snapshot() }),restore: (data) => {town.restore(data as Snapshot)return nulldiff --git a/test/save.test.ts b/test/save.test.tsindex b373141..ad45e4d 100644--- a/test/save.test.ts+++ b/test/save.test.ts@@ -4,15 +4,17 @@* the town as it was.*/import assert from "node:assert/strict"+import { createHash } from "node:crypto"+import { readFileSync } from "node:fs"import { test } from "node:test"import { Effect } from "effect"-import { load, loadLatest, memoryStorage, read, save, SAVE_FORMAT, SAVE_VERSION, Storage, World, type LoadError } from "../src/platform/save.ts"+import { describe, load, loadLatest, loadText, memoryStorage, read, save, SAVE_FORMAT, SAVE_VERSION, Storage, World, type LoadError } from "../src/platform/save.ts"import { headless, type Headless } from "../src/game/headless.ts"const worldOf = (town: Headless): World["Service"] => ({- snapshot: () => town.snapshot(),+ snapshot: () => ({ ok: true, value: town.snapshot() }),restore: (data) => {try {town.restore(data)@@ -26,8 +28,7 @@ const worldOf = (town: Headless): World["Service"] => ({/*** The world as it plays: everything but the counter new entity ids come- * from, which bevy-ts never moves backwards on a load (so ids are never- * reused), and which nothing in the town reads.+ * from, which a load sets to the save's, and which nothing in the town reads.*/const playing = (town: Headless) => {const { nextEntity: _, ...world } = town.snapshot()@@ -106,6 +107,38 @@ test("a storage that will not take the save says so", () => {assert.equal((result as { failure: { _tag: string } }).failure._tag, "StorageFailed")})+test("a world that cannot be saved says so, and writes nothing", () => {+ const { storage } = setup()+ const unsaveable: World["Service"] = { snapshot: () => ({ ok: false, error: { _tag: "UnencodableResource", name: "Town/Treasury" } }), restore: () => null, title: () => "" }+ const result = Effect.runSync(Effect.result(save("manual").pipe(Effect.provideService(Storage, storage), Effect.provideService(World, unsaveable))))+ assert.equal(result._tag, "Failure")+ const error = (result as { failure: Parameters<typeof describe>[0] }).failure+ assert.equal(error._tag, "Unsaveable")+ assert.match(describe(error), /Could not save the town/)+ assert.equal(storage.files.size, 0)+})++/** A snapshot's world, keys sorted, without its format and game versions: what plays. */+const fingerprint = (world: object) => {+ const canonical = (value: unknown): unknown =>+ Array.isArray(value) ? value.map(canonical)+ : value !== null && typeof value === "object" ? Object.fromEntries(Object.keys(value).sort().map((k) => [k, canonical((value as Record<string, unknown>)[k])]))+ : value+ const { version: _, gameVersion: __, ...rest } = world as { version: unknown; gameVersion: unknown }+ return createHash("sha1").update(JSON.stringify(canonical(rest))).digest("hex")+}++test("a save the game wrote on Ritmo 0.9 (save version 10, snapshot format 2) loads and plays on as it did", () => {+ // Saved after 90 s of a small, fair town (seed 5); the fingerprint is that town 30 s later, played on Ritmo 0.9.+ const text = readFileSync(new URL("./fixtures/save-v10-ritmo-0.9.json", import.meta.url), "utf8")+ assert.equal(JSON.parse(text).version, 10)+ const { town } = setup()+ const loaded = Effect.runSync(Effect.result(loadText(text).pipe(Effect.provideService(World, worldOf(town)))))+ assert.equal(loaded._tag, "Success")+ town.run(30)+ assert.equal(fingerprint(town.snapshot()), "b62c15241f26b2e4b2a5ef5bf4cd72969f966351")+})+test("a save from before files had envelopes still loads", () => {const { town, storage, run } = setup()town.run(10)diff --git a/test/share.test.ts b/test/share.test.tsindex a547513..57096fe 100644--- a/test/share.test.ts+++ b/test/share.test.ts@@ -137,7 +137,7 @@ test("ids, lines, and picture kinds", () => {})const worldOf = (town: Headless): World["Service"] => ({- snapshot: () => town.snapshot(),+ snapshot: () => ({ ok: true, value: town.snapshot() }),restore: (data) => {try {town.restore(data)