A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D
Burghers furnish their townhouses: a carpenter and furniture
Clauded85daeb0dd60
diff --git a/README.md b/README.mdindex c83ff01..07d48a4 100644--- a/README.md+++ b/README.md@@ -36,7 +36,8 @@ makes a different island, with a wandering coast and capes reaching out.Lumberjacks fell trees and sawmills cut planks. Quarries and mines dig stoneand ore for the smithy's tools. Farms grow wheat for the mill and the-bakery, sheep give wool for the weaver, and fisheries feed the first+bakery, sheep give wool for the weaver, a carpenter turns planks into+furniture for the townhouses, and fisheries feed the firstsettlers. You never move a crate yourself: carriers push their carts alongthe roads, each loaded with what it carries, and markets send walkersthrough the streets with baskets of fish, bread, and cloth.@@ -54,7 +55,8 @@ Every street has a desirability. A smithy or a quarry drags it down forseveral cells around; parks you lay out yourself (lawns, flower beds,walks in from the street, lamps, a fountain, a statue), a chapel, and paved streetslift it. Citizens will only live on a decent street, and the-finest streets, with every service calling, grow three-storey townhouses.+finest streets, with every service calling and furniture in the parlour,+grow three-storey townhouses.Settlers do the rough work and citizens the skilled, and nobody walks morethan fifteen road cells to a job, so the far-off mine needs its ownworkers' cottages. Zone the town well and it sorts itself into a finediff --git a/docs/how-to-play.md b/docs/how-to-play.mdindex 4a0b1af..a062830 100644--- a/docs/how-to-play.md+++ b/docs/how-to-play.md@@ -164,17 +164,20 @@ Nobody tells you to build it that way; it works best that way.- **Tiers.** Settlers live anywhere. A citizens' home needs desirability 5as well as bread, cloth, and faith, and its rebuilding is paid at oncefrom the treasury and the store (35 coins, 4 planks, 2 stone; a- townhouse 45 coins, 4 planks, 4 stone, and a tool): a home the store+ townhouse 45 coins, 4 planks, 4 stone, a tool, and 2 furniture): a home the storecannot pay for waits at its tier, and one that steps down keeps itsrebuilding and rises back into it for nothing. A home whose street drops below 5goes back to settlers even with every need met. A **townhouse** of- burghers (12 residents, the best taxes) needs desirability 12 and a- fire watch, a healer, and a watch house all calling on it. At+ burghers (12 residents, the best taxes) needs desirability 12, a+ fire watch, a healer, and a watch house all calling on it, and+ furniture: a carpenter makes it from planks, and a market's walker+ brings a fresh piece every few minutes. A townhouse whose furniture+ wears out is a citizens' home again until the next piece comes. Atdesirability −5 or less a home is squalid and holds fewer people.- **Workers by tier, and the commute.** Settlers do the rough work(lumberjack, forester, quarry, mine, fishery, smokehouse, farm, sheep,storage, fire watch, watch house, builder's yard); citizens the skilled- (sawmill, smithy, mill, bakery, weaver, market, chapel, healer,+ (sawmill, smithy, mill, bakery, weaver, carpenter, market, chapel, healer,hospital). Skilled jobs take their own crew first; citizens left over dorough work, and until there are citizens, settlers stand in at askilled job as apprentices, at three-quarters pace. The jobs counter in@@ -298,8 +301,9 @@ over with a new one.(fish, smoked fish, or bread); with bread, cloth, and faith on a streetwith desirability 5 a home becomes a two-story citizens' home that holdsand pays twice as much, and on a fine street (12) with every service- calling, a three-story townhouse. Cloth is only brought to a street fit- for citizens, however much is in store: the home's panel says so, and+ calling and furniture from a carpenter, a three-story townhouse. Cloth is+ only brought to a street fit for citizens, and furniture to one fit for+ burghers, however much is in store: the home's panel says so, andwhat the street is short of.- **Pulling down** a building or a home costs a tenth of what it cost incoins, and half its materials (rounded down) go back into storage, todiff --git a/scripts/balance.ts b/scripts/balance.tsindex 8c726a1..2113bc0 100644--- a/scripts/balance.ts+++ b/scripts/balance.ts@@ -428,7 +428,7 @@ const roadToward = (w: World, kind: Kind | null, limit = 16): Array<Point> => {* were fed as often as the town's homes are now (`fed`, the share of them fed).*/const cottageWorth = (w: World, fed: number) => {- const cottage = { tier: 1 as const, food: 1, bread: 0, cloth: 0, faith: 0, residents: home.tiers[1].residents }+ const cottage = { tier: 1 as const, food: 1, bread: 0, cloth: 0, faith: 0, furniture: 0, residents: home.tiers[1].residents }const residents = capacity(cottage, w.mood.approval, 0, rules, w.policy.settlers)return fed * taxOf({ ...cottage, residents }, w.policy, rules) - moreAdmin(w.homes.reduce((n, h) => n + h.residents, 0), residents, rules)}@@ -486,6 +486,8 @@ const plan = (w: World): ReadonlyArray<{ readonly kind: KindId; readonly when: b{ kind: "bakery", when: count(w, "bakery") < Math.min(bakeries, count(w, "mill")) },{ kind: "sheep", when: count(w, "sheep") < weavers },{ kind: "weaver", when: count(w, "weaver") < Math.min(weavers, count(w, "sheep")) },+ // Townhouses want furniture: a carpenter once there are citizens to rise.+ { kind: "carpenter", when: w.census.citizens! >= 20 && count(w, "carpenter") < 1 + Math.floor(w.census.burghers! / 120) },{ kind: "warehouse", when: count(w, "warehouse") < Math.floor(homes / 25) },// Fish and bread rot: a granary keeps them, and smoked fish keeps.{ kind: "granary", when: homes >= 40 && count(w, "granary") < 1 + Math.floor(homes / 70) },diff --git a/scripts/check.ts b/scripts/check.tsindex f461ee9..ae2a606 100644--- a/scripts/check.ts+++ b/scripts/check.ts@@ -101,7 +101,7 @@ const settle = (s: Snapshot, homes: number) => {id: s.nextEntity++,components: {"Town/Tile": { x, y, size: 1 },- "Town/House": { tier: 2, residents: 8, food: forever, bread: forever, cloth: forever, faith: forever, clock: 1 }+ "Town/House": { tier: 2, residents: 8, food: forever, bread: forever, cloth: forever, faith: forever, furniture: forever, clock: 1 }}})placed += 1@@ -125,6 +125,9 @@ const check = (name: string, ok: boolean, detail: string) => {t.change((s) => {placed = settle(s, 25)s.resources["Town/Treasury"].coins = 10_000+ // Furniture in store, so the finest of them can rise to townhouses.+ const hall = s.entities.find((e) => e.components["Town/TownHall"])!.components["Town/Inventory"]+ hall.stock.furniture = 30})t.run(8 * 60)const f = t.fate()@@ -250,7 +253,7 @@ const homeAt = (s: Snapshot, x: number, y: number, tier: 1 | 2 | 3, residents: nid,components: {"Town/Tile": { x, y, size: 1 },- "Town/House": { tier, residents, food: needs ? forever : 0, bread: needs ? forever : 0, cloth: needs ? forever : 0, faith: needs ? forever : 0, clock: 1 },+ "Town/House": { tier, residents, food: needs ? forever : 0, bread: needs ? forever : 0, cloth: needs ? forever : 0, faith: needs ? forever : 0, furniture: needs ? forever : 0, clock: 1 },"Town/Risk": { fire: r.fire ?? 0, health: r.health ?? 0, order: r.order ?? 0, thefts: 0 },"Town/Condition": { value: CONDITION_MAX }}diff --git a/src/archetypes.ts b/src/archetypes.tsindex a58a0b1..a46abef 100644--- a/src/archetypes.ts+++ b/src/archetypes.ts@@ -71,7 +71,7 @@ export const rolesOf = (kind: Kind, rules: Rules = shippedRules) => {export const houseDraft = (cell: Point) =>Game.Command.spawn([Tile, { x: cell.x, y: cell.y, size: 1 }],- [House, { tier: 1, residents: 0, food: 0, bread: 0, cloth: 0, faith: 0, clock: 0 }]+ [House, { tier: 1, residents: 0, food: 0, bread: 0, cloth: 0, faith: 0, furniture: 0, clock: 0 }])export const houseStart = (rules: Rules = shippedRules) => [site(rules.home.cost), ...wearOf(rules)]export const ruinDraft = (tile: { readonly x: number; readonly y: number; readonly size: number }, cause: "burnt" | "collapsed" | "derelict") =>diff --git a/src/art.ts b/src/art.tsindex c01bd87..dd987af 100644--- a/src/art.ts+++ b/src/art.ts@@ -638,7 +638,8 @@ const dresses: Readonly<Record<KindId, Dress>> = {healer: { accent: 0x4f9a8a },hospital: { accent: 0x4f9a8a, glass: glassCool },watchhouse: { accent: 0x3d4f6e, flag: 0x3d4f6e },- builder: { accent: 0x8a6a45, roof: roofOf(0xb08a5a) }+ builder: { accent: 0x8a6a45, roof: roofOf(0xb08a5a) },+ carpenter: { accent: 0x9a6b3f, roof: roofOf(0x9a6b3f) }}/**diff --git a/src/asset-lab/buildings.ts b/src/asset-lab/buildings.tsindex 8d87469..e4c6f8e 100644--- a/src/asset-lab/buildings.ts+++ b/src/asset-lab/buildings.ts@@ -30,7 +30,8 @@ const dresses: Record<KindId, { accent: number; roof?: number; glass?: number }>healer: { accent: 0x4f9a8a },hospital: { accent: 0x4f9a8a, glass: 0xc9d6ee },watchhouse: { accent: 0x3d4f6e },- builder: { accent: 0x8a6a45, roof: 0xb08a5a }+ builder: { accent: 0x8a6a45, roof: 0xb08a5a },+ carpenter: { accent: 0x9a6b3f, roof: 0x9a6b3f }}export interface BuildingOptions {diff --git a/src/asset-lab/people.ts b/src/asset-lab/people.tsindex db6d9bf..3077454 100644--- a/src/asset-lab/people.ts+++ b/src/asset-lab/people.ts@@ -240,6 +240,18 @@ export function drawCargo(d: Drawing, good: GoodId, count: number, u: number, v:)d.box(u + 0.03, v, 0.035, 0.018, z + 8, 1.6, 0x8f9891, 0x8f9891, 0x7c857d, 0.75)break+ case "furniture": {+ // A chest, and a chair on it (two chairs side by side in a full load).+ d.box(u, v, 1.8 * U, 1.1 * U, z, 3, 0xc9965f, 0xb5814c, 0x9a6b3f, 1)+ for (const c of n >= 2 ? [-0.8, 0.8] : [0]) {+ const y = v + c * U+ d.box(u, y, 0.6 * U, 0.6 * U, z + 5, 0.8, 0xe0b27e, 0xc9965f, 0xb5814c, 0.75)+ d.box(u - 0.5 * U, y, 0.12 * U, 0.6 * U, z + 5.8, 4, 0xe0b27e, 0xc9965f, 0xb5814c, 0.75)+ for (const [a, b] of [[-0.5, -0.5], [0.5, -0.5], [0.5, 0.5], [-0.5, 0.5]] as const)+ d.line([[u + a * U, y + b * U, z + 3], [u + a * U, y + b * U, z + 5]], 0.6, 0x8a6a45)+ }+ break+ }}}diff --git a/src/content.ts b/src/content.tsindex 9f8551f..eee4083 100644--- a/src/content.ts+++ b/src/content.ts@@ -12,7 +12,7 @@ export const ticks = (seconds: number): number => Math.round(seconds / STEP_SECO// ── Goods ─────────────────────────────────────────────────────────────────-export const goodIds = ["wood", "planks", "stone", "ore", "tools", "fish", "smoked", "wheat", "flour", "bread", "wool", "cloth"] as const+export const goodIds = ["wood", "planks", "stone", "ore", "tools", "fish", "smoked", "wheat", "flour", "bread", "wool", "cloth", "furniture"] as constexport type GoodId = (typeof goodIds)[number]/** Each good's crate label colour (the only colour a good has), and what traders pay for one. */@@ -28,7 +28,8 @@ export const goods: Readonly<Record<GoodId, { readonly title: string; readonly cflour: { title: "flour", color: 0xc9b48a, price: 3 },bread: { title: "bread", color: 0xc4523f, price: 4 },wool: { title: "wool", color: 0xa7ada4, price: 2 },- cloth: { title: "cloth", color: 0x8a58a8, price: 6 }+ cloth: { title: "cloth", color: 0x8a58a8, price: 6 },+ furniture: { title: "furniture", color: 0x9a6b3f, price: 9 }}/**@@ -42,7 +43,7 @@ export const RESERVE_MAX = 200export const trade = { sells: [] as ReadonlyArray<GoodId>, reserve: 25 }export type Amounts = Readonly<Record<GoodId, number>>-export const none: Amounts = { wood: 0, planks: 0, stone: 0, ore: 0, tools: 0, fish: 0, smoked: 0, wheat: 0, flour: 0, bread: 0, wool: 0, cloth: 0 }+export const none: Amounts = { wood: 0, planks: 0, stone: 0, ore: 0, tools: 0, fish: 0, smoked: 0, wheat: 0, flour: 0, bread: 0, wool: 0, cloth: 0, furniture: 0 }export const amounts = (some: Partial<Record<GoodId, number>>): Amounts => ({ ...none, ...some })export const total = (a: Amounts): number => goodIds.reduce((sum, g) => sum + a[g], 0)/** Amounts made good by good. */@@ -53,9 +54,9 @@ export const each = (f: (good: GoodId) => number): Amounts => {}/** Goods a market walker hands out to homes. */-export const provisions: ReadonlyArray<GoodId> = ["fish", "smoked", "bread", "cloth"]+export const provisions: ReadonlyArray<GoodId> = ["fish", "smoked", "bread", "cloth", "furniture"]/** Goods the top bar shows, in order. */-export const shownGoods: ReadonlyArray<GoodId> = ["wood", "planks", "stone", "tools", "fish", "smoked", "bread", "cloth"]+export const shownGoods: ReadonlyArray<GoodId> = ["wood", "planks", "stone", "tools", "fish", "smoked", "bread", "cloth", "furniture"]/** Goods that are food in store (see `larder`). */export const foods: ReadonlyArray<GoodId> = ["fish", "smoked", "bread"]@@ -94,7 +95,7 @@ export type Topper = "none" | "chimney" | "flag" | "cupola" | "sails" | "crates"export const kindIds = ["townhall", "warehouse", "lumberjack", "forester", "quarry", "mine", "fishery", "sawmill","smithy", "farm", "mill", "bakery", "sheep", "weaver", "market", "chapel",- "granary", "smokehouse", "firewatch", "healer", "hospital", "watchhouse", "builder"+ "granary", "smokehouse", "firewatch", "healer", "hospital", "watchhouse", "builder", "carpenter"] as constexport type KindId = (typeof kindIds)[number]@@ -375,11 +376,18 @@ export const kinds: Readonly<Record<KindId, Kind>> = {recipe: { input: "wool", inputs: 1, output: "cloth", batch: 1, seconds: 6 }, holds: { accepts: ["wool", "cloth"], cap: 8 }, carriers: 2,wear: 60, appeal: { value: -2, reach: 2 }},+ carpenter: {+ id: "carpenter", title: "Carpenter", blurb: "makes furniture from planks, for the burghers' townhouses",+ category: "crafts", size: 2, half: 12, stories: 1, roof: "gable", bays: 2, window: 4, topper: "chimney",+ cost: { coins: 160, materials: { planks: 4, stone: 2, tools: 1 } }, upkeep: 8, workers: 2, crew: "citizens", unlock: { residents: 0, citizens: 20 }, buildable: true,+ recipe: { input: "planks", inputs: 2, output: "furniture", batch: 1, seconds: 8 }, holds: { accepts: ["planks", "furniture"], cap: 8 }, carriers: 2,+ wear: 60, appeal: { value: -2, reach: 2 }+ },market: {- id: "market", title: "Market", blurb: "a walker carries fish, bread, and cloth to the homes it passes",+ id: "market", title: "Market", blurb: "a walker carries fish, bread, cloth, and furniture to the homes it passes",category: "services", size: 2, half: 12, stories: 1, roof: "flat", bays: 2, window: 6, topper: "flag",cost: { coins: 120, materials: { planks: 6, stone: 2 } }, upkeep: 6, workers: 2, crew: "citizens", unlock: free, buildable: true,- holds: { accepts: ["fish", "smoked", "bread", "cloth"], cap: 12 },+ holds: { accepts: ["fish", "smoked", "bread", "cloth", "furniture"], cap: 12 },service: { service: "goods", seconds: 6, range: 18 }, appeal: { value: 2, reach: 3, full: 2 },upgrade: {title: "Market hall", blurb: "a covered hall: its walker goes further, more often, and the street around it is finer", rank: 2,@@ -436,7 +444,7 @@ export const kinds: Readonly<Record<KindId, Kind>> = {}export const kindOrder: ReadonlyArray<KindId> = [- "warehouse", "granary", "lumberjack", "forester", "quarry", "mine", "sawmill", "smithy", "sheep", "weaver",+ "warehouse", "granary", "lumberjack", "forester", "quarry", "mine", "sawmill", "smithy", "sheep", "weaver", "carpenter","fishery", "smokehouse", "farm", "mill", "bakery", "market", "chapel", "firewatch", "healer", "hospital", "watchhouse", "builder"]@@ -512,8 +520,8 @@ export const park = {export type Tier = 1 | 2 | 3export const tierIds: ReadonlyArray<Tier> = [1, 2, 3]-/** What a home can be short of. Settlers need food (fish, smoked fish, or bread); citizens and burghers bread, cloth, and faith. */-export type Need = "food" | "bread" | "cloth" | "faith"+/** What a home can be short of. Settlers need food (fish, smoked fish, or bread); citizens bread, cloth, and faith; burghers furniture besides. */+export type Need = "food" | "bread" | "cloth" | "faith" | "furniture"export const home = {/** Half the house's width, in units: a 1×1 cell is 8 units from centre to edge. */@@ -522,7 +530,7 @@ export const home = {tiers: {1: { title: "settlers", residents: 4, tax: 2.5, height: 14, needs: ["food"], appeal: -100, rise: { coins: 0, materials: {} } },2: { title: "citizens", residents: 8, tax: 5, height: 26, needs: ["bread", "cloth", "faith"], appeal: 5, rise: { coins: 35, materials: { planks: 4, stone: 2 } } },- 3: { title: "burghers", residents: 12, tax: 6.5, height: 38, needs: ["bread", "cloth", "faith"], appeal: 12, rise: { coins: 45, materials: { planks: 4, stone: 4, tools: 1 } } }+ 3: { title: "burghers", residents: 12, tax: 7, height: 38, needs: ["bread", "cloth", "faith", "furniture"], appeal: 12, rise: { coins: 45, materials: { planks: 4, stone: 4, tools: 1, furniture: 2 } } }} as Readonly<Record<Tier, {readonly title: stringreadonly residents: number@@ -542,7 +550,7 @@ export const home = {/** A resident moves in (or out) this often. */settle: ticks(3),/** How long each need stays met after a walker's visit: cloth and faith last longer than a meal. */- lasts: { food: ticks(90), bread: ticks(120), cloth: ticks(240), faith: ticks(180) } as Readonly<Record<Need, number>>,+ lasts: { food: ticks(90), bread: ticks(120), cloth: ticks(240), faith: ticks(180), furniture: ticks(300) } as Readonly<Record<Need, number>>,/** Where nobody wants to live: the desirability the map's legend calls squalid. */squalid: -5,/**@@ -707,7 +715,7 @@ export const condition = {/** Tax rates the town can set, in percent of the usual. */export const TAX_STEPS = [50, 75, 100, 125, 150, 200] as const-export const needTitle: Readonly<Record<Need, string>> = { food: "food", bread: "bread", cloth: "cloth", faith: "faith" }+export const needTitle: Readonly<Record<Need, string>> = { food: "food", bread: "bread", cloth: "cloth", faith: "faith", furniture: "furniture" }// ── The town ──────────────────────────────────────────────────────────────diff --git a/src/host.ts b/src/host.tsindex a2d5001..02e454d 100644--- a/src/host.ts+++ b/src/host.ts@@ -220,12 +220,13 @@ export const createHost = async (flour: "a mill's; a bakery bakes it into bread",bread: "food that citizens need, and a cottage with bread pays half again: it rots in about five minutes",wool: "sheep farms shear it; a weaver weaves it into cloth",- cloth: "citizens need it: only brought to streets with desirability 5 or more"+ cloth: "citizens need it: only brought to streets with desirability 5 or more",+ furniture: "burghers need it in their townhouses: a carpenter makes it from planks; only brought to streets fine enough for townhouses"}const groups: ReadonlyArray<ReadonlyArray<GoodId>> = [["wood", "planks", "stone", "ore", "tools"],["fish", "smoked", "wheat", "flour", "bread"],- ["wool", "cloth"]+ ["wool", "cloth", "furniture"]]stock.title = "Goods in the town's storage, and which way each is going · click for what the town makes and uses"const goodCells = new Map<GoodId, HTMLElement>()@@ -1116,15 +1117,16 @@ export const createHost = async (const needs = section("homes supplied","homes",- "A hungry home pays no taxes. Settlers need food (fish, smoked fish, or bread) from a market, and a cottage with bread besides pays half again; a visit feeds a home a fish or a loaf for every four residents, so a citizens' home eats twice what a cottage does and a townhouse three times; citizens and burghers need bread, cloth, and faith. Cloth is only brought to streets with desirability 5 or more. Fish rots in about three minutes and bread in five; a granary keeps them five times as long."+ "A hungry home pays no taxes. Settlers need food (fish, smoked fish, or bread) from a market, and a cottage with bread besides pays half again; a visit feeds a home a fish or a loaf for every four residents, so a citizens' home eats twice what a cottage does and a townhouse three times; citizens and burghers need bread, cloth, and faith, and burghers furniture from a carpenter besides. Cloth is only brought to streets with desirability 5 or more, furniture to streets of 12 or more. Fish rots in about three minutes and bread in five; a granary keeps them five times as long.")- const needIcons: Readonly<Record<"food" | "bread" | "cloth" | "faith", IconName>> = {+ const needIcons: Readonly<Record<"food" | "bread" | "cloth" | "faith" | "furniture", IconName>> = {food: "fish",bread: "bread",cloth: "cloth",- faith: "faith"+ faith: "faith",+ furniture: "furniture"}- const bars = (["food", "bread", "cloth", "faith"] as const).map((n) => {+ const bars = (["food", "bread", "cloth", "faith", "furniture"] as const).map((n) => {const line = el("div", "need")const label = el("span", "label")label.innerHTML = icon(needIcons[n], 16)@@ -1263,10 +1265,12 @@ export const createHost = async (? "every workplace has its crew": `${s.shortStaffed.length} short of workers: ${s.shortStaffed.slice(0, 4).map((w) => `${w.title} ${w.assigned}/${w.needed}${w.nobodyNear ? " (nobody within reach)" : ""}`).join(", ")}${s.shortStaffed.length > 4 ? ", …" : ""} · click the jobs counter to visit them`for (const b of bars) {- const share = s.homes > 0 ? s.needs[b.n] / s.homes : 0+ // Furniture is counted against the townhouses: no other home keeps it.+ const of = b.n === "furniture" ? Math.max(s.townhouses, s.needs.furniture) : s.homes+ const share = of > 0 ? s.needs[b.n] / of : 0b.fill.style.width = `${Math.round(share * 100)}%`- b.fill.className = `fill ${share < 0.34 ? "none" : share < 0.67 ? "low" : ""}`- b.value.textContent = `${s.needs[b.n]}/${s.homes}`+ b.fill.className = `fill ${of === 0 ? "" : share < 0.34 ? "none" : share < 0.67 ? "low" : ""}`+ b.value.textContent = `${s.needs[b.n]}/${of}`}larderLine.textContent = `${s.larder}`eatenLine.textContent = `${s.eaten} · ${s.rotted}`diff --git a/src/icons.ts b/src/icons.tsindex 76928be..4450a72 100644--- a/src/icons.ts+++ b/src/icons.ts@@ -23,6 +23,7 @@ const paths: Record<string, string> = {bread: `<path d="M2 10.5c0-3.5 3-5.5 6-5.5s6 2 6 5.5c0 1.5-1 2.5-2.5 2.5h-7C3 13 2 12 2 10.5z" fill="#e89a7c"/><path d="M5.5 7.5l1 2M8 6.5l1 2M10.5 7l1 2" fill="none" stroke-width="1"/>`,wool: `<circle cx="8" cy="8.5" r="5.5" fill="#eceee8"/><path d="M3.5 6.5c3 1 6 1 9-1M3 9.5c3.5 1.5 7 1.5 10-1M5 13c2.5.5 5 0 7-2" fill="none" stroke-width="1"/><path d="M12 12.5l2.5 1.5" fill="none"/>`,cloth: `<path d="M2.5 5.5l6-2.5 5 2.5-6 2.5z" fill="#c7aed6"/><path d="M2.5 5.5v6l5 2.5V8z" fill="#a37cbe"/><path d="M7.5 8v6l6-2.5v-6z" fill="#8a58a8"/>`,+ furniture: `<path d="M4.5 2.5h7v6h-7z" fill="#c9965f"/><path d="M6 4h4M6 6h4" fill="none" stroke-width="1"/><path d="M3.5 8.5h9v2h-9z" fill="#9a6b3f"/><path d="M4.5 10.5v4M11.5 10.5v4" fill="none" stroke-width="1.6"/>`,// ── The town ──coins: `<ellipse cx="8" cy="11.5" rx="5" ry="2" fill="#e3c25a"/><path d="M3 11.5v-2c0 1.1 2.2 2 5 2s5-.9 5-2v2" fill="#d6ae2e"/><ellipse cx="8" cy="9.5" rx="5" ry="2" fill="#f0d98a"/><path d="M3 9.5v-2c0 1.1 2.2 2 5 2s5-.9 5-2v2" fill="#d6ae2e"/><ellipse cx="8" cy="7.5" rx="5" ry="2" fill="#f5e3a6"/><ellipse cx="8" cy="7.5" rx="2" ry=".7" fill="none" stroke-width="1"/>`,settlers: `<circle cx="8" cy="4.5" r="2.3" fill="#f5f6f2"/><path d="M3.5 14c0-3.5 2-5.5 4.5-5.5s4.5 2 4.5 5.5z" fill="#e6c3b2"/>`,diff --git a/src/map-lab/map.ts b/src/map-lab/map.tsindex db55f8c..155495f 100644--- a/src/map-lab/map.ts+++ b/src/map-lab/map.ts@@ -133,6 +133,7 @@ const quarter: Array<[string, number, number]> = [["granary", -9.5, 1],["smokehouse", 10, 1],["hospital", 9.5, -11],+ ["carpenter", 14.5, -11],["park-sample", 2.5, -8],["park-lamp", -13.5, -8],["park-statue", 9.5, -8],diff --git a/src/places.ts b/src/places.tsindex 978aaa3..d02b845 100644--- a/src/places.ts+++ b/src/places.ts@@ -10,7 +10,7 @@ const streetOf: Readonly<Record<KindId, string>> = {townhall: "Hall", warehouse: "Warehouse", granary: "Granary", lumberjack: "Timber", forester: "Forest", quarry: "Quarry",mine: "Mine", fishery: "Fisher", smokehouse: "Smokehouse", sawmill: "Sawmill", smithy: "Smithy", farm: "Farm", mill: "Mill",bakery: "Baker", sheep: "Shepherd", weaver: "Weaver", market: "Market", chapel: "Chapel", firewatch: "Watch", healer: "Healer",- hospital: "Hospital", watchhouse: "Constable", builder: "Builder"+ hospital: "Hospital", watchhouse: "Constable", builder: "Builder", carpenter: "Joiner"}const suffixes = ["Lane", "Street", "Row", "Way", "Close", "Walk"] as constdiff --git a/src/present.ts b/src/present.tsindex c2d8ca7..2c19716 100644--- a/src/present.ts+++ b/src/present.ts@@ -340,7 +340,7 @@ let hungryUntil = 0const 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+const needIcons = { food: "food", bread: "bread", cloth: "cloth", faith: "faith", furniture: "furniture" } as constconst appealColor = (v: number) =>v >= home.tiers[3].appeal ? 0x1f4f8f : v >= home.tiers[2].appeal ? GOOD : v >= 0 ? 0xc6d4e4 : v > home.squalid ? 0xeaa26a : BAD@@ -442,7 +442,7 @@ export const Interact = Game.System(const homesWorth = (at: ReadonlyArray<Point>) => {if (at.length === 0) return ""const standing = houses.filter((row) => !row.data.closed.present).reduce((n, row) => n + row.data.house.get().residents, 0)- const fed = { tier: 1 as Tier, food: 1, bread: 0, cloth: 0, faith: 0, residents: home.tiers[1].residents }+ const fed = { tier: 1 as Tier, food: 1, bread: 0, cloth: 0, faith: 0, furniture: 0, residents: home.tiers[1].residents }let people = 0const pays = at.reduce((sum, c) => {const d = appealAt(cells, c.x, c.y), residents = capacity(fed, approval, d, undefined, rates.settlers)@@ -861,7 +861,7 @@ export const Interact = Game.System(/** What the town has of each provision, in storage and on market shelves. */const inTown = (): InTown => {const stock = resources.stock.get()- const sum = { fish: stock.fish, smoked: stock.smoked, bread: stock.bread, cloth: stock.cloth }+ const sum = { fish: stock.fish, smoked: stock.smoked, bread: stock.bread, cloth: stock.cloth, furniture: stock.furniture }for (const { data } of buildings) {const inv = maybe(data.inventory)if (!inv || maybe(data.service)?.service !== "goods" || data.site.present || data.rising.present) continue@@ -869,6 +869,7 @@ export const Interact = Game.System(sum.smoked += inv.stock.smokedsum.bread += inv.stock.breadsum.cloth += inv.stock.cloth+ sum.furniture += inv.stock.furniture}return sum}@@ -945,7 +946,7 @@ export const Interact = Game.System(const needs: Array<Line> = []const nowNeeds = new Set<Need>(tier.needs)const growNeeds = new Set<Need>(nextTier ? home.tiers[nextTier].needs : [])- for (const n of ["food", "bread", "cloth", "faith"] as const) {+ for (const n of ["food", "bread", "cloth", "faith", "furniture"] as const) {if (!nowNeeds.has(n) && !growNeeds.has(n)) continueif (met(h, n)) {needs.push({ icon: needIcons[n], label: needTitle[n], value: "✓", tone: "ok" })@@ -1506,7 +1507,8 @@ export const Interact = Game.System(admin: ledger.admin,net,homes: census.homes,- needs: { food: census.food, bread: census.bread, cloth: census.cloth, faith: census.faith },+ needs: { food: census.food, bread: census.bread, cloth: census.cloth, faith: census.faith, furniture: census.furniture },+ townhouses: houses.filter(({ data }) => data.house.get().tier === 3).length,policy: rates,stock,prices: resources.market.get().prices,diff --git a/src/rules/explain.ts b/src/rules/explain.tsindex 8811846..0bdd734 100644--- a/src/rules/explain.ts+++ b/src/rules/explain.ts@@ -7,7 +7,7 @@*/import type { Need, Tier } from "../content.ts"import { shippedRules, type Rules } from "./config.ts"-import { kept as keptBy, met, wantsCitizenGoods, type Needs } from "./households.ts"+import { kept as keptBy, met, wantsBurgherGoods, wantsCitizenGoods, type Needs } from "./households.ts"export interface Part {readonly label: string@@ -24,6 +24,7 @@ export interface InTown {readonly smoked: numberreadonly bread: numberreadonly cloth: number+ readonly furniture: number}/** Whether a walker of each kind can reach the home at all: a market's (or the town hall's) with provisions, and a chapel's. */export interface Served {@@ -84,6 +85,13 @@ export const whyUnmet = (need: Need, h: Needs, street: Street, inTown: InTown, sif (!served.faith) return noWalker("chapel", rules)return "the chapel's walker has not passed lately"}+ case "furniture": {+ if (!wantsBurgherGoods(h, street.desirability, rules))+ return `furniture is not brought here: the street is at ${signed(street.desirability)} and a townhouse needs ${rules.home.tiers[3].appeal}${against(street.parts) ? ` (${against(street.parts)})` : ""}`+ if (!served.goods) return noWalker("market", rules)+ if (inTown.furniture === 0) return "the town has no furniture: a carpenter makes it from planks"+ return "the market's walker has not passed with furniture lately"+ }}}diff --git a/src/rules/guide.ts b/src/rules/guide.tsindex b742ff7..6cfa4ed 100644--- a/src/rules/guide.ts+++ b/src/rules/guide.ts@@ -465,6 +465,18 @@ export const guideSteps: ReadonlyArray<GuideStep> = [when: (f) => f.poorStreet,done: (f) => f.finerHomes > 0},+ {+ id: "carpenter",+ chapter: "Growing citizens",+ action: "Build a carpenter: it makes furniture from planks.",+ why: "Burghers live in townhouses, and a townhouse wants furniture: two pieces to rise to one, and a fresh piece from the market now and then to stay one. Townhouses pay the most and hold the most people.",+ goal: "a carpenter stands",+ asks: ["carpenter"],+ focus: "hall",+ when: (f) => f.citizens >= 20 && f.finerHomes >= 3,+ done: (f) => has(f, "carpenter"),+ waiting: rising("carpenter")+ },{id: "healer",chapter: "Keeping it standing",diff --git a/src/rules/households.ts b/src/rules/households.tsindex ae7e235..fc3020b 100644--- a/src/rules/households.ts+++ b/src/rules/households.ts@@ -7,6 +7,7 @@ export interface Needs {readonly bread: numberreadonly cloth: numberreadonly faith: number+ readonly furniture: number}export const met = (h: Needs, need: Need): boolean => h[need] > 0@@ -64,16 +65,17 @@ export const kept = (r: { readonly fire: number; readonly health: number; readon* The tier a home settles into: settlers whose every citizens' need is met,* on a street desirable enough, become citizens; citizens with a street* nicer still and all three services calling become burghers in a- * townhouse. A home that loses its staple (bread: fish will not do), or+ * townhouse once furnished. A home that loses its staple (bread: fish will not do), or* more than one of its needs, or whose street falls below its tier, steps- * back down.+ * back down; a townhouse whose furniture has worn out is a citizens' home+ * again.*/export const tierFor = (h: Needs, desirability: number, r: { readonly fire: number; readonly health: number; readonly order: number }, rules: Rules = shippedRules): Tier => {const fits = (tier: Tier) => desirability >= rules.home.tiers[tier].appealif (h.tier === 1) return satisfaction(h, 2, rules) === 1 && fits(2) ? 2 : 1if (satisfaction(h, h.tier, rules) < 2 / 3 || !met(h, rules.home.staple) || !fits(2)) return 1if (h.tier === 2) return satisfaction(h, 3, rules) === 1 && fits(3) && kept(r, rules) ? 3 : 2- return fits(3) && kept(r, rules) ? 3 : 2+ return fits(3) && kept(r, rules) && met(h, "furniture") ? 3 : 2}/** Coins a minute the town hall's administration costs for `residents` people in its homes, less the share a finer hall `saves`. */@@ -109,7 +111,7 @@ export const taxOf = (h: Needs & { readonly residents: number }, rates: Rates, r: 0/** What the same home would pay with every need met and bread on the table: the money a town leaves on the table. */export const suppliedTaxOf = (h: Needs & { readonly residents: number }, rates: Rates, rules: Rules = shippedRules, desirability = 0): number =>- taxOf({ ...h, food: 1, bread: 1, cloth: 1, faith: 1 }, rates, rules, desirability)+ taxOf({ ...h, food: 1, bread: 1, cloth: 1, faith: 1, furniture: 1 }, rates, rules, desirability)export const refreshLevel = (need: Need, rules: Rules = shippedRules) => rules.home.lasts[need] / 2export const lowNeed = (left: number, need: Need, rules: Rules = shippedRules) => left < refreshLevel(need, rules)@@ -119,12 +121,15 @@ export const mealRate = (winter: boolean) => (mealDecay(0, winter) + mealDecay(1type Mutable<T> = { -readonly [K in keyof T]: T[K] }export const ageNeeds = <T extends Needs & { readonly clock: number }>(h: T, eat: number): Mutable<T> => ({...h, clock: h.clock + 1, food: Math.max(0, h.food - eat), bread: Math.max(0, h.bread - eat),- cloth: Math.max(0, h.cloth - 1), faith: Math.max(0, h.faith - 1)+ cloth: Math.max(0, h.cloth - 1), faith: Math.max(0, h.faith - 1), furniture: Math.max(0, h.furniture - 1)})/** Citizen goods also reach settlers whose neighbourhood permits promotion. */export const wantsCitizenGoods = (house: Needs, desirability: number, rules: Rules = shippedRules) =>house.tier >= 2 || desirability >= rules.home.tiers[2].appeal+/** Furniture goes to townhouses, and to citizens on a street fine enough for one. */+export const wantsBurgherGoods = (house: Needs, desirability: number, rules: Rules = shippedRules) =>+ house.tier >= 3 || (house.tier === 2 && desirability >= rules.home.tiers[3].appeal)/** Fish or loaves a home eats at a visit: one for every `home.perMeal` residents, rounded up, and at least one. */export const mealsOf = (h: { readonly residents: number }, rules: Rules = shippedRules): number => Math.max(1, Math.ceil(h.residents / rules.home.perMeal))@@ -139,7 +144,7 @@ export const mealsOf = (h: { readonly residents: number }, rules: Rules = shippe* from the basket's surplus (more than half of it left), so the citizens* further along the walk are not left without. A home fed only part of* its meal is fed for that part of the time. Cloth goes only where- * citizens could live.+ * citizens could live, furniture only where burghers could.*/export const serveGoods = <T extends Needs & { readonly residents: number }>(house: T, available: Readonly<Record<GoodId, number>>, rules: Rules = shippedRules, desirability = 0) => {const h = { ...house } as Mutable<T>, basket = { ...available }@@ -170,6 +175,9 @@ export const serveGoods = <T extends Needs & { readonly residents: number }>(houif (citizens && lowNeed(h.cloth, "cloth", rules) && basket.cloth > 0) {basket.cloth -= 1; h.cloth = rules.home.lasts.cloth}+ if (wantsBurgherGoods(h, desirability, rules) && lowNeed(h.furniture, "furniture", rules) && basket.furniture > 0) {+ basket.furniture -= 1; h.furniture = rules.home.lasts.furniture+ }return { house: h, basket, eaten }}diff --git a/src/rules/worth.ts b/src/rules/worth.tsindex c7a9729..f5700d2 100644--- a/src/rules/worth.ts+++ b/src/rules/worth.ts@@ -58,7 +58,7 @@ export const producers = (rules: Rules = shippedRules): Array<ProducerWorth> =>// ── Chains: what a unit of a good a minute takes, from the land up ──────-const needIds: ReadonlyArray<Need> = ["food", "bread", "cloth", "faith"]+const needIds: ReadonlyArray<Need> = ["food", "bread", "cloth", "faith", "furniture"]/** The needs a good meets when a walker hands it to a home: every food meets food; a good named for a need meets it. */export const meets = (good: GoodId): ReadonlyArray<Need> => [@@ -143,12 +143,13 @@ export const promotionCost = (tier: Tier, rules: Rules = shippedRules): number =export const homeWorth = (tier: Tier, rules: Rules = shippedRules): HomeWorth => {const t = rules.home.tiers[tier], residents = t.residents- const needs = { food: 1, bread: tier >= 2 ? 1 : 0, cloth: tier >= 2 ? 1 : 0, faith: tier >= 2 ? 1 : 0 }+ const needs = { food: 1, bread: tier >= 2 ? 1 : 0, cloth: tier >= 2 ? 1 : 0, faith: tier >= 2 ? 1 : 0, furniture: tier >= 3 ? 1 : 0 }const tax = taxOf({ tier, residents, ...needs }, { settlers: 100, citizens: 100 }, rules)const seconds = (ticks: number) => ticks * rules.stepSecondsconst meals = mealsOf({ residents }, rules) * 60 / seconds(rules.home.lasts.food)const staple = tier >= 2 ? rules.goods.bread.price : rules.goods.fish.priceconst eats = meals * staple + (tier >= 2 ? (60 / seconds(rules.home.lasts.cloth)) * rules.goods.cloth.price : 0)+ + (tier >= 3 ? (60 / seconds(rules.home.lasts.furniture)) * rules.goods.furniture.price : 0)const below = tier > 1 ? homeWorth((tier - 1) as Tier, rules) : nullconst cost = tier === 1 ? costWorth(rules.home.cost as Kind["cost"], rules) : promotionCost(tier, rules)const net = tax - eats, gain = below ? net - below.net : netdiff --git a/src/save.ts b/src/save.tsindex a6d9b15..543ca3e 100644--- a/src/save.ts+++ b/src/save.ts@@ -30,7 +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 and its upgrades as the first.+ * from 8, its water as never fished, its upgrades as the first, and no+ * furniture anywhere yet.* Anything else is left to the world's own validation.*/const carry = (version: number, world: unknown): unknown | null => {@@ -45,6 +46,26 @@ const carry = (version: number, world: unknown): unknown | null => {const upgraded = e.components?.["Town/Upgraded"]if (upgraded && typeof upgraded === "object" && !("level" in upgraded)) e.components!["Town/Upgraded"] = { level: 1 }}+ // From 8 too, furniture: none of it anywhere, stores and markets that take it, homes and the census without it.+ const furnish = (o: unknown) => (o && typeof o === "object" && !("furniture" in o) ? { ...o, furniture: 0 } : o)+ for (const e of Array.isArray(w.entities) ? w.entities : []) {+ const c = e.components+ if (!c) continue+ for (const [name, field] of [["Town/Site", "owed"], ["Town/Works", "owed"], ["Town/Inventory", "stock"], ["Town/Roam", "basket"]] as const) {+ const v = c[name] as Record<string, unknown> | undefined+ if (v && typeof v === "object") c[name] = { ...v, [field]: furnish(v[field]) }+ }+ if (c["Town/House"]) c["Town/House"] = furnish(c["Town/House"])+ 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))))+ inventory.accepts = [...inventory.accepts, "furniture"]+ }+ if (r["Town/Census"]) r["Town/Census"] = furnish(r["Town/Census"])+ const market = r["Town/Market"] as { prices?: unknown } | undefined+ if (market && typeof market === "object") r["Town/Market"] = { ...market, prices: furnish(market.prices) }+ const loads = (r["Town/Policy"] as { loads?: Record<string, unknown> } | undefined)?.loads+ if (loads && typeof loads === "object" && !("furniture" in loads)) loads.furniture = TRADE_LOADif (version === 8) return wconst fate = r["Town/Fate"] as Record<string, unknown> | undefinedif (fate && typeof fate === "object" && !("rank" in fate)) {diff --git a/src/schema.ts b/src/schema.tsindex c4642aa..857a092 100644--- a/src/schema.ts+++ b/src/schema.ts@@ -33,7 +33,7 @@ const service = Decode.literal(...serviceIds)/** A count of every good. */const amounts = Decode.struct({wood: integer, planks: integer, stone: integer, ore: integer, tools: integer, fish: integer, smoked: integer,- wheat: integer, flour: integer, bread: integer, wool: integer, cloth: integer+ wheat: integer, flour: integer, bread: integer, wool: integer, cloth: integer, furniture: integer})export const statuses = ["building", "idle", "working", "starved", "blocked", "unstaffed", "unconnected", "paused"] as const@@ -73,6 +73,7 @@ export const House = Descriptor.ConstructedComponent(Decode.struct({bread: integer,cloth: integer,faith: integer,+ furniture: integer,clock: integer}))("Town/House")@@ -211,6 +212,7 @@ export const Census = Descriptor.ConstructedResource(Decode.struct({bread: integer,cloth: integer,faith: integer,+ furniture: integer,/** Homes sick, and homes and buildings on fire, right now. */sick: integer,burning: integerdiff --git a/src/sim/index.ts b/src/sim/index.tsindex bc9c6bb..c1c534e 100644--- a/src/sim/index.ts+++ b/src/sim/index.ts@@ -63,7 +63,7 @@ export const blankResources = () => ({Rng: 0x5eed,Treasury: { coins: 0 },Ledger: { taxes: 0, trade: 0, upkeep: 0, admin: 0 },- Census: { homes: 0, settlers: 0, citizens: 0, burghers: 0, jobs: 0, employed: 0, food: 0, bread: 0, cloth: 0, faith: 0, sick: 0, burning: 0 },+ 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 },Policy: { settlers: 100, citizens: 100, sells: [], buys: [], reserve: 25, loads: amounts(Object.fromEntries(goodIds.map((g) => [g, TRADE_LOAD]))) },Charter: { ...defaultCharter(0), founded: 0, winters: [] as Array<"none" | "mild" | "normal" | "hard"> },Land: { mask: "", cells: 0 },diff --git a/src/sim/logistics.ts b/src/sim/logistics.tsindex 558af33..7202728 100644--- a/src/sim/logistics.ts+++ b/src/sim/logistics.ts@@ -1,5 +1,5 @@import { transport } from "../rules/config.ts"-import { wantsCitizenGoods } from "../rules/households.ts"+import { wantsBurgherGoods, wantsCitizenGoods } from "../rules/households.ts"import { appealAt } from "../appeal.ts"import { preferDelivery } from "../rules/transport.ts"/**@@ -115,12 +115,18 @@ export const Dispatch = Game.System(const service = maybe(data.service)?.serviceif (service === "goods") {const roads = reach(grid, [ds[0]!]), range = maybe(data.service)!.range- const citizenDistrict = queries.homes.each().some(({ data: h }) => {+ let citizenDistrict = false, burgherDistrict = false+ for (const { data: h } of queries.homes.each()) {const tile = h.tile.get(), found = nearest(roads, doors(grid, tile))- return found !== null && found.distance < range && wantsCitizenGoods(h.house.get(), appealAt(resources.appeal.get().cells, tile.x, tile.y), rules)- })+ if (found === null || found.distance >= range) continue+ const desirability = appealAt(resources.appeal.get().cells, tile.x, tile.y)+ citizenDistrict ||= wantsCitizenGoods(h.house.get(), desirability, rules)+ burgherDistrict ||= wantsBurgherGoods(h.house.get(), desirability, rules)+ if (burgherDistrict) break+ }for (const g of provisions) {if (g === "cloth" && !citizenDistrict) continue+ if (g === "furniture" && !burgherDistrict) continueconst cap = Math.min(inventory.cap, rules.transport.basket)wants.push({ id: entity.id, doors: ds, good: g, site: false,want: () => cap - inventory.stock[g] - inbound(entity.id, g), fill: () => (inventory.stock[g] + inbound(entity.id, g)) / cap })diff --git a/src/sim/town.ts b/src/sim/town.tsindex 72b5dc3..d66aa0f 100644--- a/src/sim/town.ts+++ b/src/sim/town.ts@@ -207,7 +207,7 @@ export const TakeCensus = Game.System(let citizens = 0let burghers = 0let sick = 0- const needs = { food: 0, bread: 0, cloth: 0, faith: 0 }+ const needs = { food: 0, bread: 0, cloth: 0, faith: 0, furniture: 0 }for (const { data } of queries.homes.each()) {const h = data.house.get()homes += 1@@ -215,7 +215,7 @@ export const TakeCensus = Game.System(else citizens += h.residentsif (h.tier === 3) burghers += h.residentsif (data.sick.present) sick += 1- for (const n of ["food", "bread", "cloth", "faith"] as const) if (met(h, n)) needs[n] += 1+ for (const n of ["food", "bread", "cloth", "faith", "furniture"] as const) if (met(h, n)) needs[n] += 1}let jobs = 0let employed = 0diff --git a/src/ui.ts b/src/ui.tsindex c99bcdc..8f7968b 100644--- a/src/ui.ts+++ b/src/ui.ts@@ -216,7 +216,9 @@ export interface Stats {readonly net: numberreadonly homes: number/** Homes with each need met. */- readonly needs: { readonly food: number; readonly bread: number; readonly cloth: number; readonly faith: number }+ readonly needs: { readonly food: number; readonly bread: number; readonly cloth: number; readonly faith: number; readonly furniture: number }+ /** Homes that are townhouses (the ones that keep furniture). */+ readonly townhouses: numberreadonly policy: {readonly settlers: numberreadonly citizens: numberdiff --git a/test/balance-model.test.ts b/test/balance-model.test.tsindex 4d42af7..5b7f397 100644--- a/test/balance-model.test.ts+++ b/test/balance-model.test.ts@@ -141,7 +141,7 @@ test("the mathematical plan reaches citizens through ordinary game construction"test("promotion-aware goods preserve cloth and feed an eligible settler bread before food expires", () => {- const rules = resolveRules(), house = { tier: 1 as const, residents: 4, food: rules.home.lasts.food, bread: 0, cloth: 0, faith: 0 }+ const rules = resolveRules(), house = { tier: 1 as const, residents: 4, food: rules.home.lasts.food, bread: 0, cloth: 0, faith: 0, furniture: 0 }const eligible = serveGoods(house, amounts({ bread: 2, cloth: 2, fish: 2 }), rules, rules.home.tiers[2].appeal)assert(eligible.house.bread > 0 && eligible.house.cloth > 0)const worker = serveGoods({ ...house, food: 0 }, amounts({ bread: 2, cloth: 2, fish: 2 }), rules, 0)@@ -154,7 +154,7 @@ test("promotion-aware goods preserve cloth and feed an eligible settler bread be})test("a visit feeds a home by its residents: a cottage one meal, a citizens' home two, a townhouse three", () => {- const rules = resolveRules(), hungry = { food: 0, bread: 0, cloth: 0, faith: 0 }+ const rules = resolveRules(), hungry = { food: 0, bread: 0, cloth: 0, faith: 0, furniture: 0 }const cottage = serveGoods({ ...hungry, tier: 1 as const, residents: 4 }, amounts({ fish: 10 }), rules, 0)assert.equal(cottage.eaten, 1)assert.equal(cottage.basket.fish, 9)@@ -171,7 +171,7 @@ test("a visit feeds a home by its residents: a cottage one meal, a citizens' hom})test("taxes above 100% empty homes directly, settlers sooner, so the most a rate brings in comes before the top", () => {- const rules = resolveRules(), fed = { tier: 1 as const, residents: 4, food: 1, bread: 0, cloth: 0, faith: 0 }+ const rules = resolveRules(), fed = { tier: 1 as const, residents: 4, food: 1, bread: 0, cloth: 0, faith: 0, furniture: 0 }assert.equal(taxRoom(100, 1, rules), 1)assert.equal(taxRoom(50, 1, rules), 1)assert(Math.abs(taxRoom(150, 1, rules) - 0.8) < 1e-9)@@ -191,7 +191,7 @@ test("administration: each more resident costs more, and about what a fed settleconst rules = resolveRules()// 80 cottages and 150 cottages, by their residents.assert(moreAdmin(320, 4, rules) > moreAdmin(80, 4, rules) * 2)- const cottage = taxOf({ tier: 1, residents: 4, food: 1, bread: 0, cloth: 0, faith: 0 }, { settlers: 100, citizens: 100 }, rules)+ const cottage = taxOf({ tier: 1, residents: 4, food: 1, bread: 0, cloth: 0, faith: 0, furniture: 0 }, { settlers: 100, citizens: 100 }, rules)assert(moreAdmin(320, 4, rules) > cottage * 0.5 && moreAdmin(320, 4, rules) < cottage, `${moreAdmin(320, 4, rules)} vs ${cottage}`)assert(moreAdmin(600, 4, rules) > cottage)})diff --git a/test/economy.test.ts b/test/economy.test.tsindex a1bef87..010bfb1 100644--- a/test/economy.test.ts+++ b/test/economy.test.ts@@ -61,7 +61,7 @@ test("foods that all meet a need cost within a few times one another to keep mak})test("a tier's staple is needed to keep the tier: a citizens' home fed fish instead of bread steps down", () => {- const fish = { tier: 2 as const, food: 100, bread: 0, cloth: 100, faith: 100 }+ const fish = { tier: 2 as const, food: 100, bread: 0, cloth: 100, faith: 100, furniture: 0 }assert.equal(tierFor(fish, rules.home.tiers[3].appeal, { fire: 0, health: 0, order: 0 }, rules), 1)})diff --git a/test/guide.test.ts b/test/guide.test.tsindex cab3737..decc9cf 100644--- a/test/guide.test.ts+++ b/test/guide.test.ts@@ -249,7 +249,7 @@ test("every step can be done, and a town that has done them all is told nothing"homes: 200, residents: 400, citizens: 200, finerHomes: 30, crown: { open: true, met: 3 }, trading: true, taxed: true, sawTown: true, sawHome: true, sawBuilding: true,roadToWater: true, rank: 3, upgraded: new Set<KindId>(["market"]), unreached: 5, winter: true, worn: true, poorStreet: true, approval: 40, net: -5, most: 120, stock: amounts({ tools: 0 })},- ["fishery", "lumberjack", "sawmill", "forester", "quarry", "granary", "firewatch", "builder", "market", "sheep", "weaver", "chapel", "farm", "mill", "bakery", "healer", "watchhouse", "mine", "smithy"]+ ["fishery", "lumberjack", "sawmill", "forester", "quarry", "granary", "firewatch", "builder", "market", "sheep", "weaver", "chapel", "farm", "mill", "bakery", "healer", "watchhouse", "mine", "smithy", "carpenter"])assert.deepEqual(guideDone(finished, none).sort(), [...all].sort())assert.equal(guideStep(finished, none), null)diff --git a/test/legibility.test.ts b/test/legibility.test.tsindex d774639..602192d 100644--- a/test/legibility.test.ts+++ b/test/legibility.test.ts@@ -19,8 +19,8 @@ import { capacity, streetRoom, streetTax, taxOf } from "../src/rules/households.import { approvalTarget, grudgeAfter } from "../src/rules/approval.ts"import { headless } from "../src/sim/headless.ts"-const settlers = { tier: 1 as const, residents: 4, food: 100, bread: 100, cloth: 0, faith: 100, clock: 0 }-const plenty: InTown = { fish: 20, smoked: 0, bread: 30, cloth: 188 }+const settlers = { tier: 1 as const, residents: 4, food: 100, bread: 100, cloth: 0, faith: 100, furniture: 0, clock: 0 }+const plenty: InTown = { fish: 20, smoked: 0, bread: 30, cloth: 188, furniture: 0 }const served: Served = { goods: true, faith: true }const quarryStreet: Street = { desirability: -4, parts: [{ label: "quarry", value: -6 }, { label: "chapel", value: 2 }] }@@ -42,7 +42,7 @@ test("on a street fit for citizens the reason moves to the walker or the store",assert.match(whyUnmet("cloth", settlers, fine, plenty, { goods: false, faith: true })!, new RegExp(`${kinds.market.service!.range} road cells`))assert.equal(whyUnmet("faith", settlers, fine, plenty, served), null)assert.match(whyUnmet("faith", { ...settlers, faith: 0 }, fine, plenty, { goods: true, faith: false })!, /no chapel walker/)- assert.match(whyUnmet("food", { ...settlers, food: 0 }, fine, { fish: 0, smoked: 0, bread: 0, cloth: 0 }, served)!, /no food in store/)+ assert.match(whyUnmet("food", { ...settlers, food: 0 }, fine, { fish: 0, smoked: 0, bread: 0, cloth: 0, furniture: 0 }, served)!, /no food in store/)assert.equal(streetShort(quarryStreet, 5), "−4 here, 5 needed: quarry −6")})diff --git a/tools/balance/model/project.ts b/tools/balance/model/project.tsindex 1034c29..3bcd210 100644--- a/tools/balance/model/project.ts+++ b/tools/balance/model/project.ts@@ -87,7 +87,7 @@ export const project = ({ rules, scenario }: Inputs, options: ProjectionOptions)const p = pending[i]!if (p.ready > second) continueconst id = nextId++- if (p.action.kind === "home") homes.push({ id, tile: p.action.tile, tier: 1, residents: 0, clock: 0, food: 0, bread: 0, cloth: 0, faith: 0, condition: rules.conditionMax, meters: { fire: 0, health: 0, order: 0 } })+ if (p.action.kind === "home") homes.push({ id, tile: p.action.tile, tier: 1, residents: 0, clock: 0, food: 0, bread: 0, cloth: 0, faith: 0, furniture: 0, condition: rules.conditionMax, meters: { fire: 0, health: 0, order: 0 } })else buildings.push({ id, kind: p.action.kind, tile: p.action.tile, paused: false, site: false, condition: rules.conditionMax, stock: amounts({}) })pending.splice(i, 1)}diff --git a/tools/balance/scenario.ts b/tools/balance/scenario.tsindex f2cd51b..3b8169b 100644--- a/tools/balance/scenario.ts+++ b/tools/balance/scenario.ts@@ -72,7 +72,7 @@ export const district = (name: string, tiers: ReadonlyArray<Tier>, kinds: Readonif (branch) for (const x of [15, 23, 31, 39, 47]) for (let y = 24; y <= 36; y++) if (y !== 30) roads.push({ x, y })const homeCells = Array.from({ length: 44 }, (_, i) => ({ x: 9 + i, y: 29, size: 1 })).filter((p) => !roads.some((r) => r.x === p.x && r.y === p.y))const houses = tiers.map((tier, i): ModelHome => ({ id: i + 1, tile: homeCells[i]!, tier, residents: rules.home.tiers[tier].residents,- food: rules.home.lasts.food, bread: tier >= 2 ? rules.home.lasts.bread : 0, cloth: tier >= 2 ? rules.home.lasts.cloth : 0, faith: tier >= 2 ? rules.home.lasts.faith : 0,+ food: rules.home.lasts.food, bread: tier >= 2 ? rules.home.lasts.bread : 0, cloth: tier >= 2 ? rules.home.lasts.cloth : 0, faith: tier >= 2 ? rules.home.lasts.faith : 0, furniture: tier >= 3 ? rules.home.lasts.furniture : 0,clock: 0, condition: rules.conditionMax, meters: { fire: 0, health: 0, order: 0 } }))const buildings: ModelBuilding[] = [], grid = new GridBuilder()for (const p of roads) grid.claim({ ...p, size: 1 }, -1, "road")diff --git a/tools/balance/verify/fixture.ts b/tools/balance/verify/fixture.tsindex cc2ef41..5760d12 100644--- a/tools/balance/verify/fixture.ts+++ b/tools/balance/verify/fixture.ts@@ -16,7 +16,7 @@ export const fixture = (scenario: Scenario, rules: Rules): Headless => {s.entities = []; s.relations = {}; s.nextEntity = Math.max(0, ...scenario.homes.map((h) => h.id), ...scenario.buildings.map((b) => b.id)) + 1const add = (components: Record<string, unknown>, id = s.nextEntity++) => s.entities.push({ id, components })for (const h of scenario.homes) add({- "Town/Tile": h.tile, "Town/House": { tier: h.tier, residents: h.residents, food: h.food, bread: h.bread, cloth: h.cloth, faith: h.faith, clock: h.clock },+ "Town/Tile": h.tile, "Town/House": { tier: h.tier, residents: h.residents, food: h.food, bread: h.bread, cloth: h.cloth, faith: h.faith, furniture: h.furniture, clock: h.clock },...Object.fromEntries(wearOf(rules).map(([d, v]) => [d.name, structuredClone(v)])),"Town/Risk": { ...h.meters, thefts: 0 }, "Town/Condition": { value: h.condition },...(h.sick ? { "Town/Sick": { left: rules.risk.health.lasts } } : {})