Armoury: each guard post's kit, best first, with stats
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
bacef12cb5
commit
b5dfb713de
3 changed files with 32 additions and 5 deletions
12
game.py
12
game.py
|
|
@ -4758,11 +4758,11 @@ def wear_share(ratio: float) -> float:
|
|||
return 0.1 + 0.2 * max(0.0, 2 - ratio)
|
||||
|
||||
|
||||
def issued_kit(world: dict, slot: str) -> list[tuple[str, int]]:
|
||||
"""The `slot` items handed to the guards on duty, best first."""
|
||||
def issued_kit(world: dict, slot: str, people: int | None = None) -> list[tuple[str, int]]:
|
||||
"""The `slot` items handed to the guards on duty (or `people` guards), best first."""
|
||||
stock = world["city"]["stockpile"]
|
||||
stat = KIT_DEFENCE[slot][0]
|
||||
people = guards_on_duty(world)
|
||||
people = guards_on_duty(world) if people is None else people
|
||||
issued = []
|
||||
for item in sorted((i for i in stock if kit_slot(i) == slot), key=lambda i: -ITEMS[i].get(stat, 0)):
|
||||
if not people:
|
||||
|
|
@ -4868,7 +4868,8 @@ def defence(world: dict, guards: int | None = None) -> dict:
|
|||
if city["starving"]:
|
||||
total *= 0.8
|
||||
return {"parts": parts, "garrison": garrison, "total": round(total, 1), "starving": city["starving"],
|
||||
"guards": armed, "posts": posts, "wages": int(city.get("wages", 0)), "wage": GUARD_WAGE}
|
||||
"guards": armed, "posts": posts, "wages": int(city.get("wages", 0)), "wage": GUARD_WAGE,
|
||||
"kit": {slot: issued_kit(world, slot, posts) for slot in KIT_DEFENCE}}
|
||||
|
||||
|
||||
def standing_defence(world: dict) -> float:
|
||||
|
|
@ -6842,6 +6843,9 @@ ORDER_RECIPES, ORDER_RAW = _order_sources()
|
|||
# What changed, shown on the Patch notes page. Newest first; every shipped change adds a
|
||||
# line here (new / balance / fix), and a new release a new entry on top.
|
||||
PATCH_NOTES = [
|
||||
{"date": "2026-10-30", "title": "Armoury", "notes": [
|
||||
("new", "Added armoury to raid readiness."),
|
||||
]},
|
||||
{"date": "2026-10-29", "title": "Frames, no coal past steel", "notes": [
|
||||
("balance", "Mithril, adamant and rune bars: no coal. Steel still takes 2."),
|
||||
("balance", "Ore worth: mithril 15 → 21, adamantite 30 → 36, runite 55 → 63. Bars: mithril 47 → 32, adamant 74 → 54, rune 114 → 95."),
|
||||
|
|
|
|||
|
|
@ -2442,6 +2442,24 @@ function foodKinds(r) {
|
|||
`<span class="${meals >= r.day ? "" : "missing"}"${goto(id)} title="${esc(`${item(id).name} · ${fmt(meals)} / ${fmt(r.day)} meals${gotoTip(id)}`)}">${item(id).icon}</span>`).join("")}</div>`;
|
||||
}
|
||||
|
||||
// What each guard post carries, best first: unpaid posts faded, guards with nothing in red.
|
||||
function armoury(d) {
|
||||
const slots = { weapon: "Weapons", shield: "Shields", jerkin: "Body armour", salve: "Salves" };
|
||||
return Object.entries(slots).map(([slot, label]) => {
|
||||
const issued = d.kit[slot] || [], bare = d.posts - issued.reduce((n, [, q]) => n + q, 0);
|
||||
let seat = 0;
|
||||
const chips = [...issued, ...(bare > 0 ? [[null, bare]] : [])].flatMap(([id, qty]) => {
|
||||
const paid = Math.max(0, Math.min(qty, d.guards - seat));
|
||||
seat += qty;
|
||||
return [[paid, true], [qty - paid, false]].filter(([n]) => n).map(([n, on]) => {
|
||||
const tip = id ? [item(id).name, itemStats(id)].filter(Boolean).join(": ") + gotoTip(id) : `No ${label.toLowerCase()}`;
|
||||
return `<span class="item-chip ${on ? (id ? "" : "short") : "unpaid"}"${id ? goto(id) : ""} title="${esc(tip + (on ? "" : "\nUnpaid posts"))}">${id ? `${item(id).icon} ${esc(item(id).name)}` : "✖ None"} ×${fmt(n)}${id ? ` <span class="have">+${fmt(item(id)[C.kit_defence[slot][0]] || 0)}</span>` : ""}</span>`;
|
||||
});
|
||||
});
|
||||
return `<div class="kit-row"><span class="muted small">${label}</span><div>${chips.join("")}</div></div>`;
|
||||
}).join("");
|
||||
}
|
||||
|
||||
function raidPrep(ev) {
|
||||
const city = S.city, me = S.me, d = city.defence;
|
||||
const names = { mercenaries: "Hired sellswords", ward: "Divine ward (temple)", rallied: "Rallied militia (favour)", drilled: "Drilled militia", townsfolk: "Townsfolk with pitchforks", walls: "Walls", militia: "Paid guards (barracks)", weapons: "Weapons the guards hold", shields: "Shields the guards hold", jerkins: "Body armour the guards wear", salves: "Salves", arrows: "Arrows", garrison: "Garrison" };
|
||||
|
|
@ -2449,7 +2467,8 @@ function raidPrep(ev) {
|
|||
const reqs = (ev.requests || []).map(reqRow).join("");
|
||||
return `<div class="cols">
|
||||
<div class="panel"><h2>Raid readiness</h2>${reqs}
|
||||
<p class="small muted">Stockpile gear arms the defenders, best first. Fights use up arrows and break some gear.</p></div>
|
||||
<p class="small muted">Stockpile gear arms the defenders, best first. Fights use up arrows and break some gear.</p>
|
||||
<h2 style="margin-top:16px">Armoury</h2>${armoury(d)}</div>
|
||||
<div class="panel"><h2>Guards · ${d.guards} / ${d.posts} paid</h2>
|
||||
<p class="small">Wage chest ${COIN} ${fmt(d.wages)} / ${fmt(full)} · ${d.wage} gold a guard per threat</p>
|
||||
<div class="bar"><span style="width:${full ? Math.min(100, d.wages / full * 100) : 0}%"></span></div>
|
||||
|
|
|
|||
|
|
@ -312,6 +312,10 @@ select { background: var(--bg); border: 1px solid var(--line); border-radius: 8p
|
|||
table.parts { width: 100%; border-collapse: collapse; font-size: 14px; }
|
||||
table.parts td { padding: 4px 0; border-bottom: 1px solid var(--line); }
|
||||
table.parts td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
|
||||
.kit-row { display: grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: baseline; margin-bottom: 8px; }
|
||||
.kit-row > div { display: flex; flex-wrap: wrap; gap: 4px; }
|
||||
.item-chip.unpaid { opacity: .45; }
|
||||
.kit-row .item-chip .have { color: var(--muted); }
|
||||
.report { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin-bottom: 14px; }
|
||||
.report.win { border-left-color: var(--good); }
|
||||
.report.loss { border-left-color: var(--bad); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue