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:
rope 2026-10-30 11:55:48 +00:00
parent bacef12cb5
commit b5dfb713de
3 changed files with 32 additions and 5 deletions

View file

@ -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>

View file

@ -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); }