From 7c87978d124f818935e0f3220eb50aac86edd6b4 Mon Sep 17 00:00:00 2001 From: rope Date: Tue, 20 Oct 2026 15:47:10 +0100 Subject: [PATCH] Food slot on the doll: pick what to eat first, or cheapest first Co-Authored-By: Claude Opus 5.5 --- game.py | 2 +- static/app.js | 31 +++++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/game.py b/game.py index 90f5fc7..5e7202b 100644 --- a/game.py +++ b/game.py @@ -3562,7 +3562,7 @@ for _index, (_area, _level, _prefix, _races) in enumerate(AREAS): ACTION_GLYPHS[f"fight_{_slug(_race)}"] = (RACE_GLYPHS[_race], TIER_TINTS[_index]) UI_GLYPHS = ["two-coins", "sparkles", "hearts", "prayer", "checked-shield", "magic-shield", "stopwatch", "swordman", "biceps", "cancel", "striking-diamonds", "archery-target", "dodging", "shield-reflect", - "cape", "gem-pendant", "gauntlet", "ring", "quiver", "leather-boot", "crystal-ball", "visored-helm", "breastplate", + "cape", "gem-pendant", "gauntlet", "ring", "quiver", "leather-boot", "crystal-ball", "hot-meal", "visored-helm", "breastplate", "leg-armor", "pointy-sword", "round-shield", *(kind["glyph"] for kind in DAMAGE_TYPES.values())] diff --git a/static/app.js b/static/app.js index dad265c..4ddd570 100644 --- a/static/app.js +++ b/static/app.js @@ -1237,10 +1237,11 @@ const DOLL = [ ["cape", "Cape", "cape"], ["helmet", "Head", "visored-helm"], ["amulet", "Amulet", "gem-pendant"], ["weapon", "Main hand", "pointy-sword"], ["body", "Body", "breastplate"], ["shield", "Off hand", "round-shield"], ["gloves", "Gloves", "gauntlet"], ["legs", "Legs", "leg-armor"], ["ring", "Ring", "ring"], - ["ammo", "Ammo", "quiver"], ["boots", "Boots", "leather-boot"], ["trinket", "Trinket", "crystal-ball"], + ["ammo", "Ammo", "quiver"], ["boots", "Boots", "leather-boot"], ["food", "Food", "hot-meal"], ]; function dollSlot(p, slot, label, outline, picked) { + if (slot === "food") return foodSlot(p, picked); const known = slot in p.equip, two = slot === "shield" && p.equip.weapon && item(p.equip.weapon).two_handed; const id = two ? p.equip.weapon : p.equip[slot]; const tip = !known ? `${label}: not in the game yet` : id ? `${label}: ${item(id).name}` : `${label}: empty`; @@ -1253,7 +1254,8 @@ function dollSlot(p, slot, label, outline, picked) { function paperDoll(p, mine) { const pick = dollPick && slot2(dollPick, p); let slot = ""; - if (pick) { + if (pick === "food") slot = foodPanel(p); + else if (pick) { const label = DOLL.find(([s]) => s === pick)[1]; const two = pick === "shield" && p.equip.weapon && item(p.equip.weapon).two_handed; const id = two ? p.equip.weapon : p.equip[pick], it = id && item(id); @@ -1307,7 +1309,28 @@ function swapGrid(p, slot, two) { // A picked slot only counts if it's one this character has. function slot2(slot, p) { - return slot in p.equip ? slot : null; + return slot in p.equip || (slot === "food" && "food" in p) ? slot : null; +} + +// Food for fights: one you picked to eat first, or the cheapest first. Only your own sheet shows it. +function foodSlot(p, picked) { + if (!("food" in p)) return ``; + const id = p.food && p.bank[p.food] ? p.food : null; + const tip = id ? `Food: ${item(id).name}, heals ${item(id).heal}` : "Food: cheapest first"; + return ``; +} + +function foodPanel(p) { + const id = p.food && p.bank[p.food] ? p.food : null; + const head = id ? `
${item(id).icon}${esc(item(id).name)} + ${HEART} ${item(id).heal} ยท ${fmt(p.bank[id])} left
` + : `
${glyph("two-coins", "#e0b04a")}Cheapest first
`; + const tiles = [...p.edible].sort((a, b) => item(a).heal - item(b).heal).map((f) => ``); + const cheap = ``; + return head + (p.edible.length ? `
Eat first
${cheap}${tiles.join("")}
` + : `
No food in your bank.
`); } // The equipment panel, the same on the character sheet and the combat page (which leaves out tools). @@ -1437,7 +1460,7 @@ document.addEventListener("click", (e) => { if (d.garrison) return act("/api/garrison", { join: d.garrison === "1" }); if (d.perk) return act("/api/perk", { perk: d.perk }); if (d.favour) return act("/api/favour", { kind: d.favour }); - if (d.food) return act("/api/food", { item: d.food }); + if (d.food) return act("/api/food", { item: d.food === "cheapest" ? null : d.food }); if (d.potion) return act("/api/potion", { item: d.potion }); if (d.unpost) { if (!confirm("Delete this message?")) return;