Town square costs read have / need
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
138a4e5d77
commit
e3b70c1e3a
1 changed files with 7 additions and 2 deletions
|
|
@ -281,6 +281,11 @@ function itemChip(id, qty, have) {
|
||||||
return `<span class="item-chip ${short ? "short" : ""}" title="${esc(item(id).name)}">${item(id).icon} ${fmt(qty)}${have !== undefined ? ` <span class="have">/ ${fmt(have)}</span>` : ""}</span>`;
|
return `<span class="item-chip ${short ? "short" : ""}" title="${esc(item(id).name)}">${item(id).icon} ${fmt(qty)}${have !== undefined ? ` <span class="have">/ ${fmt(have)}</span>` : ""}</span>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Progress towards a building cost: "have / need".
|
||||||
|
function costChip(icon, name, need, have) {
|
||||||
|
return `<span class="item-chip ${have < need ? "short" : ""}" title="${esc(name)}">${icon} ${fmt(have)} <span class="have">/ ${fmt(need)}</span></span>`;
|
||||||
|
}
|
||||||
|
|
||||||
// --- skill pages ----------------------------------------------------------
|
// --- skill pages ----------------------------------------------------------
|
||||||
|
|
||||||
function skillPage(id) {
|
function skillPage(id) {
|
||||||
|
|
@ -439,8 +444,8 @@ function town() {
|
||||||
for (const [key, b] of Object.entries(city.buildings)) {
|
for (const [key, b] of Object.entries(city.buildings)) {
|
||||||
const spec = C.buildings[key];
|
const spec = C.buildings[key];
|
||||||
const cost = b.cost ? Object.entries(b.cost).map(([id, q]) => id === "gold"
|
const cost = b.cost ? Object.entries(b.cost).map(([id, q]) => id === "gold"
|
||||||
? `<span class="item-chip ${city.treasury < q ? "short" : ""}">🪙 ${fmt(q)} <span class="have">/ ${fmt(city.treasury)}</span></span>`
|
? costChip("🪙", "Gold", q, city.treasury)
|
||||||
: itemChip(id, q, city.stockpile[id] || 0)).join("") : "";
|
: costChip(item(id).icon, item(id).name, q, city.stockpile[id] || 0)).join("") : "";
|
||||||
const label = b.damaged ? "Repair" : `Build level ${b.level + 1}`;
|
const label = b.damaged ? "Repair" : `Build level ${b.level + 1}`;
|
||||||
html += `<div class="action building ${b.damaged ? "damaged" : ""}">
|
html += `<div class="action building ${b.damaged ? "damaged" : ""}">
|
||||||
<div class="top"><div class="ico">${spec.icon}</div><div>
|
<div class="top"><div class="ico">${spec.icon}</div><div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue