Skip to content

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

A finer home saved before homes paid to rise keeps its rebuilding

SandroMaglionef8fb86ad7976
diff --git a/src/save.ts b/src/save.ts
index db4cfb9..d2ab0ae 100644
--- a/src/save.ts
+++ b/src/save.ts
@@ -30,8 +30,8 @@ export const SAVE_VERSION = 9
* done); from 7, its first term, and its rank: a town that was complete
* (or governed on after) is a town, any other a hamlet that rises as its
* goals hold. A complete town waiting on its mayor carries on playing;
- * from 8, its water as never fished, its upgrades as the first, and no
- * furniture anywhere yet, at its first price.
+ * from 8, its water as never fished, its upgrades as the first, its finer
+ * homes as rebuilt already, and no furniture anywhere yet, at its first price.
* Anything else is left to the world's own validation.
*/
const carry = (version: number, world: unknown): unknown | null => {
@@ -56,6 +56,9 @@ const carry = (version: number, world: unknown): unknown | null => {
if (v && typeof v === "object") c[name] = { ...v, [field]: furnish(v[field]) }
}
if (c["Town/House"]) c["Town/House"] = furnish(c["Town/House"])
+ // Homes rose for nothing before 9: a finer home has had its rebuilding, and rises back into it for nothing if it steps down.
+ const tier = (c["Town/House"] as { tier?: unknown } | undefined)?.tier
+ if ((tier === 2 || tier === 3) && !("Town/Rebuilt" in c)) c["Town/Rebuilt"] = { tier }
const inventory = c["Town/Inventory"] as { accepts?: Array<string> } | undefined, kind = (c["Town/Building"] as { kind?: string } | undefined)?.kind
if (inventory && Array.isArray(inventory.accepts) && !inventory.accepts.includes("furniture")
&& (kind === "market" || goodIds.every((g) => g === "furniture" || inventory.accepts!.includes(g))))
diff --git a/test/save.test.ts b/test/save.test.ts
index 3fb0806..fb254e6 100644
--- a/test/save.test.ts
+++ b/test/save.test.ts
@@ -215,3 +215,19 @@ test("a town saved before furniture loads with none of it, and stores and market
assert(accepts("townhall").includes("furniture"))
assert.equal(accepts("sawmill").includes("furniture"), false)
})
+
+test("a finer home saved before homes paid to rise keeps its rebuilding", () => {
+ const { town, storage, run } = setup()
+ const hall = town.snapshot().entities.find((e) => e.components["Town/TownHall"])!.components["Town/Tile"]
+ town.edit({ type: "homes", cells: [{ x: hall.x + 4, y: hall.y }, { x: hall.x + 4, y: hall.y + 1 }] })
+ town.run(60)
+ town.change((s) => {
+ for (const [i, e] of s.entities.filter((e) => e.components["Town/House"] && !e.components["Town/Site"]).entries()) e.components["Town/House"].tier = i === 0 ? 2 : 3
+ })
+ run(save("manual"))
+ const file = JSON.parse(storage.get("inkline-town/save/manual")!)
+ storage.set("inkline-town/save/manual", JSON.stringify({ ...file, version: 8, world: beforeFurniture(file.world) }))
+ assert.equal(run(load("manual"))._tag, "Success")
+ const rebuilt = town.snapshot().entities.filter((e) => e.components["Town/House"]).map((e) => [e.components["Town/House"].tier, e.components["Town/Rebuilt"]?.tier])
+ assert.deepEqual(rebuilt.sort(), [[2, 2], [3, 3]])
+})