Knife and fork for cheapest-first food

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-21 09:23:19 +01:00
parent 0a73f65f20
commit 70367604b9
3 changed files with 6 additions and 5 deletions

View file

@ -30,7 +30,7 @@ const $ = (sel, root = document) => root.querySelector(sel);
// Icons are game-icons.net glyphs (CC BY 3.0) from one sprite, tinted per tier or material.
const glyph = (name, tint) => `<svg class="gi" style="color:${tint}" aria-hidden="true"><use href="/static/icons.svg#${name}"></use></svg>`;
const COIN = glyph("two-coins", "#e0b04a"), FAVOUR = glyph("sparkles", "#b98ce8"), HEART = glyph("hearts", "#e2645c");
const COIN = glyph("two-coins", "#e0b04a"), ANY_FOOD = glyph("knife-fork", "#d9c6a0"), FAVOUR = glyph("sparkles", "#b98ce8"), HEART = glyph("hearts", "#e2645c");
function iconise(content) {
const entries = [...Object.values(content.items), ...content.skills, ...Object.values(content.classes),
@ -1571,17 +1571,17 @@ function foodSlot(p, picked) {
const none = !p.edible.length;
const tip = none ? "No food in your bank" : id ? `Food: ${item(id).name}, heals ${item(id).heal}` : "Food: cheapest first";
return `<button class="doll-slot ${picked ? "on" : ""} ${none ? "starving" : ""}" data-doll="food" title="${esc(tip)}">
${none ? glyph("hot-meal", "#e2645c") : id ? item(id).icon : glyph("two-coins", "#e0b04a")}${id ? `<span class="swap-qty">${fmt(p.bank[id])}</span>` : ""}</button>`;
${none ? glyph("hot-meal", "#e2645c") : id ? item(id).icon : ANY_FOOD}${id ? `<span class="swap-qty">${fmt(p.bank[id])}</span>` : ""}</button>`;
}
function foodPanel(p) {
const id = p.food && p.bank[p.food] ? p.food : null;
const head = id ? `<div class="worn-head"><span class="ico">${item(id).icon}</span><b>${esc(item(id).name)}</b>
<span class="muted small">${HEART} ${item(id).heal} · ${fmt(p.bank[id])} left</span></div>`
: `<div class="worn-head"><span class="ico">${glyph("two-coins", "#e0b04a")}</span><b>Cheapest first</b></div>`;
: `<div class="worn-head"><span class="ico">${ANY_FOOD}</span><b>Cheapest first</b></div>`;
const tiles = [...p.edible].sort((a, b) => item(a).heal - item(b).heal).map((f) => `<button class="doll-slot swap ${f === id ? "on" : ""}" data-food="${f}"
title="${esc(`${item(f).name}: heals ${item(f).heal}`)}">${item(f).icon}<span class="swap-qty">${fmt(p.bank[f])}</span></button>`);
const cheap = `<button class="doll-slot swap ${id ? "" : "on"}" data-food="cheapest" title="Cheapest first">${glyph("two-coins", "#e0b04a")}</button>`;
const cheap = `<button class="doll-slot swap ${id ? "" : "on"}" data-food="cheapest" title="Cheapest first">${ANY_FOOD}</button>`;
return head + (p.edible.length ? `<div class="swap-head muted small">Eat first</div><div class="swap-grid">${cheap}${tiles.join("")}</div>`
: `<div class="small warn">No food in your bank.</div>`);
}