From e85eddb00a2247a0fa16f19012d3c33cf1def423 Mon Sep 17 00:00:00 2001 From: Alexander Whitestone Date: Sun, 12 Apr 2026 11:54:18 -0400 Subject: [PATCH] fix: bulkCost variable scoping in renderBuildings bulkCost was declared with const inside if/else blocks but referenced in the outer scope at line 2150 for ETA calculation. Hoisted the declaration to the function scope so it's accessible throughout. Fixes smoke test ReferenceError crash. --- game.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/game.js b/game.js index 3dc6353..39b4647 100644 --- a/game.js +++ b/game.js @@ -2102,19 +2102,20 @@ function renderBuildings() { let qty = G.buyAmount; let afford = false; let costStr = ''; + let bulkCost = {}; if (qty === -1) { const maxQty = getMaxBuyable(def.id); afford = maxQty > 0; if (maxQty > 0) { - const bulkCost = getBulkCost(def.id, maxQty); + bulkCost = getBulkCost(def.id, maxQty); costStr = Object.entries(bulkCost).map(([r, a]) => `${fmt(a)} ${r}`).join(', '); costStr = `x${maxQty}: ${costStr}`; } else { - const singleCost = getBuildingCost(def.id); - costStr = Object.entries(singleCost).map(([r, a]) => `${fmt(a)} ${r}`).join(', '); + bulkCost = getBuildingCost(def.id); + costStr = Object.entries(bulkCost).map(([r, a]) => `${fmt(a)} ${r}`).join(', '); } } else { - const bulkCost = getBulkCost(def.id, qty); + bulkCost = getBulkCost(def.id, qty); afford = true; for (const [resource, amount] of Object.entries(bulkCost)) { if ((G[resource] || 0) < amount) { afford = false; break; }