A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D
Guide's done-when line wraps as a paragraph; no 'Laid' sentence; hunger waits 20 s
SandroMaglione8a2ddf833aa0
diff --git a/src/factory.css b/src/factory.cssindex 31b57ab..d721c36 100644--- a/src/factory.css+++ b/src/factory.css@@ -391,7 +391,9 @@ 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; }+/* The flag in its own column, the words wrapping beside it as one paragraph. */+.hud .ticker .cell.guide .goal { display: grid; grid-template-columns: 12px minmax(0, 1fr); column-gap: 7px; align-items: start; margin-top: 6px; font-size: 11px; line-height: 1.7; color: #6d7f9c; }+.hud .ticker .cell.guide .goal > .glyph, .hud .ticker .cell.guide .goal > svg { height: 1.7em; }.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 aa3f6df..49eb3ea 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 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>`+ `<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)}<span>done when ${callouts(g.goal)}</span></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/present.ts b/src/present.tsindex 7e84d45..28f4de8 100644--- a/src/present.ts+++ b/src/present.ts@@ -87,7 +87,7 @@ import { emptyPreview, type Alert as Notice, type HitBox, type Legend, type Lineimport { blockers as blockersOf, streetAdvice, type InTown, type Served, type Street } from "./rules/explain.ts"import { breadBonus, streetTax, suppliedTaxOf } from "./rules/households.ts"import { rockBlocks, type RockPart } from "./render3d/rock-blocks.ts"-import { GUIDE_QUIET, guideBuilding, guideDone, guideStep, guideSteps, type GuideFacts, type GuideFocus } from "./rules/guide.ts"+import { GUIDE_QUIET, guideDone, guideStep, guideSteps, type GuideFacts, type GuideFocus } from "./rules/guide.ts"import { ticks } from "./content.ts"const cellAt = (at: Point): Point => {@@ -317,7 +317,7 @@ const ALERT_PATIENCE = ticks(30)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)+const HUNGER_PATIENCE = ticks(20)/** 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@@ -1269,7 +1269,7 @@ export const Interact = Game.System(chronicle: resources.chronicle.get().lines,alerts,guide: {- 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,+ step: step && shown ? { key: step.id, chapter: step.chapter, goal: step.goal, text: 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 f7410ba..be54fe6 100644--- a/src/rules/guide.ts+++ b/src/rules/guide.ts@@ -83,8 +83,6 @@ export interface GuideStep {readonly goal: stringreadonly focus: GuideFocus | nullreadonly when: (f: GuideFacts) => boolean- /** The buildings it asks for (done when they stand). */- readonly kinds?: ReadonlyArray<KindId>/** One of the first steps, which come one after another, without the quiet. */readonly opening?: boolean/** It cannot wait for the guide's quiet (and goes ahead of the step shown). */@@ -112,7 +110,6 @@ export const guideSteps: ReadonlyArray<GuideStep> = [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",- kinds: ["fishery"],opening: true,when: (f) => f.builtHomes > 0,done: (f) => has(f, "fishery") || has(f, "bakery")@@ -130,7 +127,6 @@ 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.",focus: "hall",@@ -153,7 +149,6 @@ export const guideSteps: ReadonlyArray<GuideStep> = [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",- kinds: ["lumberjack", "sawmill"],opening: true,when: (f) => f.stock.planks < 25 || f.standing.has("fishery"),done: (f) => has(f, "lumberjack", "sawmill")@@ -161,7 +156,6 @@ 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.",focus: { kind: "lumberjack" },@@ -174,7 +168,6 @@ export const guideSteps: ReadonlyArray<GuideStep> = [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",- kinds: ["quarry"],opening: true,when: (f) => f.stock.stone < 10 || has(f, "lumberjack", "sawmill"),done: (f) => has(f, "quarry")@@ -212,7 +205,6 @@ export const guideSteps: ReadonlyArray<GuideStep> = [{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.",focus: "hall",@@ -223,7 +215,6 @@ 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.",focus: "worn",@@ -234,7 +225,6 @@ 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.",focus: "hall",@@ -253,7 +243,6 @@ export const guideSteps: ReadonlyArray<GuideStep> = [{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; 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",@@ -263,7 +252,6 @@ export const guideSteps: ReadonlyArray<GuideStep> = [{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" },@@ -273,7 +261,6 @@ export const guideSteps: ReadonlyArray<GuideStep> = [{id: "cloth",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",@@ -283,7 +270,6 @@ export const guideSteps: ReadonlyArray<GuideStep> = [{id: "chapel",goal: "a chapel stands",- kinds: ["chapel"],chapter: "Growing citizens",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",@@ -302,7 +288,6 @@ 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.",focus: "hall",@@ -313,7 +298,6 @@ 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.",focus: "hall",@@ -341,7 +325,6 @@ 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.",focus: "ore",@@ -354,10 +337,6 @@ export const guideSteps: ReadonlyArray<GuideStep> = [export const guideDone = (f: GuideFacts, done: ReadonlySet<string>): Array<string> =>guideSteps.filter((s) => !done.has(s.id) && s.done(f)).map((s) => s.id)-/** The step asks for buildings that are laid but not all standing yet: say so, rather than ask again. */-export const guideBuilding = (step: GuideStep, f: GuideFacts) =>- step.id === "homes" ? f.homes > 0 && f.builtHomes === 0 : (step.kinds ?? []).some((k) => f.placed.has(k) && !f.standing.has(k))-/*** The step to show now, if any: an urgent one first; else the step already* shown (`shown`), until it is done or put away; else, unless the guide isdiff --git a/test/guide.test.ts b/test/guide.test.tsindex c054eda..0040a98 100644--- a/test/guide.test.ts+++ b/test/guide.test.ts@@ -8,7 +8,7 @@ import assert from "node:assert/strict"import { test } from "node:test"import { amounts, kinds, type KindId } from "../src/content.ts"-import { guideBuilding, guideDone, guideStep, guideSteps, type GuideFacts } from "../src/rules/guide.ts"+import { guideDone, guideStep, guideSteps, type GuideFacts } from "../src/rules/guide.ts"const fresh: GuideFacts = {homes: 0,@@ -68,9 +68,7 @@ test("the opening comes step after step, each once the last is built", () => {const put = new Set(guideDone(housed, none))assert.equal(guideStep(housed, put, { quiet: true })?.id, "fishery", "no quiet in the opening")const building = { ...housed, placed: new Set<KindId>(["fishery"]) }- const step = guideStep(building, put)!- assert.equal(step.id, "fishery")- assert.ok(guideBuilding(step, building), "a laid fishery is told as being built")+ assert.equal(guideStep(building, put)?.id, "fishery", "a laid fishery is not done until it stands")const fed = town({ homes: 4, residents: 8 }, ["fishery"])assert.equal(guideStep(fed, new Set(guideDone(fed, none)), { quiet: true })?.id, "planks")const sawn = town({ homes: 4, residents: 8 }, ["fishery", "lumberjack", "sawmill"])