Siegeworks: city accepts them, Give on raid readiness
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1bac06cb28
commit
6697545ba0
3 changed files with 18 additions and 3 deletions
2
game.py
2
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:
|
||||
|
|
|
|||
|
|
@ -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 `<div class="req ${r.next ? "dim" : ""}"><span${link}${tip}>${item(r.item).icon}</span><span><span${link}${tip}>${esc(r.label)}</span> <span class="muted small">${fmt(r.have)} / ${fmt(r.want)}</span></span>
|
||||
${mine ? `<button class="btn sm gold" data-donate="${r.item}" data-qty="all">Give ${fmt(mine)}</button>` : "<span></span>"}
|
||||
${mine ? `<button class="btn sm gold" data-donate="${give}" data-qty="all"${siege ? ` title="${esc(item(siege).name)}"` : ""}>Give ${fmt(mine)}${siege ? ` ${item(siege).icon}` : ""}</button>` : "<span></span>"}
|
||||
${r.foods ? foodKinds(r) : `<div class="bar"><span style="width:${r.want ? Math.min(100, r.have / r.want * 100) : 100}%"></span></div>`}</div>`;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue