Only donate what the city uses; sell useless overflow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e3a5f519fc
commit
b82f979b4c
3 changed files with 63 additions and 7 deletions
|
|
@ -133,6 +133,8 @@ function showSummary(sum) {
|
|||
if (sum.lucky) toast(sum.lucky === 1 ? "✨ Double yield!" : `✨ ${sum.lucky} double yields!`, "level");
|
||||
const spilled = Object.entries(sum.overflow);
|
||||
if (spilled.length) toast(`📦 Bank full: ${spilled.map(([id, q]) => `${fmt(q)} ${item(id).name.toLowerCase()}`).join(", ")} went to the city`);
|
||||
const sold = Object.entries(sum.sold || {});
|
||||
if (sold.length) toast(`📦 Bank full: sold ${sold.map(([id, q]) => `${fmt(q)} ${item(id).name.toLowerCase()}`).join(", ")} for ${fmt(sum.sold_gold)} gold`);
|
||||
for (const [skill, level] of sum.levels) toast(`🎉 ${skillOf(skill).name} level ${level}!`, "level");
|
||||
if (sum.stopped) toast(`Stopped: ${sum.stopped}`, "bad");
|
||||
if (sum.resumed) toast(`Back to ${C.actions.find((x) => x.id === sum.resumed).name.toLowerCase()}`);
|
||||
|
|
@ -143,6 +145,7 @@ function awayModal(sum) {
|
|||
const xp = Object.entries(sum.xp).map(([id, q]) => `<li>${skillOf(id).icon} ${fmt(q)} ${esc(skillOf(id).name)} XP</li>`).join("");
|
||||
const levels = sum.levels.map(([id, l]) => `<li>🎉 ${esc(skillOf(id).name)} reached level ${l}</li>`).join("");
|
||||
const spilled = Object.entries(sum.overflow).map(([id, q]) => `<li>${item(id).icon} ${fmt(q)} ${esc(item(id).name)}</li>`).join("");
|
||||
const sold = Object.entries(sum.sold || {}).map(([id, q]) => `<li>${item(id).icon} ${fmt(q)} ${esc(item(id).name)}</li>`).join("");
|
||||
openModal(`
|
||||
<h2>While you were away</h2>
|
||||
<p class="muted">You completed ${fmt(sum.done)} actions${sum.wins || sum.losses ? ` (${sum.wins} fights won, ${sum.losses} lost)` : ""}.</p>
|
||||
|
|
@ -151,6 +154,7 @@ function awayModal(sum) {
|
|||
${sum.gold ? `<p class="gold">+${fmt(sum.gold)} gold</p>` : ""}
|
||||
${xp ? `<ul>${xp}</ul>` : ""}
|
||||
${levels ? `<ul>${levels}</ul>` : ""}
|
||||
${sold ? `<p class="muted small">Your bank was full, so this was sold for ${fmt(sum.sold_gold)} gold:</p><ul>${sold}</ul>` : ""}
|
||||
${spilled ? `<p class="muted small">Your bank was full, so this went to the city stockpile (for half the favour of giving it yourself):</p><ul>${spilled}</ul>` : ""}
|
||||
${sum.stopped ? `<p class="tag bad">Stopped: ${esc(sum.stopped)}</p>` : ""}
|
||||
<p><button class="btn primary" data-close>Back to work</button></p>`);
|
||||
|
|
@ -453,7 +457,8 @@ function bank() {
|
|||
<p class="small muted">When an item doesn't fit:
|
||||
<button class="btn sm ${me.overflow === "city" ? "gold" : ""}" data-overflow="city">Send it to the city</button>
|
||||
<button class="btn sm ${me.overflow === "stop" ? "gold" : ""}" data-overflow="stop">Stop working</button>
|
||||
<br>Raids never touch your bank. Overflow sent to the city earns half the favour of giving it yourself.</p>
|
||||
<br>Raids never touch your bank. Overflow sent to the city earns half the favour of giving it yourself;
|
||||
anything the city has no use for is sold instead.</p>
|
||||
</div>
|
||||
${favourPanel()}
|
||||
</div>
|
||||
|
|
@ -476,13 +481,20 @@ function itemPanel(id) {
|
|||
${it.heal ? `<div class="row"><div class="small muted">Heals ${it.heal} in fights.</div>
|
||||
${S.me.food === id ? `<span class="tag good">Your fighting food</span>` : `<button class="btn sm" data-food="${id}">Eat this first in fights</button>`}</div>` : ""}
|
||||
${it.food ? `<div class="row small muted">Feeds ${it.food} townsfolk for two days in the city granary.</div>` : ""}
|
||||
<div class="row"><div class="k">Donate to the city · +${it.value} favour each</div><div class="btns">${qtyBtns("data-donate")}</div></div>
|
||||
${C.city_uses[id].length
|
||||
? `<div class="row"><div class="k">Donate to the city · +${it.value} favour each</div><div class="btns">${qtyBtns("data-donate")}</div>
|
||||
<div class="small muted">Used for ${esc(listing(C.city_uses[id]))}.</div></div>`
|
||||
: `<div class="row small muted">The city has no use for this. Sell it, or give it to someone who can use it.</div>`}
|
||||
${others.length ? `<div class="row"><div class="k">Give to <select data-keep="give-to">${others.map((p) => `<option value="${esc(p.id)}">${esc(p.name)}</option>`).join("")}</select></div><div class="btns">${qtyBtns("data-give")}</div></div>` : ""}
|
||||
<div class="row"><div class="k">Sell</div><div class="btns">${qtyBtns("data-sell")}</div></div>
|
||||
<div class="row"><button class="btn sm" data-select="">Close</button></div>
|
||||
</div>${goldPanel()}`;
|
||||
}
|
||||
|
||||
function listing(words) {
|
||||
return words.length < 2 ? words.join("") : `${words.slice(0, -1).join(", ")} and ${words.at(-1)}`;
|
||||
}
|
||||
|
||||
function equipRow(id, it) {
|
||||
const [skill, level] = it.req || [];
|
||||
const short = skill && S.me.levels[skill] < level;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue