diff --git a/game.py b/game.py index 1b25198..2d7d0d6 100644 --- a/game.py +++ b/game.py @@ -2535,6 +2535,8 @@ def city_uses(item: str) -> list[str]: uses.append("the townsfolk") if spec.get("slot") in ("weapon", "shield") or "kit" in spec or item == "arrows": uses.append("the armoury") + if "siege" in spec: + uses.append(BUILDINGS["outworks"]["name"]) if item == "water_barrel": uses.append("the fire brigade") if "fitting" in spec: diff --git a/static/app.js b/static/app.js index 2bf852c..d1df8fe 100644 --- a/static/app.js +++ b/static/app.js @@ -1205,7 +1205,7 @@ function cityNeed(id) { for (const r of rows) { const short = r.want - r.have; const counts = r.any === "food" ? it.food : r.any === "fuel" ? id === "kindling" || C.firewood.includes(id) - : r.any ? (it.slot || it.kit) === r.any : id === r.item; + : r.any ? (it.slot || it.kit || it.siege) === r.any : id === r.item; if (short <= 0 || !counts) continue; qty += r.any === "food" ? Math.ceil(short / it.food) : short; why.push(`${source}: ${r.label} ยท ${fmt(r.have)} / ${fmt(r.want)}`); @@ -2613,11 +2613,13 @@ function favourSpends() { // A have / need row with its bar, and a Give button when you hold the item. function reqRow(r) { - const mine = !r.kinds && S.me.bank[r.item] || 0; + // A Siegeworks row takes the best trap or engine you hold. + const siege = Object.keys(S.me.bank).filter((id) => r.any && item(id).siege === r.any).sort((a, b) => item(b).siege_power - item(a).siege_power)[0]; + const give = siege || r.item, mine = !r.kinds && S.me.bank[give] || 0; // "Any" rows and kinds of food open the skill as you left it; a named item opens its own recipe. const link = goto(r.item, Boolean(r.any || r.kinds)), tip = link ? ` title="${esc(gotoTip(r.item).trim())}"` : ""; return `
${item(r.item).icon}${esc(r.label)} ${fmt(r.have)} / ${fmt(r.want)} - ${mine ? `` : ""} + ${mine ? `` : ""} ${r.foods ? foodKinds(r) : `
`}
`; } diff --git a/tests/test_game.py b/tests/test_game.py index f5221df..3bb5b41 100644 --- a/tests/test_game.py +++ b/tests/test_game.py @@ -4438,6 +4438,17 @@ class SiegeworksTest(unittest.TestCase): def raid(self, world, strength): return {"id": 1, "kind": "raid", "strength": strength, "sabotage": 0, "group": "the Red Hand", "status": "upcoming"} + def test_the_city_takes_siegeworks(self): + world = self.outworks(1) + fred = world["players"]["fred"] + fred["bank"].update(maple_engine=9, maple_trap=3) + self.assertEqual(game.city_uses("maple_engine"), ["Outworks"]) + self.assertIsNone(game.donate(world, fred, "maple_engine", 9, T0)) + self.assertIsNone(game.donate(world, fred, "maple_trap", 3, T0)) + game._sell_useless_stock(world, T0) + self.assertEqual(world["city"]["stockpile"]["maple_engine"], 9) + self.assertEqual(game.defence(world)["parts"]["engines"], 4 * 35) + def test_no_outworks_no_defence(self): world = self.outworks(0, {"yew_trap": 50, "yew_engine": 5}) parts = game.defence(world)["parts"]