A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D
Start with only the hall's ring road; every guide step says what closes it
SandroMaglione5c19d4f437d3
diff --git a/scripts/check.ts b/scripts/check.tsindex 57b48d2..6b539db 100644--- a/scripts/check.ts+++ b/scripts/check.ts@@ -32,6 +32,13 @@ import { headless, type Snapshot } from "../src/sim/headless.ts"const town = (charter: CharterValue = { size: "small", term: 45, land: "fair", seed: 7 }) => {const t = headless(charter)+ // A new town has only the ring road round its hall; these checks were laid out along a stub road out of each side.+ t.change((s) => {+ const hall = s.entities.find((e) => e.components["Town/TownHall"])!.components["Town/Tile"]+ for (let i = 2; i <= 3; i++)+ for (const cell of [{ x: hall.x + 2 + i, y: hall.y + 1 }, { x: hall.x + 1, y: hall.y + 2 + i }, { x: hall.x - i, y: hall.y + 1 }, { x: hall.x + 1, y: hall.y - i }])+ s.entities.push({ id: s.nextEntity++, components: { "Town/Tile": { ...cell, size: 1 }, "Town/Road": {} } })+ })const fate = () => t.snapshot().resources["Town/Fate"] as { state: string; reason: string; at: number; governing: boolean }return { ...t, fate }}diff --git a/src/factory.css b/src/factory.cssindex 3aac8db..31b57ab 100644--- a/src/factory.css+++ b/src/factory.css@@ -374,8 +374,8 @@ body { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;box-shadow: inset 3px 0 0 transparent;}.hud .ticker .cell + .cell { border-left: none; border-top: 1px dashed #e3e6df; }-/* The icon as tall as a line of text, so it sits centred on the first line. */-.hud .ticker .cell .mark { height: 1.55em; }+/* The icon as tall as a line of text, so it sits centred on the first line (a pixel lower: the letters sit low in the line). */+.hud .ticker .cell .mark { height: 1.55em; transform: translateY(1px); }.hud .ticker .cell .text { flex: 1; min-width: 0; }.hud .ticker .cell em { font-style: normal; color: #9aa29b; white-space: nowrap; }.hud .ticker .cell.place { cursor: pointer; }@@ -390,6 +390,8 @@ body { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;}.hud .ticker .head.guide .quiet:hover { color: #3d4943; text-decoration: underline; }.hud .ticker .cell.guide { background: #f6f8fc; }+/* What closes the step, under it. */+.hud .ticker .cell.guide .goal { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 11px; color: #6d7f9c; }.hud .ticker .cell.guide.place:hover { background: #eef3fb; }.hud .ticker .cell.guide + .head { border-top: 1px dashed #e3e6df; }.hud .ticker .alert.warn { box-shadow: inset 3px 0 0 #d9a24e; }diff --git a/src/host.ts b/src/host.tsindex 6d29c56..aa3f6df 100644--- a/src/host.ts+++ b/src/host.ts@@ -1692,7 +1692,7 @@ export const createHost = async (mount: HTMLElement, persistence: () => Persisteconst guideHtml = g? [`<div class="head guide"><span>guide · ${escapeHtml(g.chapter)}</span><span class="progress" title="Steps of the guide done">${s.guide.done} of ${s.guide.total} done</span><button class="quiet" data-guide-off title="Turn the guide off (the guide button in the bottom right turns it back on)">hide guide</button></div>`,- `<div class="cell alert hint guide${g.at !== null ? " place" : ""}" data-guide>${icon("hint", 16, "mark")}<span class="text">${callouts(g.text)}</span><span class="acts">${g.at !== null ? `<button class="act locate" title="Show me where">${icon("locate", 14)}</button>` : ""}<button class="act dismiss" data-skip="${escapeHtml(g.key)}" title="Skip this step">${icon("close", 12)}</button></span></div>`+ `<div class="cell alert hint guide${g.at !== null ? " place" : ""}" data-guide>${icon("hint", 16, "mark")}<span class="text">${callouts(g.text)}<span class="goal">${icon("goal", 12)}done when ${callouts(g.goal)}</span></span><span class="acts">${g.at !== null ? `<button class="act locate" title="Show me where">${icon("locate", 14)}</button>` : ""}<button class="act dismiss" data-skip="${escapeHtml(g.key)}" title="Skip this step">${icon("close", 12)}</button></span></div>`]: []const tickerHtml = [diff --git a/src/mapgen.ts b/src/mapgen.tsindex a8b840c..7ae04a6 100644--- a/src/mapgen.ts+++ b/src/mapgen.ts@@ -4,8 +4,8 @@ import { shippedRules, type Rules } from "./rules/config.ts"* the charter's size, its coast wandering in and out and a few capes* reaching out; lakes, forests and single trees, outcrops of stone and* deposits of ore, as many as the land's richness gives; and a clearing in- * the middle where the town hall stands, ringed by a road with a stub out- * from each side.+ * the middle where the town hall stands, ringed by a road (the mayor lays+ * the rest).* Pure: the same charter always makes the same land.*/import * as Random from "@typeonce/bevy-ts-math/Random"@@ -117,7 +117,8 @@ export const generate = (charter: CharterValue, rules: Rules = shippedRules): Lareturn { x: random.integer(1, GRID - 1), y: random.integer(1, GRID - 1) }}- // The town hall, a ring road around it, and a stub out from the middle of each side.+ // The town hall and a ring road around it. The ground a cell or two out from each side is cleared too, but no road+ // leads out: where the town grows is the mayor's first choice.for (let dx = 0; dx < 3; dx++) for (let dy = 0; dy < 3; dy++) take({ x: hall.x + dx, y: hall.y + dy })const roads: Array<Point> = []for (let x = hall.x - 1; x <= hall.x + 3; x++) {@@ -125,10 +126,8 @@ export const generate = (charter: CharterValue, rules: Rules = shippedRules): Laif (x === hall.x - 1 || x === hall.x + 3 || y === hall.y - 1 || y === hall.y + 3) roads.push({ x, y })}}- for (let i = 2; i <= 3; i++) {- roads.push({ x: hall.x + 2 + i, y: hall.y + 1 }, { x: hall.x + 1, y: hall.y + 2 + i }, { x: hall.x - i, y: hall.y + 1 }, { x: hall.x + 1, y: hall.y - i })- }roads.forEach(take)+ for (let i = 2; i <= 3; i++) [{ x: hall.x + 2 + i, y: hall.y + 1 }, { x: hall.x + 1, y: hall.y + 2 + i }, { x: hall.x - i, y: hall.y + 1 }, { x: hall.x + 1, y: hall.y - i }].forEach(take)// Lakes, the first not too far from the town.const water: Array<Point> = []diff --git a/src/present.ts b/src/present.tsindex 5b9b209..7e84d45 100644--- a/src/present.ts+++ b/src/present.ts@@ -313,6 +313,11 @@ const legends: Readonly<Record<Exclude<View, "none">, Legend>> = {/** When each workshop began waiting for its input: a shelf runs empty for a moment all the time, so the ticker only says so after `ALERT_PATIENCE`. */const starvedSince = new Map<number, number>()const ALERT_PATIENCE = ticks(30)+/** Since when the store has held no food (`null`: it has some). Fish comes in and goes out in handfuls, so the ticker waits `HUNGER_PATIENCE` before saying so. */+let emptySince: number | null = null+/** Once said, it stays said a while, so a handful of fish arriving does not flick it off and on. */+let hungryUntil = 0+const HUNGER_PATIENCE = ticks(8)/** A view's colour over a model: pale, so the ink still reads. */const TINT = { good: 0xbcd2ee, fair: 0xf3e3a8, bad: 0xf2b9a0, cool: 0xdccbe8, mark: 0xd5dad3, settlers: 0xead7bd, fine: 0xa9c4e8, plain: 0xffffff }const needIcons = { food: "food", bread: "bread", cloth: "cloth", faith: "faith" } as const@@ -1069,7 +1074,12 @@ export const Interact = Game.System(if (waiting.size > 0) alerts.push({ tone: "warn", text: `waiting for inputs: ${list(waiting)}`, at: first(waiting)?.at ?? null, size: first(waiting)?.at.size ?? 1, id: first(waiting)?.id ?? null, places: placesOf(waiting) })if (remote.size > 0) alerts.push({ tone: "warn", text: `no workers within ${COMMUTE} road cells: ${list(remote)}`, at: first(remote)?.at ?? null, size: first(remote)?.at.size ?? 1, id: first(remote)?.id ?? null, places: placesOf(remote) })const hallRow = buildings.find(({ data }) => data.hall.present)- if (census.homes > 0 && larder(stock) === 0) alerts.push({ tone: "bad", text: "no food in store: homes go hungry", at: hallRow?.data.tile.get() ?? null, size: hallRow?.data.tile.get().size ?? 1, id: hallRow?.entity.id ?? null })+ const empty = census.homes > 0 && larder(stock) === 0+ if (!empty || (emptySince !== null && emptySince > tick)) emptySince = null+ if (empty && emptySince === null) emptySince = tick+ if (empty && tick - emptySince! >= HUNGER_PATIENCE) hungryUntil = tick + HUNGER_PATIENCE+ if (hungryUntil > tick + HUNGER_PATIENCE) hungryUntil = 0+ if (census.homes > 0 && tick < hungryUntil) alerts.push({ tone: "bad", text: "no food in store: homes go hungry", at: hallRow?.data.tile.get() ?? null, size: hallRow?.data.tile.get().size ?? 1, id: hallRow?.entity.id ?? null })const ledger = resources.ledger.get()const charter = resources.charter.get()const t = elapsed(resources.time.get(), charter)@@ -1128,6 +1138,7 @@ export const Interact = Game.System(net: steadyNet(resources.history.get().samples, net),approval: mood.approval,trading: rates.sells.length > 0 || rates.buys.length > 0,+ buysTools: rates.buys.includes("tools"),taxed: rates.settlers !== 100 || rates.citizens !== 100,most: Math.max(...goodIds.map((g) => stock[g])),sawTown: ui.menu === "town",@@ -1258,7 +1269,7 @@ export const Interact = Game.System(chronicle: resources.chronicle.get().lines,alerts,guide: {- step: step && shown ? { key: step.id, chapter: step.chapter, text: guideBuilding(step, facts) ? `${step.text} Laid: it starts once the builders finish it.` : step.text, at: shown.at, size: shown.at?.size ?? 1, id: shown.id } : null,+ step: step && shown ? { key: step.id, chapter: step.chapter, goal: step.goal, text: guideBuilding(step, facts) ? `${step.text} Laid: it starts once the builders finish it.` : step.text, at: shown.at, size: shown.at?.size ?? 1, id: shown.id } : null,done: guideSteps.filter((s) => put.has(s.id)).length,total: guideSteps.length,off: guide.offdiff --git a/src/rules/guide.ts b/src/rules/guide.tsindex a6f56cc..f7410ba 100644--- a/src/rules/guide.ts+++ b/src/rules/guide.ts@@ -51,6 +51,8 @@ export interface GuideFacts {readonly approval: number/** The town buys or sells something; a tax rate is off the usual. */readonly trading: boolean+ /** The town buys tools from traders. */+ readonly buysTools: booleanreadonly taxed: boolean/** The most of any one good in store. */readonly most: number@@ -77,6 +79,8 @@ export interface GuideStep {readonly chapter: Chapter/** What to do and why. Building names become chips to place one; a key in brackets, a key. */readonly text: string+ /** When the step is done, in a few words: shown under it, so the mayor knows what closes it. */+ readonly goal: stringreadonly focus: GuideFocus | nullreadonly when: (f: GuideFacts) => boolean/** The buildings it asks for (done when they stand). */@@ -94,6 +98,7 @@ const has = (f: GuideFacts, ...kinds: ReadonlyArray<KindId>) => kinds.every((k)export const guideSteps: ReadonlyArray<GuideStep> = [{id: "homes",+ goal: "a home stands",chapter: "Founding",text: "Drag a row of homes along the road from the town hall (H), or lay more road first (R). Builders carry planks from the store to each one; once it stands, settlers move in on their own, and every home pays taxes.",focus: "hall",@@ -103,6 +108,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "fishery",+ goal: "a fishery stands",chapter: "Founding",text: "The bar at the top is the town's store. Settlers eat fish from it, and the fish there will not last. Build a fishery (B) on a road within two cells of water; the town hall's walker carries the fish to the homes.",focus: "water",@@ -113,6 +119,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "crown",+ goal: "the goods are sent, with the button on the request",chapter: "Governing",text: "The crown asks for goods by a deadline. Send them from the bar at the top for coins; an unanswered request is a fine, and three missed in a row and the mayor is dismissed.",focus: null,@@ -122,6 +129,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "winter",+ goal: "a granary or a smokehouse stands",kinds: ["granary", "smokehouse"],chapter: "Keeping it standing",text: "Winter is coming: fishing slows, homes eat faster, and fish rots in store. A granary keeps fish five times as long, and a smokehouse makes fish that keeps all winter.",@@ -132,14 +140,16 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "tools",+ goal: "the town buys tools (town panel, trade), or a smithy stands",chapter: "Growing citizens",- text: "Tools are scarce until a smithy forges them from ore, and that needs 10 citizens. Keep them for the weaver, the mill, and the bakery (not lamps), or buy them from traders in the town panel (T).",+ text: "Tools are running low, and only a smithy makes new ones, which opens at 10 citizens. Until then, buy tools from traders in the town panel (T), and keep them for workshops.",focus: null,- when: (f) => f.residents >= 15 && f.stock.tools <= 3 && !has(f, "weaver", "mill", "bakery"),- done: (f) => has(f, "weaver", "mill", "bakery") || has(f, "smithy")+ when: (f) => f.residents >= 15 && f.stock.tools <= 3 && !has(f, "smithy"),+ done: (f) => f.buysTools || has(f, "smithy")},{id: "planks",+ goal: "a lumberjack and a sawmill stand",chapter: "Founding",text: "Every home and building costs planks from the store, and they run out. Goods come in chains: a lumberjack by the woods fells wood, and a sawmill saws the wood into planks.",focus: "trees",@@ -150,6 +160,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "forester",+ goal: "a forester stands",kinds: ["forester"],chapter: "Founding",text: "The lumberjack is running out of trees. A forester beside it plants new ones for it to fell.",@@ -159,6 +170,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "quarry",+ goal: "a quarry stands",chapter: "Founding",text: "Storage, workshops, and paving take stone, and the town starts with little. A quarry cuts it from the pale rocks nearby (the dark ones are ore, for later).",focus: "stone",@@ -169,6 +181,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "look",+ goal: "you click a home",chapter: "Founding",text: "The town is on its feet. Click a home to see who lives there, what it needs, and what it pays; click any building to see what it makes and what holds it back.",focus: "hall",@@ -178,6 +191,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "watch",+ goal: "you open the town panel (T)",chapter: "Founding",text: "As the town grows, keep an eye on the store at the top (goods running low), approval and jobs at the top right, and this ticker, which says what needs looking at. The town panel (T) holds the term's goals, trade, and taxes.",focus: null,@@ -185,8 +199,19 @@ export const guideSteps: ReadonlyArray<GuideStep> = [when: (f) => has(f, "quarry") && f.builtHomes > 0,done: (f) => f.sawTown},+ {+ id: "grow",+ goal: "10 homes stand",+ chapter: "Founding",+ text: "Now grow. Lay new streets and homes: more residents pay more taxes and open new buildings in the build menu (B). The guide speaks up again when the town needs something.",+ focus: "hall",+ opening: true,+ when: (f) => has(f, "quarry") && f.sawHome && f.sawTown,+ done: (f) => f.builtHomes >= 10+ },{id: "firewatch",+ goal: "a fire watch stands",kinds: ["firewatch"],chapter: "Keeping it standing",text: "The risk of fire is rising: wooden cottages catch fire, and a fire spreads to its neighbours. A fire watch sends a watchman along the streets, and firefighters to any blaze. Press F to see the risk.",@@ -197,6 +222,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "builder",+ goal: "a builder's yard stands",kinds: ["builder"],chapter: "Keeping it standing",text: "Buildings wear out, and a run-down one works at half pace and may fall. A builder's yard mends what its builder passes, with planks and stone. Press C to see their condition.",@@ -207,6 +233,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "market",+ goal: "a market stands",kinds: ["market"],chapter: "Keeping it standing",text: "The town hall's walker only reaches 20 road cells. A market sends a walker with fish, bread, and cloth further along the streets.",@@ -216,6 +243,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "street",+ goal: "a home on a fine street holds citizens",chapter: "Growing citizens",text: "A home here has bread, cloth, and faith, but its street is too poor for citizens: it needs desirability 5. Press D to see it; keep workshops away, and add a chapel, a market, or a park.",focus: "poorStreet",@@ -223,25 +251,48 @@ export const guideSteps: ReadonlyArray<GuideStep> = [done: (f) => f.finerHomes > 0},{- id: "bread",- kinds: ["farm", "mill", "bakery"],+ id: "wheat",+ goal: "a farm and a mill stand",+ kinds: ["farm", "mill"],chapter: "Growing citizens",- text: "Settlers become citizens, who pay twice as much, once they have bread, cloth, and faith, all three; settlers want only food until then. Start with bread, the longest chain: a farm grows wheat, a mill grinds it into flour, and a bakery bakes the bread.",+ text: "Settlers become citizens, who pay twice as much, once they have bread, cloth, and faith, all three; until then they want only food. Start with bread, the longest chain: a farm grows wheat, and a mill grinds it into flour.",focus: "hall",when: (f) => f.residents >= 30,- done: (f) => has(f, "farm", "mill", "bakery")+ done: (f) => has(f, "farm", "mill")+ },+ {+ id: "bakery",+ goal: "a bakery stands",+ kinds: ["bakery"],+ chapter: "Growing citizens",+ text: "A bakery bakes the mill's flour into bread. Citizens need it, and a settlers' cottage with bread on the table pays half again.",+ focus: { kind: "mill" },+ when: (f) => has(f, "farm", "mill"),+ done: (f) => has(f, "bakery")},{id: "cloth",- kinds: ["sheep", "weaver", "chapel"],+ goal: "a sheep farm and a weaver stand",+ kinds: ["sheep", "weaver"],+ chapter: "Growing citizens",+ text: "Next, cloth: a sheep farm shears wool, and a weaver weaves it into cloth.",+ focus: "hall",+ when: (f) => has(f, "bakery") || f.residents >= 60,+ done: (f) => has(f, "sheep", "weaver")+ },+ {+ id: "chapel",+ goal: "a chapel stands",+ kinds: ["chapel"],chapter: "Growing citizens",- text: "Bread alone makes no citizens: they need cloth and faith too. A sheep farm and a weaver make cloth, and a chapel brings faith (and makes its street more desirable).",+ text: "The last need is faith: a chapel's walker brings it to the homes it passes, and the chapel makes its street more desirable.",focus: "hall",- when: (f) => has(f, "farm", "mill", "bakery") || f.residents >= 60,- done: (f) => has(f, "sheep", "weaver", "chapel")+ when: (f) => has(f, "sheep", "weaver"),+ done: (f) => has(f, "chapel")},{id: "goals",+ goal: "you open the town panel (T)",chapter: "Growing citizens",text: "The first citizens have moved in. Open the town panel (T) to see the goals the term is judged by: residents, citizens, approval, and coins.",focus: null,@@ -250,6 +301,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "healer",+ goal: "a healer stands",kinds: ["healer"],chapter: "Keeping it standing",text: "Sickness is spreading: hunger, crowding, and a quarry's dust make homes sick, and a sick home holds half as many. A healer's physician calls on the homes and cures them. Press A to see the risk.",@@ -260,6 +312,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "watchhouse",+ goal: "a watch house stands",kinds: ["watchhouse"],chapter: "Keeping it standing",text: "Thieves are about: poor streets, half-empty homes, and low approval breed them. A watch house sends a constable along the streets to keep order. Press O to see the risk.",@@ -269,6 +322,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "trade",+ goal: "the town sells or buys something (town panel, trade)",chapter: "Governing",text: "The town trades nothing until told to. In the town panel (T), sell what piles up beyond the reserve, and buy what runs short.",focus: null,@@ -277,6 +331,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "taxes",+ goal: "a tax rate is changed (town panel)",chapter: "Governing",text: "The town is content, and approval can carry higher taxes. Raise them in the town panel (T); above 125% leaves a grudge that lasts.",focus: null,@@ -285,6 +340,7 @@ export const guideSteps: ReadonlyArray<GuideStep> = [},{id: "smithy",+ goal: "a mine and a smithy stand",kinds: ["mine", "smithy"],chapter: "Governing",text: "Ore is for one thing: tools. Now open: a mine by the dark, rust-veined rocks digs ore, and a smithy forges it into tools, which every workshop and lamp needs and which wear out.",diff --git a/src/ui.ts b/src/ui.tsindex 584447a..cec0966 100644--- a/src/ui.ts+++ b/src/ui.ts@@ -258,7 +258,7 @@ export interface Stats {readonly alerts: ReadonlyArray<Alert>/** The mayor's guide: the step to take now (if any, and the guide is on), and how far along it is. */readonly guide: {- readonly step: (Omit<Alert, "tone"> & { readonly key: string; readonly chapter: string }) | null+ readonly step: (Omit<Alert, "tone"> & { readonly key: string; readonly chapter: string; readonly goal: string }) | nullreadonly done: numberreadonly total: numberreadonly off: booleandiff --git a/test/guide.test.ts b/test/guide.test.tsindex d8668b2..c054eda 100644--- a/test/guide.test.ts+++ b/test/guide.test.ts@@ -29,6 +29,7 @@ const fresh: GuideFacts = {net: 10,approval: 0,trading: false,+ buysTools: false,taxed: false,most: 40,sawTown: false,@@ -79,22 +80,31 @@ test("the opening comes step after step, each once the last is built", () => {assert.equal(guideStep(quarried, new Set(guideDone(quarried, none)), { quiet: true })?.id, "look")const looked = { ...quarried, sawHome: true }assert.equal(guideStep(looked, new Set(guideDone(looked, none)), { quiet: true })?.id, "watch")+ // And last, the go-ahead to grow, until ten homes stand.+ const told = { ...looked, sawTown: true }+ assert.equal(guideStep(told, new Set(guideDone(told, none)), { quiet: true })?.id, "grow")+ const grown = { ...told, homes: 10, builtHomes: 10 }+ assert.ok(guideDone(grown, none).includes("grow"))})-test("citizens' needs come as one goal, bread first, and not before bread can be made", () => {- const ready = town({ homes: 10, residents: 25, sawHome: true, sawTown: true }, ["fishery", "lumberjack", "sawmill", "quarry"])+test("citizens' needs come bread first, a building or two at a time, and not before bread can be made", () => {+ const ready = town({ homes: 12, residents: 25, sawHome: true, sawTown: true }, ["fishery", "lumberjack", "sawmill", "quarry"])const put = new Set(guideDone(ready, none))assert.notEqual(guideStep(ready, put)?.id, "cloth", "cloth and faith are no use to settlers")const grown = { ...ready, residents: 30 }- assert.equal(guideStep(grown, put)?.id, "bread")- const baking = town({ homes: 12, residents: 34, sawHome: true, sawTown: true }, ["fishery", "lumberjack", "sawmill", "quarry", "farm", "mill", "bakery"])- assert.equal(guideStep(baking, new Set(guideDone(baking, none)))?.id, "cloth")+ assert.equal(guideStep(grown, put)?.id, "wheat")+ // One or two buildings at a time: wheat and flour, then the bakery, then cloth, then the chapel.+ const chain: ReadonlyArray<[ReadonlyArray<KindId>, string]> = [[["farm", "mill"], "bakery"], [["farm", "mill", "bakery"], "cloth"], [["farm", "mill", "bakery", "sheep", "weaver"], "chapel"]]+ for (const [more, next] of chain) {+ const facts = town({ homes: 12, residents: 34, sawHome: true, sawTown: true }, ["fishery", "lumberjack", "sawmill", "quarry", ...more])+ assert.equal(guideStep(facts, new Set(guideDone(facts, none)))?.id, next)+ }})const founded: ReadonlyArray<KindId> = ["fishery", "lumberjack", "sawmill", "quarry"]test("after the opening, steps wait for the town to need them", () => {- const settled = town({ homes: 4, residents: 8, sawHome: true, sawTown: true }, founded)+ const settled = town({ homes: 10, residents: 20, sawHome: true, sawTown: true }, founded)const put = new Set(guideDone(settled, none))// Planks in hand, stone in hand, the woods full, no risk: nothing to say.assert.equal(guideStep(settled, put), null)@@ -103,7 +113,7 @@ test("after the opening, steps wait for the town to need them", () => {})test("after a step the guide keeps quiet, but not through a fire or the crown's request", () => {- const facts = town({ homes: 8, residents: 16, fewTrees: true, sawHome: true, sawTown: true }, founded)+ const facts = town({ homes: 10, residents: 20, fewTrees: true, sawHome: true, sawTown: true }, founded)const put = new Set(guideDone(facts, none))assert.equal(guideStep(facts, put, { quiet: true }), null)assert.equal(guideStep({ ...facts, burning: 1 }, put, { quiet: true })?.id, "firewatch")@@ -111,7 +121,7 @@ test("after a step the guide keeps quiet, but not through a fire or the crown's})test("a step once shown stays until it is done, even if its sign fades", () => {- const thinning = town({ homes: 4, residents: 8, fewTrees: true, sawHome: true, sawTown: true }, founded)+ const thinning = town({ homes: 10, residents: 20, fewTrees: true, sawHome: true, sawTown: true }, founded)const put = new Set(guideDone(thinning, none))assert.equal(guideStep(thinning, put)?.id, "forester")const planted = { ...thinning, fewTrees: false }@@ -152,8 +162,10 @@ test("the guide never asks for a building before the town can build it", () => {firewatch: ["firewatch"],builder: ["builder"],market: ["market"],- cloth: ["sheep", "weaver", "chapel"],- bread: ["farm", "mill", "bakery"],+ cloth: ["sheep", "weaver"],+ wheat: ["farm", "mill"],+ bakery: ["bakery"],+ chapel: ["chapel"],healer: ["healer"],watchhouse: ["watchhouse"],smithy: ["mine", "smithy"]@@ -172,6 +184,10 @@ test("the guide never asks for a building before the town can build it", () => {}})+test("every step says what closes it", () => {+ for (const step of guideSteps) assert.ok(step.goal.length > 0 && step.goal.length <= 80, step.id)+})+test("every step can be done, and a town that has done them all is told nothing", () => {const all = guideSteps.flatMap((s) => [s.id])assert.equal(new Set(all).size, all.length, "step ids are unique")