From 912f94f775c9b7f0b378dbe80c039de6eda46b03 Mon Sep 17 00:00:00 2001 From: rope Date: Mon, 26 Oct 2026 18:35:11 +0000 Subject: [PATCH] Amount field for donate/give/sell Co-Authored-By: Claude Opus 5.5 --- game.py | 1 + static/app.js | 16 +++++++++++----- static/styles.css | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/game.py b/game.py index b7f4668..487a967 100644 --- a/game.py +++ b/game.py @@ -6089,6 +6089,7 @@ PATCH_NOTES = [ ("fix", "Make box is wider: 1,000 fits."), ("new", "Fittings: โœ“ Fitted on ones the town has (โœ“ Paused while damaged)."), ("fix", "Council threat card names the dragon or raid band, not always \"Raiders\"."), + ("new", "Donate, Give, Sell: type an amount (starts at 1). 1/10/100 buttons gone, All stays."), ]}, {"date": "2026-10-25", "title": "Titles", "notes": [ ("new", "๐Ÿ† Achievements (under You): 127. Patterns, uniques, titles, emblems, looks, home. Tracks only, awards nothing."), diff --git a/static/app.js b/static/app.js index d00dfb7..39687b1 100644 --- a/static/app.js +++ b/static/app.js @@ -1801,8 +1801,8 @@ function itemPanel(id) { const merchant = S.city.merchant_until > serverNow(); const price = it.value * (merchant ? 1.5 : 1); const others = S.players.filter((p) => p.id !== S.uid); - const qtyBtns = (attr) => [1, 10, 100].filter((q) => q <= have).map((q) => ``).join("") - + ``; + const qtyBox = (kind, label) => `
` + + ``; return `
${it.icon}

${esc(it.name)}

@@ -1819,11 +1819,11 @@ function itemPanel(id) { ${it.relic ? `
Reforges masterworks with a pattern from ${esc(C.actions.find((a) => a.id === it.relic).name)}.
` : ""} ${it.food ? `
Feeds ${it.food} townsfolk for 2 days.
` : ""} ${C.city_uses[id].length - ? `
Donate to the city ยท +${it.value} favour each
${qtyBtns("data-donate")}
+ ? `
Donate to the city ยท +${it.value} favour each
${qtyBox("donate", "Donate")}
Used for ${esc(listing(C.city_uses[id]))}.
` : `
The city has no use for this.
`} - ${others.length ? `
Give to
${qtyBtns("data-give")}
` : ""} -
Sell
${qtyBtns("data-sell")}
+ ${others.length ? `
Give to
${qtyBox("give", "Give")}
` : ""} +
Sell
${qtyBox("sell", "Sell")}
${goldPanel()}`; } @@ -2981,6 +2981,12 @@ document.addEventListener("submit", async (e) => { field.value = "1"; return act("/api/action", { id: form.dataset.id, once: n }); } + if (form.dataset.form === "qty") { + const n = Math.floor(Number(value)), kind = form.dataset.kind; + if (!(n >= 1)) return toast("At least 1", "bad"); + field.value = "1"; + return act(`/api/${kind}`, { item: form.dataset.item, qty: n, ...(kind === "give" && { to: $("[data-keep=give-to]").value }) }); + } if (form.dataset.form === "gold") { field.value = ""; return act("/api/donate", { item: "gold", qty: Number(value) }); diff --git a/static/styles.css b/static/styles.css index 3be3fe9..0618d00 100644 --- a/static/styles.css +++ b/static/styles.css @@ -710,6 +710,7 @@ button.sheet-skill:hover { background: var(--panel-2); } .make { display: flex; } .make .btn { border-top-right-radius: 0; border-bottom-right-radius: 0; } .make input { width: 60px; padding-inline: 8px; appearance: textfield; border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; } +.make.sm input { width: 70px; padding-block: 3px; font-size: 13px; } .make input::-webkit-inner-spin-button, .make input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; } .reward-input { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; } .reward-input input { width: 110px; }