A town simulation in pale isometric line art, implemented with Ritmo ECS and PixiJs 3D
Read optional cells with cell.value()
SandroMaglione4f19f6decfbf
diff --git a/src/present.ts b/src/present.tsindex 633bd37..ebc28e4 100644--- a/src/present.ts+++ b/src/present.ts@@ -83,7 +83,6 @@ import {WalkerNodes,WalkerOf,Water,- maybe,type GridValue,type Status as StatusValue} from "./schema.ts"@@ -720,7 +719,7 @@ export const Interact = Game.System(for (const row of buildings) {const { data } = rowif (data.building.get().kind !== ui.upgrading || data.site.present || data.rising.present) continue- const kind = kinds[ui.upgrading], level = maybe(data.upgraded)?.level ?? 0, up = nextUpgrade(kind, level)+ const kind = kinds[ui.upgrading], level = data.upgraded.value()?.level ?? 0, up = nextUpgrade(kind, level)const tile = data.tile.get()if (!up) continueconst blocked = upgradeBlock(up, rank, { ranks })@@ -758,7 +757,7 @@ export const Interact = Game.System(} else if (tile) preview.plots.push({ ...tile, look: "picked" })if (row && tile) {showReach(tile, kinds[row.data.building.get().kind])- rangeOfKind(tile, kinds[row.data.building.get().kind], maybe(row.data.service)?.range)+ rangeOfKind(tile, kinds[row.data.building.get().kind], row.data.service.value()?.range)}}@@ -769,7 +768,7 @@ export const Interact = Game.System(sources = []for (const { data } of buildings) {if (data.site.present || data.rising.present) continue- const s = buildingSource(data.building.get().kind, data.tile.get(), undefined, maybe(data.upgraded)?.level ?? 0)+ const s = buildingSource(data.building.get().kind, data.tile.get(), undefined, data.upgraded.value()?.level ?? 0)if (s) sources.push(s)}for (const { data } of queries.trees.each()) sources.push(landSource("forest", data.tile.get()))@@ -779,7 +778,7 @@ export const Interact = Game.System(for (const { data } of ruins) sources.push(landSource("ruin", data.tile.get()))for (const { data } of houses) {if (data.site.present || data.rising.present) continue- if ((maybe(data.condition)?.value ?? CONDITION_MAX) < wear.worn) sources.push(landSource("worn", data.tile.get()))+ if ((data.condition.value()?.value ?? CONDITION_MAX) < wear.worn) sources.push(landSource("worn", data.tile.get()))const fine = data.closed.present ? null : homeSource(data.house.get().tier, data.tile.get())if (fine) sources.push(fine)}@@ -811,8 +810,8 @@ export const Interact = Game.System(/** Built homes no food walker reaches: reckoned only until a market stands, as it is a walk from each walker's door. */const unreachedHomes = () => {const walks = buildings- .filter((row) => maybe(row.data.service)?.service === "goods" && finished(row))- .map((row) => ({ way: reach(grid, doors(grid, row.data.tile.get())), range: maybe(row.data.service)!.range }))+ .filter((row) => row.data.service.value()?.service === "goods" && finished(row))+ .map((row) => ({ way: reach(grid, doors(grid, row.data.tile.get())), range: row.data.service.value()!.range }))return houses.filter((row) => {if (!finished(row)) return falseconst ds = doors(grid, row.data.tile.get())@@ -830,10 +829,10 @@ export const Interact = Game.System(const tick = resources.time.get().stepif (Math.floor(tick / 60) === wanted.at) return wanted.whyconst why = new Map<number, string>()- const standingRows = buildings.filter((r) => !r.data.site.present && !r.data.rising.present && !maybe(r.data.works))+ const standingRows = buildings.filter((r) => !r.data.site.present && !r.data.rising.present && !r.data.works.value())const homes = houses.filter((r) => !r.data.site.present && !r.data.rising.present && !r.data.closed.present)const full = (r: (typeof buildings)[number]) => {- const inv = maybe(r.data.inventory)+ const inv = r.data.inventory.value()return !!inv && goodIds.some((g) => inv.accepts.includes(g) && inv.stock[g] >= inv.cap * 0.9)}const near = (r: (typeof buildings)[number], tile: TileLike, range: number) => {@@ -845,9 +844,9 @@ export const Interact = Game.System(const millsWait = standingRows.some((r) => r.data.building.get().kind === "mill" && r.data.status.get() === "starved")const breadShort = resources.stock.get().bread < 5 && homes.some((r) => fishy(r, "bread"))for (const r of standingRows) {- const kind = kinds[r.data.building.get().kind], level = maybe(r.data.upgraded)?.level ?? 0, status = r.data.status.get()+ const kind = kinds[r.data.building.get().kind], level = r.data.upgraded.value()?.level ?? 0, status = r.data.status.get()if (!nextUpgrade(kind, level)) continue- const reach = maybe(r.data.service)?.range ?? 0+ const reach = r.data.service.value()?.range ?? 0const reason =kind.id === "townhall" ? (nextHall > level ? "the next rank asks for it" : full(r) ? "its shelves are full" : null): kind.id === "warehouse" ? (full(r) ? "its shelves are full" : null)@@ -856,7 +855,7 @@ export const Interact = Game.System(: kind.id === "bakery" ? (status === "working" && breadShort ? "homes go without bread while it works flat out" : null): kind.id === "market" ? (unreachedHomes() > 0 ? "homes lie beyond every food walker" : null): kind.id === "chapel" ? (homes.some((h) => fishy(h, "faith") && !near(r, h.data.tile.get(), reach)) ? "homes lie beyond its priest" : null)- : kind.id === "firewatch" ? (homes.some((h) => (maybe(h.data.risk)?.fire ?? 0) >= risk.warn && near(r, h.data.tile.get(), reach + 6)) ? "homes on its streets are at high fire risk" : null)+ : kind.id === "firewatch" ? (homes.some((h) => (h.data.risk.value()?.fire ?? 0) >= risk.warn && near(r, h.data.tile.get(), reach + 6)) ? "homes on its streets are at high fire risk" : null): nullif (reason) why.set(r.entity.id, reason)}@@ -872,7 +871,7 @@ export const Interact = Game.System(const describeBuilding = (row: (typeof buildings)[number]) => {const kind = kinds[row.data.building.get().kind]const status = row.data.status.get()- const site = maybe(row.data.site)+ const site = row.data.site.value()if (site) {const owed = (Object.entries(site.owed) as Array<[GoodId, number]>).filter(([, n]) => n > 0)const line: Line =@@ -900,15 +899,15 @@ export const Interact = Game.System(: undefined})}- const recipe = maybe(row.data.recipe)+ const recipe = row.data.recipe.value()if (recipe)work.push({ icon: recipe.output, label: "makes", value: recipe.input ? `${goods[recipe.input].title} → ${goods[recipe.output].title}` : goods[recipe.output].title })- const service = maybe(row.data.service)+ const service = row.data.service.value()if (service)work.push({icon: service.service === "goods" ? "trade" : service.service === "faith" ? "faith" : service.service === "repair" ? "repair" : service.service,label: "walkers out",- value: `${maybe(row.data.walkers)?.length ?? 0}`+ value: `${row.data.walkers.value()?.length ?? 0}`})// A provisions walker's building: what its walkers handed to homes over the last minute, which its shelf// alone cannot say (food leaves in the basket as soon as it comes; furniture mostly comes back).@@ -924,7 +923,7 @@ export const Interact = Game.System(: { icon: "people", label: "handed out, last minute", value: "nothing", tone: "dim", note: "no home on its walks needed what it had" })}- const inventory = maybe(row.data.inventory)+ const inventory = row.data.inventory.value()if (inventory) {const held = inventory.accepts.filter((g) => inventory.stock[g] > 0).map((g) => ({ good: g, count: inventory.stock[g] }))// A market's shelf is only what waits for the next walker.@@ -938,10 +937,10 @@ export const Interact = Game.System(: { icon: "tools", label: "tools", value: "none", tone: "bad", note: "half pace until one comes: a smithy makes them, or buy them in the town panel" })const running: Array<Line> = []- const level = maybe(row.data.upgraded)?.level ?? 0+ const level = row.data.upgraded.value()?.level ?? 0const upkeep = upkeepOf(kind, level)if (upkeep > 0) running.push({ icon: "upkeep", label: "upkeep", value: `${upkeep} coins a minute` })- const condition = maybe(row.data.condition)+ const condition = row.data.condition.value()if (condition)running.push({icon: "condition",@@ -950,7 +949,7 @@ export const Interact = Game.System(tone: condition.value < wear.worn ? "bad" : condition.value < wear.mend ? "warn" : "ok",note: condition.value < wear.worn ? "half pace, and it may fall: a builder's yard mends it" : condition.value < wear.mend ? "a builder's yard mends it as its builder passes" : undefined})- const r = maybe(row.data.risk)+ const r = row.data.risk.value()if (r)running.push({icon: "fire",@@ -987,8 +986,8 @@ export const Interact = Game.System(const stock = resources.stock.get()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+ const inv = data.inventory.value()+ if (!inv || data.service.value()?.service !== "goods" || data.site.present || data.rising.present) continuesum.fish += inv.stock.fishsum.smoked += inv.stock.smokedsum.bread += inv.stock.bread@@ -1004,7 +1003,7 @@ export const Interact = Game.System(const way = reach(grid, ds)const served = { goods: false, faith: false }for (const { data } of buildings) {- const service = maybe(data.service)+ const service = data.service.value()if (!service || data.site.present || data.rising.present || data.burning.present) continueif (service.service !== "goods" && service.service !== "faith") continueif (served[service.service]) continue@@ -1020,7 +1019,7 @@ export const Interact = Game.System(*/const describeHouse = (row: (typeof houses)[number]) => {const h = row.data.house.get()- const site = maybe(row.data.site)+ const site = row.data.site.value()const quiet = (summary: string, line: Line) => ({ h, summary, trouble: false, groups: [{ title: "household", icon: "homes", lines: [line] }] as Array<Group> })if (site) return quiet("being built", { icon: "planks", label: "builders", value: "waiting for its plank", tone: "warn" })if (row.data.closed.present)@@ -1031,9 +1030,9 @@ export const Interact = Game.System(const there = appealParts(appealSources(), tile)const desirability = appealAt(cells, tile.x, tile.y)const street: Street = { desirability, parts: there.parts }- const r = maybe(row.data.risk)+ const r = row.data.risk.value()const work = workOf(tile, h.tier)- const condition = maybe(row.data.condition)+ const condition = row.data.condition.value()const town = inTown()const served = servedAt(tile)const rate = h.tier === 1 ? rates.settlers : rates.citizens@@ -1098,7 +1097,7 @@ export const Interact = Game.System(else needs.push({ icon: "appeal", label: "street", value: signed(desirability), tone: "ok" })if (blocks.some((b) => b.what === "services")) needs.push({ icon: "order", label: "services", value: `for ${home.tiers[3].title}`, tone: "warn", ...told(servicesCause(r)) })// Rising is a rebuilding, paid at once from the treasury and the store, once.- const rebuilt = nextTier !== null && (maybe(row.data.rebuilt)?.tier ?? 1) >= nextTier+ const rebuilt = nextTier !== null && (row.data.rebuilt.value()?.tier ?? 1) >= nextTierconst short = nextTier && !rebuilt ? shortOf(home.tiers[nextTier].rise, resources.treasury.get().coins, resources.stock.get()) : nullif (nextTier)needs.push({@@ -1166,16 +1165,16 @@ export const Interact = Game.System(if (ui.tool === "upgrade") {} else if (hoveredBuilding) {const { kind, status, problem } = describeBuilding(hoveredBuilding)- const level = maybe(hoveredBuilding.data.upgraded)?.level ?? 0, works = maybe(hoveredBuilding.data.works)+ const level = hoveredBuilding.data.upgraded.value()?.level ?? 0, works = hoveredBuilding.data.works.value()const title = (upgradeAt(kind, level)?.title ?? kind.title).toLowerCase()preview.tooltip = ui.tool === "bulldoze"- ? `${title} · ${hoveredBuilding.data.hall.present ? "the town hall stays" : salvageFor(builtCost(kind, level), maybe(hoveredBuilding.data.site), works && { kind, ...works })}`+ ? `${title} · ${hoveredBuilding.data.hall.present ? "the town hall stays" : salvageFor(builtCost(kind, level), hoveredBuilding.data.site.value(), works && { kind, ...works })}`: `${title} · ${problem ?? status}${works ? ` · becoming ${anA(upgradeAt(kind, works.level)!.title.toLowerCase())}, ${Math.round(worksShare(works)! * 100)}% built` : ""}`} else if (hoveredHouse) {const h = hoveredHouse.data.house.get()const t = hoveredHouse.data.tile.get()preview.tooltip = ui.tool === "bulldoze"- ? `${tierHome[h.tier]} · ${salvageFor(home.cost, maybe(hoveredHouse.data.site))}`+ ? `${tierHome[h.tier]} · ${salvageFor(home.cost, hoveredHouse.data.site.value())}`: hoveredHouse.data.closed.present? `${tierHome[h.tier]} · closed`: `${tierHome[h.tier]} · ${h.residents} resident${h.residents === 1 ? "" : "s"} · desirability ${appealAt(cells, t.x, t.y)}${hoveredHouse.data.burning.present ? " · on fire!" : hoveredHouse.data.sick.present ? " · sick" : ""}`@@ -1208,9 +1207,9 @@ export const Interact = Game.System(const { kind, status, problem, state, groups } = describeBuilding(pickedBuilding)const standing = !pickedBuilding.data.site.present && !pickedBuilding.data.rising.presentconst pausable = kind.id !== "townhall" && standing- const level = maybe(pickedBuilding.data.upgraded)?.level ?? 0+ const level = pickedBuilding.data.upgraded.value()?.level ?? 0const now = upgradeAt(kind, level)- const works = maybe(pickedBuilding.data.works)+ const works = pickedBuilding.data.works.value()const up = works ? undefined : nextUpgrade(kind, level)const upgradeOffer = up && standing? { title: up.title, blurb: up.blurb, price: upgradePrice(up), cost: up.cost, changes: upgradeChanges(kind, level), needed: upgradesWanted().get(pickedBuilding.entity.id) ?? null,@@ -1241,7 +1240,7 @@ export const Interact = Game.System(groups,pausable,paused: pickedBuilding.data.paused.present,- salvage: salvageFor(builtCost(kind, level), maybe(pickedBuilding.data.site), works && { kind, ...works }),+ salvage: salvageFor(builtCost(kind, level), pickedBuilding.data.site.value(), works && { kind, ...works }),level,upgraded: level > 0,upgrade: upgradeOffer,@@ -1253,7 +1252,7 @@ export const Interact = Game.System(type: "house", id: pickedHouse.entity.id, cell: pickedHouse.data.tile.get(), tier: h.tier, summary, trouble, groups,closable: !pickedHouse.data.site.present && !pickedHouse.data.rising.present && !pickedHouse.data.burning.present,closed: pickedHouse.data.closed.present,- salvage: salvageFor(home.cost, maybe(pickedHouse.data.site))+ salvage: salvageFor(home.cost, pickedHouse.data.site.value())}} else if (pickedPark && picked) {ui.panel = {@@ -1342,7 +1341,7 @@ export const Interact = Game.System(}} else if (view === "fire" || view === "health" || view === "order") {for (const { entity, data } of standing(houses)) {- const r = maybe(data.risk)+ const r = data.risk.value()if (!r) continueconst struck = view === "fire" ? data.burning.present : view === "health" ? data.sick.present : r.thefts > 0const color = struck ? BAD : meterColor(r[view], RISK_MAX, risk.warn)@@ -1350,8 +1349,8 @@ export const Interact = Game.System(tints.set(entity.id, tintOf(color))}for (const { entity, data } of standing(buildings)) {- const service = maybe(data.service)?.service- const r = maybe(data.risk)+ const service = data.service.value()?.service+ const r = data.risk.value()if (service === view) {out.push({ ...data.tile.get(), color: MARK, alpha: 0.55, ring: true })tints.set(entity.id, TINT.mark)@@ -1363,13 +1362,13 @@ export const Interact = Game.System(}} else if (view === "condition") {for (const row of [...standing(houses), ...standing(buildings)]) {- const c = maybe(row.data.condition)+ const c = row.data.condition.value()if (!c) continueconst color = c.value < wear.worn ? BAD : c.value < wear.mend ? FAIR : GOODout.push({ ...row.data.tile.get(), color, alpha: 0.5 })tints.set(row.entity.id, tintOf(color))}- for (const { entity, data } of standing(buildings)) if (maybe(data.service)?.service === "repair") {+ for (const { entity, data } of standing(buildings)) if (data.service.value()?.service === "repair") {out.push({ ...data.tile.get(), color: MARK, alpha: 0.55, ring: true })tints.set(entity.id, TINT.mark)}@@ -1443,8 +1442,8 @@ export const Interact = Game.System(const { data } = rowif (data.site.present || data.rising.present) continueconst kind = kinds[data.building.get().kind]- const level = maybe(data.upgraded)?.level ?? 0- const works = maybe(data.works)+ const level = data.upgraded.value()?.level ?? 0+ const works = data.works.value()const from = works ? works.level - 1 : levelif (!nextUpgrade(kind, from)) continueconst k = `${kind.id}:${from}`@@ -1472,7 +1471,7 @@ export const Interact = Game.System(const due = new Map([...upgradesWanted()].filter(([id]) => {const row = buildings.find((b) => b.entity.id === id)const kind = row && kinds[row.data.building.get().kind]- const up = row && kind && nextUpgrade(kind, maybe(row.data.upgraded)?.level ?? 0)+ const up = row && kind && nextUpgrade(kind, row.data.upgraded.value()?.level ?? 0)if (!up || !kind || arrowed.has(kind.id) || upgradeBlock(up, rank, { ranks }) !== null || coinsNow < up.cost.coins) return falsearrowed.add(kind.id)return true@@ -1481,7 +1480,7 @@ export const Interact = Game.System(const [firstId, firstWhy] = [...due][0] ?? []const dueFirst = firstId === undefined ? undefined : buildings.find((b) => b.entity.id === firstId)if (dueFirst && !upgrades.some((u) => u.underway > 0)) {- const kind = kinds[dueFirst.data.building.get().kind], level = maybe(dueFirst.data.upgraded)?.level ?? 0+ const kind = kinds[dueFirst.data.building.get().kind], level = dueFirst.data.upgraded.value()?.level ?? 0const from = (upgradeAt(kind, level)?.title ?? kind.title).toLowerCase(), to = nextUpgrade(kind, level)!.title.toLowerCase()alerts.push({ tone: "hint", text: `${firstWhy}: the ${from} can become ${anA(to)}. {Tap|Click} it, under its gold arrow, to begin`, at: dueFirst.data.tile.get(), size: dueFirst.data.tile.get().size, id: dueFirst.entity.id })}@@ -1527,7 +1526,7 @@ export const Interact = Game.System(}const placedKinds = new Set(buildings.map(({ data }) => data.building.get().kind))const standingKinds = new Set(buildings.filter(({ data }) => !data.site.present && !data.rising.present).map(({ data }) => data.building.get().kind))- const wornRow = buildings.find((row) => finished(row) && !row.data.hall.present && (maybe(row.data.condition)?.value ?? CONDITION_MAX) < wear.mend)+ const wornRow = buildings.find((row) => finished(row) && !row.data.hall.present && (row.data.condition.value()?.value ?? CONDITION_MAX) < wear.mend)// A settlers' home with bread, cloth, and faith, kept from citizens only by its street.const poorRow = houses.find((row) => {const h = row.data.house.get()@@ -1578,9 +1577,9 @@ export const Interact = Game.System(rank: f.rank,upgraded: new Set(buildings.filter((row) => row.data.upgraded.present).map((row) => row.data.building.get().kind)),risk: {- fire: houses.some((row) => (maybe(row.data.risk)?.fire ?? 0) >= RISK_MAX * 0.35),- health: houses.some((row) => (maybe(row.data.risk)?.health ?? 0) >= RISK_MAX * 0.35),- order: houses.some((row) => (maybe(row.data.risk)?.order ?? 0) >= RISK_MAX * 0.35)+ fire: houses.some((row) => (row.data.risk.value()?.fire ?? 0) >= RISK_MAX * 0.35),+ health: houses.some((row) => (row.data.risk.value()?.health ?? 0) >= RISK_MAX * 0.35),+ order: houses.some((row) => (row.data.risk.value()?.order ?? 0) >= RISK_MAX * 0.35)},fewTrees: buildings.some((row) => {if (row.data.building.get().kind !== "lumberjack" || !finished(row)) return false@@ -1702,7 +1701,7 @@ export const Interact = Game.System(goals: goalsOf(charter,{ settlers: census.settlers, citizens: census.citizens, burghers: census.burghers, coins, net: steadyNet(resources.history.get().samples, net), approval: mood.approval,- hall: hallRow ? maybe(hallRow.data.upgraded)?.level ?? 0 : 0 },+ hall: hallRow ? hallRow.data.upgraded.value()?.level ?? 0 : 0 },undefined,f.rank),@@ -1934,28 +1933,28 @@ export const Animate = Game.System(const status = data.status.get()// An upgrade the town needs now, and can make (see `upgradesWanted`).const upgradable = services.ui.wanted.has(entity.id)- const recipe = maybe(data.recipe)- const walkers = maybe(data.walkers)?.length ?? 0- const worn = (maybe(data.condition)?.value ?? CONDITION_MAX) < wear.worn- const r = maybe(data.risk)+ const recipe = data.recipe.value()+ const walkers = data.walkers.value()?.length ?? 0+ const worn = (data.condition.value()?.value ?? CONDITION_MAX) < wear.worn+ const r = data.risk.value()services.buildingNodes.get(entity.id)?.update({alert: alertOf(r ? { fire: r.fire, health: 0, order: 0 } : undefined, false, worn),burning: data.burning.present,worn,effects: {- wear: 1-(maybe(data.condition)?.value??CONDITION_MAX)/CONDITION_MAX,+ wear: 1-(data.condition.value()?.value??CONDITION_MAX)/CONDITION_MAX,fireRisk: hazardStrength(r?.fire??0,risk.warn,RISK_MAX)},working: status === "working",tint: services.ui.tints.get(entity.id),problem: problemOf(kind, status) !== null,- build: buildOf(maybe(data.site), maybe(data.rising)),- beat: recipe ? recipe.made : maybe(data.service) ? walkers : 0,+ build: buildOf(data.site.value(), data.rising.value()),+ beat: recipe ? recipe.made : data.service.value() ? walkers : 0,doors: doorsOf(grid, data.tile.get()),- site: siteShare(maybe(data.site)),- level: maybe(data.upgraded)?.level ?? 0,- works: worksShare(maybe(data.works)),+ site: siteShare(data.site.value()),+ level: data.upgraded.value()?.level ?? 0,+ works: worksShare(data.works.value()),upgradable},dt,@@ -1964,24 +1963,24 @@ export const Animate = Game.System(}for (const { entity, data } of queries.houses.each()) {const tile = data.tile.get()- const worn = (maybe(data.condition)?.value ?? CONDITION_MAX) < wear.worn+ const worn = (data.condition.value()?.value ?? CONDITION_MAX) < wear.wornconst desirability = appealAt(cells, tile.x, tile.y)services.houseNodes.get(entity.id)?.update({tier: data.house.get().tier,- build: buildOf(maybe(data.site), maybe(data.rising)),+ build: buildOf(data.site.value(), data.rising.value()),doors: doorsOf(grid, tile),- site: siteShare(maybe(data.site)),- alert: data.site.present ? null : alertOf(maybe(data.risk), data.sick.present, worn),+ site: siteShare(data.site.value()),+ alert: data.site.present ? null : alertOf(data.risk.value(), data.sick.present, worn),burning: data.burning.present,worn,effects: {- wear: Math.max(desirability<0?0.55:0,1-(maybe(data.condition)?.value??CONDITION_MAX)/CONDITION_MAX),- fireRisk: hazardStrength(maybe(data.risk)?.fire??0,risk.warn,RISK_MAX),- health: hazardStrength(maybe(data.risk)?.health??0,risk.warn,RISK_MAX),- order: hazardStrength(maybe(data.risk)?.order??0,risk.warn,RISK_MAX),+ wear: Math.max(desirability<0?0.55:0,1-(data.condition.value()?.value??CONDITION_MAX)/CONDITION_MAX),+ fireRisk: hazardStrength(data.risk.value()?.fire??0,risk.warn,RISK_MAX),+ health: hazardStrength(data.risk.value()?.health??0,risk.warn,RISK_MAX),+ order: hazardStrength(data.risk.value()?.order??0,risk.warn,RISK_MAX),sick: Number(data.sick.present)},band: desirability < 0 ? "poor" : desirability >= home.tiers[2].appeal ? "fine" : "plain",@@ -1994,11 +1993,11 @@ export const Animate = Game.System(for (const { entity } of queries.ruins.each()) services.ruinNodes.get(entity.id)?.update(emphasis(entity.id))for (const { entity, data } of queries.walkers.each()) {const p = walkerAt(data.route.get())- const errand = maybe(data.errand)- const roam = maybe(data.roam)+ const errand = data.errand.value()+ const roam = data.roam.value()const load: Load = errand? { kind: "cart", good: errand.good, count: !errand.back || errand.count > 0 ? errand.count : 0 }- : maybe(data.rescue)+ : data.rescue.value()? { kind: "service", role: "firefighter" }: roam?.service === "fire"? { kind: "service", role: "watchman" }@@ -2073,7 +2072,7 @@ export const Stroll = Game.System(const waiting = ui.founding || (ui.stats !== null && ui.stats.fate.state !== "playing")const homes = queries.houses.each()- .filter(({ data }) => !maybe(data.site) && !maybe(data.rising))+ .filter(({ data }) => !data.site.value() && !data.rising.value()).map(({ data }) => ({ ...data.tile.get(), tier: data.house.get().tier, residents: data.house.get().residents }))townsfolk.folk.step(waiting ? 0 : services.clock.deltaSeconds * ui.speed, homes, resources.grid.get())}diff --git a/src/schema.ts b/src/schema.tsindex 745534d..08bfe96 100644--- a/src/schema.ts+++ b/src/schema.ts@@ -12,7 +12,6 @@* whole world snapshots to plain data and loads back checked.*/import { Clock as SimulationClock, Decode, Descriptor, Schema } from "@typeonce/ritmo"-import type { OptionalReadCell } from "@typeonce/ritmo/Query"import * as Random from "@typeonce/ritmo-math/Random"import type { NodeRegistry } from "@typeonce/ritmo-render"import { step } from "./content.ts"@@ -25,9 +24,6 @@ import type { Edit, UiValue } from "./ui.ts"export const Root = Schema.defineRoot("Town")-/** An optional query slot's value, or `undefined` when the entity lacks it. */-export const maybe = <T>(cell: OptionalReadCell<T>) => (cell.present ? cell.get() : undefined)-const integer = Decode.integerconst cell = Decode.struct({ x: integer, y: integer })const good = Decode.literal(...goodIds)diff --git a/src/sim/decay.ts b/src/sim/decay.tsindex a9baff6..52b2345 100644--- a/src/sim/decay.ts+++ b/src/sim/decay.ts@@ -11,7 +11,7 @@ import { ruinDraft } from "../archetypes.ts"import { foods, goodIds, stepsOf } from "../content.ts"import { counted, placeName } from "../places.ts"import { Ruin } from "../schema.ts"-import { Building, Burning, Charter, Chronicle, Condition, Game, Rules, House, Inventory, Pantry, Recipe, Rising, Rng, Site, Staff, Tile, Time, maybe } from "../schema.ts"+import { Building, Burning, Charter, Chronicle, Condition, Game, Rules, House, Inventory, Pantry, Recipe, Rising, Rng, Site, Staff, Tile, Time } from "../schema.ts"import { elapsed, write } from "./shared.ts"/** The pantry warns of rotting food at most this often. */@@ -57,7 +57,7 @@ export const Decay = Game.System(continue}const tile = data.tile.get()- const b = maybe(data.building)+ const b = data.building.value()commands.despawn(entity)commands.spawn(ruinDraft(tile, "collapsed"))write(@@ -76,7 +76,7 @@ export const Decay = Game.System(let rotted = 0for (const { data } of queries.shelves.each()) {const inv = data.inventory.get()- const keeps = kinds[maybe(data.building)?.kind ?? "townhall"].keeps ?? 1+ const keeps = kinds[data.building.value()?.kind ?? "townhall"].keeps ?? 1let stock = inv.stockfor (const g of goodIds) {const life = spoils[g]diff --git a/src/sim/edits.ts b/src/sim/edits.tsindex 9388f2c..84af2bf 100644--- a/src/sim/edits.ts+++ b/src/sim/edits.ts@@ -13,7 +13,7 @@ import { canPlace, cellsOf, GridBuilder, ownerAt, useAt } from "../grid.ts"import { inside } from "../iso.ts"import { generate } from "../mapgen.ts"import { Road, Water, Tree } from "../schema.ts"-import { Appeal, Building, Tile, Census, Charter, Chronicle, Crown, Fate, Fires, Game, Guide, Rules, History, House, Inventory, Land, Ledger, Market, maybe, Mood, Pantry, Park, Paved, Paused, Policy, Rising, Rng, Rock, Service, Site, Status, Stock, Storage, Time, TownHall, Toast, Treasury, Upgraded, Works, Edits, Selection } from "../schema.ts"+import { Appeal, Building, Tile, Census, Charter, Chronicle, Crown, Fate, Fires, Game, Guide, Rules, History, House, Inventory, Land, Ledger, Market, Mood, Pantry, Park, Paved, Paused, Policy, Rising, Rng, Rock, Service, Site, Status, Stock, Storage, Time, TownHall, Toast, Treasury, Upgraded, Works, Edits, Selection } from "../schema.ts"import { salvageOf, salvageText, withWorks } from "../rules/salvage.ts"import { elapsed, rollWinters, termTicks, TileRead, useOf, write } from "./shared.ts"import type { Rules as RuleInputs } from "../rules/config.ts"@@ -331,9 +331,9 @@ export const ApplyEdits = Game.System(// A building or a home: a fee, and part of its materials back (a site's, all of it).const built = queries.built.get(owner)if (built.ok && (built.value.data.building.present || built.value.data.house.present)) {- const b = maybe(built.value.data.building)- const own = salvageOf(b ? builtCost(kinds[b.kind], maybe(built.value.data.upgraded)?.level ?? 0) : home.cost, maybe(built.value.data.site)?.owed ?? null, rules)- const s = b ? withWorks(own, kinds[b.kind], maybe(built.value.data.works), rules) : own+ const b = built.value.data.building.value()+ const own = salvageOf(b ? builtCost(kinds[b.kind], built.value.data.upgraded.value()?.level ?? 0) : home.cost, built.value.data.site.value()?.owed ?? null, rules)+ const s = b ? withWorks(own, kinds[b.kind], built.value.data.works.value(), rules) : ownif (s.fee > 0 && coins < s.fee) {events.toast.emit(`Pulling it down costs ${s.fee} coins`)break@@ -433,7 +433,7 @@ export const ApplyEdits = Game.System(if (!row?.ok) breakconst { data } = row.valueconst kind = kinds[data.building.get().kind]- const level = maybe(data.upgraded)?.level ?? 0+ const level = data.upgraded.value()?.level ?? 0const up = nextUpgrade(kind, level)if (!up || data.works.present || begun.has(row.value.entity.id) || data.site.present || data.rising.present) breakconst blocked = upgradeBlock(up, resources.fate.get().rank, rules)diff --git a/src/sim/hazards.ts b/src/sim/hazards.tsindex 2891f07..35ec923 100644--- a/src/sim/hazards.ts+++ b/src/sim/hazards.ts@@ -18,7 +18,7 @@ import { goodIds, risk, upgradeAt, type GoodId } from "../content.ts"import { doors, nearest, pathTo, reach, useAt } from "../grid.ts"import { counted, placeName, type Landmark } from "../places.ts"import type { Point } from "../iso.ts"-import { Appeal, Building, Burning, Charter, Chronicle, Condition, Figure, Fires, Game, Rules, Grid, House, Inventory, Mood, Park, Paused, Paved, Rescue, Rising, Risk, Rng, Road, Route, Ruin, Service, Sick, Site, Staff, Storage, Tile, Time, Tree, Treasury, Upgraded, WalkerOf, Water, maybe } from "../schema.ts"+import { Appeal, Building, Burning, Charter, Chronicle, Condition, Figure, Fires, Game, Rules, Grid, House, Inventory, Mood, Park, Paused, Paved, Rescue, Rising, Risk, Rng, Road, Route, Ruin, Service, Sick, Site, Staff, Storage, Tile, Time, Tree, Treasury, Upgraded, WalkerOf, Water } from "../schema.ts"import { elapsed, seasonAt, write } from "./shared.ts"// ── Desirability ──────────────────────────────────────────────────────────@@ -47,7 +47,7 @@ export const Appraise = Game.System(if (!every(resources.time.get(), appeal.every) && resources.appeal.get().cells.length > 0) returnconst sources: Array<AppealSource> = []for (const { data } of queries.buildings.each()) {- const s = buildingSource(data.building.get().kind, data.tile.get(), rules, maybe(data.upgraded)?.level ?? 0)+ const s = buildingSource(data.building.get().kind, data.tile.get(), rules, data.upgraded.value()?.level ?? 0)if (s) sources.push(s)}for (const { data } of queries.trees.each()) sources.push(landSource("forest", data.tile.get(), rules))@@ -140,7 +140,7 @@ export const Hazards = Game.System(const rows = queries.cared.each()const hot = rows.filter(({ data }) => {- const b = maybe(data.building)+ const b = data.building.value()return b !== undefined && kinds[b.kind].hot === true && !data.burning.present}).map(({ data }) => data.tile.get())const dusty = landmarks.filter((l) => kinds[l.kind].dusty)@@ -163,10 +163,10 @@ export const Hazards = Game.System(const { data } = rowif (data.burning.present) continueconst tile = data.tile.get()- const h = maybe(data.house)+ const h = data.house.value()// A closed home has nobody in it to fall sick, steal, or knock over a lamp.if (h && data.paused.present) continue- const b = maybe(data.building)+ const b = data.building.value()const r = { ...data.risk.get() }const increments = riskIncrements({tile, condition: data.condition.get().value, desirability: appealAt(cells, tile.x, tile.y), approval, heating,@@ -295,7 +295,7 @@ export const Hazards = Game.System(let best: { readonly watch: (typeof watches)[number]; readonly roads: ReturnType<typeof reach>; readonly cell: Point; readonly distance: number } | null = nullfor (const watch of watches) {// A fire brigade sends more (see `Upgrade.crews`).- const crews = upgradeAt(kinds.firewatch, maybe(watch.data.upgraded)?.level ?? 0)?.crews ?? risk.fire.crews+ const crews = upgradeAt(kinds.firewatch, watch.data.upgraded.value()?.level ?? 0)?.crews ?? risk.fire.crewsif ((out.get(watch.entity.id) ?? 0) >= crews) continueconst starts = doors(grid, watch.data.tile.get())if (starts.length === 0) continuediff --git a/src/sim/logistics.ts b/src/sim/logistics.tsindex a70ac95..fdc1027 100644--- a/src/sim/logistics.ts+++ b/src/sim/logistics.ts@@ -14,7 +14,7 @@ import { preferDelivery } from "../rules/transport.ts"import { goodIds, provisions, type GoodId } from "../content.ts"import { doors, nearest, pathTo, reach, key, type Reach } from "../grid.ts"import type { Point } from "../iso.ts"-import { Building, Burning, Carriers, Errand, Figure, Game, Rules, Grid, House, Appeal, Inventory, Recipe, Rising, Route, Service, Site, Storage, Tile, Time, WalkerOf, Works, maybe } from "../schema.ts"+import { Building, Burning, Carriers, Errand, Figure, Game, Rules, Grid, House, Appeal, Inventory, Recipe, Rising, Route, Service, Site, Storage, Tile, Time, WalkerOf, Works } from "../schema.ts"import { CELL_STEPS } from "./shared.ts"/** The most a carrier takes at once. */@@ -98,13 +98,13 @@ export const Dispatch = Game.System(const sitesWant = new Set(wants.filter((w) => w.want() > 0).map((w) => w.good))const rooms: Array<{ readonly id: Id; readonly doors: ReadonlyArray<Point>; readonly room: (g: GoodId) => number; readonly keeps: boolean }> = []for (const { entity, data } of queries.wanting.each()) {- const inventory = maybe(data.inventory)+ const inventory = data.inventory.value()if (!inventory) continueconst ds = doors(grid, data.tile.get())if (ds.length === 0) continue- const recipe = maybe(data.recipe)+ const recipe = data.recipe.value()const space = (g: GoodId) => (inventory.accepts.includes(g) ? inventory.cap - inventory.stock[g] - inbound(entity.id, g) : 0)- const kind = maybe(data.building)?.kind+ const kind = data.building.value()?.kindif (data.storage.present) {rooms.push({ id: entity.id, doors: ds, room: space, keeps: kind !== undefined && (kinds[kind].keeps ?? 0) > 1 })}@@ -114,9 +114,9 @@ export const Dispatch = Game.System(}// A workshop that wears out tools keeps a couple on hand.if (kind !== undefined && kinds[kind].wear) wants.push({ id: entity.id, doors: ds, good: "tools", site: false, want: () => TOOL_STOCK - inventory.stock.tools - inbound(entity.id, "tools"), fill: () => (inventory.stock.tools + inbound(entity.id, "tools")) / TOOL_STOCK })- const service = maybe(data.service)?.service+ const service = data.service.value()?.serviceif (service === "goods") {- const roads = reach(grid, [ds[0]!]), range = maybe(data.service)!.range+ const roads = reach(grid, [ds[0]!]), range = data.service.value()!.rangelet citizenDistrict = false, burgherDistrict = falsefor (const { data: h } of queries.homes.each()) {const tile = h.tile.get(), found = nearest(roads, doors(grid, tile))@@ -156,7 +156,7 @@ export const Dispatch = Game.System(const roads = reach(grid, starts)const inventory = data.inventory.get()let stock = inventory.stock- const recipe = maybe(data.recipe)+ const recipe = data.recipe.value()// A storage meets demands with what it holds; anyone else sends on what it made.// A producer waits for a full load (or a full shelf) so its carriers do not walk with one crate.@@ -179,7 +179,7 @@ export const Dispatch = Game.System(// Food that spoils goes to a granary if there is one in reach, before the nearest storage; a// storage that does not keep food sends it on to a granary that does.const perishable = spoils[good] !== undefined- const senderKeeps = (kinds[maybe(data.building)?.kind ?? "townhall"].keeps ?? 0) > 1+ const senderKeeps = (kinds[data.building.value()?.kind ?? "townhall"].keeps ?? 0) > 1if (best === null && (!data.storage.present || (perishable && !senderKeeps))) {let kept = falsefor (const r of rooms) {diff --git a/src/sim/term.ts b/src/sim/term.tsindex 2b88b5d..013576e 100644--- a/src/sim/term.ts+++ b/src/sim/term.ts@@ -7,7 +7,7 @@ import { shippedRules } from "../rules/config.ts"*/import { crown, HISTORY_TICKS, stepsOf, WINTER_WARNING, type GoodId } from "../content.ts"import * as Random from "@typeonce/ritmo-math/Random"-import { Building, Census, Charter, Chronicle, Crown, Fate, Game, Rules, History, House, Inventory, Ledger, Mood, Pantry, Paused, Policy, Recipe, Rising, Rng, Site, Stock, Storage, Time, Treasury, TownHall, Upgraded, maybe } from "../schema.ts"+import { Building, Census, Charter, Chronicle, Crown, Fate, Game, Rules, History, House, Inventory, Ledger, Mood, Pantry, Paused, Policy, Recipe, Rising, Rng, Site, Stock, Storage, Time, Treasury, TownHall, Upgraded } from "../schema.ts"import { elapsed, seasonAt, termTicks, write } from "./shared.ts"// ── Time ──────────────────────────────────────────────────────────────────@@ -223,7 +223,7 @@ export const Judge = Game.System(const { crown, fate, ranks } = rules// The town hall's upgrades: a city asks for a guildhall.const hallRow = queries.halls.each()[0]- const hall = hallRow ? maybe(hallRow.data.upgraded)?.level ?? 0 : 0+ const hall = hallRow ? hallRow.data.upgraded.value()?.level ?? 0 : 0const charter = resources.charter.get()const t = elapsed(resources.time.get(), charter)diff --git a/src/sim/town.ts b/src/sim/town.tsindex 2a1d360..85b1e29 100644--- a/src/sim/town.ts+++ b/src/sim/town.ts@@ -8,7 +8,7 @@ import { tradeCollection } from "../rules/trade.ts"import { appealAt, parkUpkeep } from "../appeal.ts"import { doors, key, reach } from "../grid.ts"import { amounts, goodIds, upgradeAt, upkeepOf, type GoodId } from "../content.ts"-import { Appeal, Building, Burning, Census, Charter, Flow, Game, Rules, Grid, House, Inventory, Ledger, Market, Mood, Park, Paused, Policy, Rebuilt, Rising, Risk, Sick, Site, Staff, Storage, Tile, Time, TownHall, Treasury, Upgraded, maybe } from "../schema.ts"+import { Appeal, Building, Burning, Census, Charter, Flow, Game, Rules, Grid, House, Inventory, Ledger, Market, Mood, Park, Paused, Policy, Rebuilt, Rising, Risk, Sick, Site, Staff, Storage, Tile, Time, TownHall, Treasury, Upgraded } from "../schema.ts"import { connected, elapsed, seasonAt } from "./shared.ts"import { ageNeeds, baseCollection, mealDecay, adminOf, capacity, met, rateOf, shortOf, taxOf, tierFor } from "../rules/households.ts"@@ -91,10 +91,10 @@ export const Households = Game.System(else if (next.clock % home.settle === 0) {const tile = data.tile.get()const desirability = appealAt(cells, tile.x, tile.y)- const tier = tierFor(next, desirability, maybe(data.risk) ?? { fire: 0, health: 0, order: 0 }, rules)+ const tier = tierFor(next, desirability, data.risk.value() ?? { fire: 0, health: 0, order: 0 }, rules)// Rising a tier is a rebuilding, paid for at once, once: a home that cannot be paid for waits, and one// that stepped down moves back up into what it was rebuilt as.- const built = maybe(data.rebuilt)?.tier ?? 1+ const built = data.rebuilt.value()?.tier ?? 1if (tier <= h.tier || tier <= built) next.tier = tierelse if (pay(home.tiers[tier].rise)) {next.tier = tier@@ -162,10 +162,10 @@ export const Collect = Game.System(if (reached) taxes += taxOf(data.house.get(), policy, rules, appealAt(cells, tile.x, tile.y))}let upkeep = 0- for (const { data } of queries.buildings.each()) upkeep += upkeepOf(kinds[data.building.get().kind], maybe(data.upgraded)?.level ?? 0) * (data.paused.present ? PAUSED_UPKEEP : 1)+ for (const { data } of queries.buildings.each()) upkeep += upkeepOf(kinds[data.building.get().kind], data.upgraded.value()?.level ?? 0) * (data.paused.present ? PAUSED_UPKEEP : 1)for (const { data } of queries.parks.each()) upkeep += parkUpkeep(data.park.get(), rules)// A guildhall or a city hall runs the town for less (see `Upgrade.admin`).- const saves = (hall ? upgradeAt(kinds.townhall, maybe(hall.data.upgraded)?.level ?? 0)?.admin : undefined) ?? 0+ const saves = (hall ? upgradeAt(kinds.townhall, hall.data.upgraded.value()?.level ?? 0)?.admin : undefined) ?? 0const admin = adminOf(residents, rules, saves)const stores = queries.stores.each()diff --git a/src/sim/walkers.ts b/src/sim/walkers.tsindex 12c0e27..dabe5a3 100644--- a/src/sim/walkers.ts+++ b/src/sim/walkers.ts@@ -14,7 +14,7 @@ import { appealAt } from "../appeal.ts"import { amounts, categoryColor, each, provisions, stepsOf, total, type Amounts } from "../content.ts"import { DIRS, doors, isRoad, key, nearest, ownerAt, pathTo, reach, useAt } from "../grid.ts"import { inside, type Point } from "../iso.ts"-import { Building, Burning, Condition, Figure, Game, Rules, Grid, Appeal, Handed, Patrol, House, Inventory, Pantry, Paused, Recipe, Rescue, Rising, Risk, Roam, Route, Service, Sick, Site, Staff, Status, Tile, Time, WalkerOf, maybe, type HandedValue, type Status as StatusValue } from "../schema.ts"+import { Building, Burning, Condition, Figure, Game, Rules, Grid, Appeal, Handed, Patrol, House, Inventory, Pantry, Paused, Recipe, Rescue, Rising, Risk, Roam, Route, Service, Sick, Site, Staff, Status, Tile, Time, WalkerOf, type HandedValue, type Status as StatusValue } from "../schema.ts"import { CELL_STEPS } from "./shared.ts"import { paced } from "./work.ts"@@ -109,13 +109,13 @@ export const SendWalkers = Game.System(const service = data.service.get()const staff = data.staff.get()const starts = doors(grid, data.tile.get())- const stock = maybe(data.inventory)?.stock+ const stock = data.inventory.value()?.stockconst staffed = !data.paused.present && (staff.needed === 0 || staff.assigned > 0)const carries = (g: (typeof provisions)[number]) =>service.service === "goods" ? provisions.includes(g) : service.service === "repair" ? g === "planks" || g === "stone" : falseconst basket: Amounts = each((g) => (stock && carries(g) ? Math.min(BASKET, stock[g]) : 0))const goes = service.service === "goods" ? total(basket) > 0 : service.service === "repair" ? basket.planks > 0 : true- if (!maybe(data.recipe)) {+ if (!data.recipe.value()) {const status: StatusValue = data.paused.present? "paused": starts.length === 0diff --git a/src/sim/work.ts b/src/sim/work.tsindex bbe1be1..367f6f2 100644--- a/src/sim/work.ts+++ b/src/sim/work.ts@@ -17,7 +17,7 @@ const FLOW_SLICES = 6const each = (f: (g: (typeof goodIds)[number]) => number): Amounts => Object.fromEntries(goodIds.map((g) => [g, f(g)])) as Amountsimport { around, doors, GridBuilder, key, ownerAt, reach, roadPrint, useAt } from "../grid.ts"-import { Building, Burning, Carriers, Charter, Chronicle, Errand, Flow, Roam, Condition, Field, FieldOf, Game, Rules, Gatherer, Grid, House, Inventory, Land, Paused, Paved, Planter, Recipe, Rising, Rng, Rock, Service, Site, Staff, Status, Stock, Storage, Tile, Time, Treasury, Tree, Upgraded, maybe, type Status as StatusValue, Water, Works } from "../schema.ts"+import { Building, Burning, Carriers, Charter, Chronicle, Errand, Flow, Roam, Condition, Field, FieldOf, Game, Rules, Gatherer, Grid, House, Inventory, Land, Paused, Paved, Planter, Recipe, Rising, Rng, Rock, Service, Site, Staff, Status, Stock, Storage, Tile, Time, Treasury, Tree, Upgraded, type Status as StatusValue, Water, Works } from "../schema.ts"import { connected, elapsed, seasonAt, TileRead, useOf, write } from "./shared.ts"import { assignWorkers, equipmentPace, effort, paced } from "../rules/production.ts"@@ -209,7 +209,7 @@ export const Raise = Game.System(commands.remove(entity, Works)commands.insert(entity, Game.Command.entry(Upgraded, { level: works.level }))data.staff.set({ ...data.staff.get(), needed: kind.workers })- const recipe = maybe(data.recipe), carriers = maybe(data.carriers), service = maybe(data.service)+ const recipe = data.recipe.value(), carriers = data.carriers.value(), service = data.service.value()if (recipe && kind.recipe) commands.insert(entity, Game.Command.entry(Recipe, { ...recipe, period: stepsOf(kind.recipe.seconds) }))if (shelves.ok && kind.holds) shelves.value.data.inventory.set({ ...shelves.value.data.inventory.get(), cap: kind.holds.cap })if (carriers && kind.carriers) commands.insert(entity, Game.Command.entry(Carriers, { count: kind.carriers }))@@ -458,7 +458,7 @@ export const Work = Game.System(const tile = data.tile.get()const kind = kinds[data.building.get().kind]const staff = data.staff.get()- const gatherer = maybe(data.gatherer)+ const gatherer = data.gatherer.value()let recipe = data.recipe.get()const inventory = data.inventory.get()let stock = inventory.stock@@ -468,7 +468,7 @@ export const Work = Game.System(let short = !fedif (open && staff.assigned > 0 && recipe.progress === 0 && room && fed) {- const deep = upgradeAt(kind, maybe(data.upgraded)?.level ?? 0)?.deep ?? false+ const deep = upgradeAt(kind, data.upgraded.value()?.level ?? 0)?.deep ?? falseif (gatherer && !gather(gatherer.source, tile, gatherer.radius, deep)) short = trueelse {if (recipe.input !== null) stock = { ...stock, [recipe.input]: stock[recipe.input] - recipe.inputs }@@ -476,7 +476,7 @@ export const Work = Game.System(}}- const pace = equipmentPace(kind, stock.tools, maybe(data.condition)?.value ?? Infinity, fishing, rules)+ const pace = equipmentPace(kind, stock.tools, data.condition.value()?.value ?? Infinity, fishing, rules)const put = effort(staff, tick, rules)if (open && recipe.progress > 0 && put > 0 && paced(pace, tick)) {const progress = recipe.progress + put@@ -554,7 +554,7 @@ export const Plant = Game.System(const grown = reach.filter((c) => useAt(grid, c.x, c.y) === planter.what).lengthconst spots = reach.filter((c) => useAt(grid, c.x, c.y) === "empty" && !sown.has(key(c.x, c.y)))// A forester has no recipe of its own: its status is its planting.- if (!maybe(data.recipe)) {+ if (!data.recipe.value()) {const status: StatusValue = data.paused.present ? "paused" : !open ? "unconnected" : staff.assigned === 0 ? "unstaffed" : grown < planter.max && spots.length > 0 ? "working" : "idle"if (data.status.get() !== status) data.status.set(status)}