Firekeeping: tend all fires
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6e48c72d95
commit
fd85580466
3 changed files with 45 additions and 7 deletions
|
|
@ -1111,8 +1111,19 @@ function pickFirewood() {
|
|||
return [...open].reverse().find((t) => me.bank[C.firewood[t]]) ?? 0;
|
||||
}
|
||||
|
||||
// The fire tending all feeds next: the least fuel left among those with room in your pile.
|
||||
function tendAllTarget() {
|
||||
const action = S.me.action && C.actions.find((a) => a.id === S.me.action.id), fk = S.me.firekeeping;
|
||||
if (!action?.id.startsWith("tend_all_")) return null;
|
||||
const sum = (fuel) => fuel.reduce((total, c) => total + c.left, 0);
|
||||
const room = Object.keys(C.fires).map((id) => [id, fireNow(id)])
|
||||
.filter(([, n]) => sum(n.mine) + (fk.minutes - fk.bank) * 60 <= sum(n.mine.filter((c) => c.tier < action.tier)) + 1e-6);
|
||||
return room.reduce((best, f) => (!best || f[1].left < best[1].left ? f : best), null)?.[0] ?? null;
|
||||
}
|
||||
|
||||
function firekeepingPage() {
|
||||
const me = S.me, fk = me.firekeeping, pick = pickFirewood(), speed = Object.values(S.city.fires)[0].speed;
|
||||
const all = `tend_all_${C.firewood[pick]}`, tendingAll = me.action?.id.startsWith("tend_all_"), allWhy = me.blocked[all];
|
||||
const perLog = (tier) => +(C.tend_xp[tier] * fk.minutes).toFixed(1);
|
||||
const logs = C.firewood.map((log, tier) => {
|
||||
const level = tendLevel(tier), locked = me.levels.firekeeping < level;
|
||||
|
|
@ -1121,13 +1132,15 @@ function firekeepingPage() {
|
|||
}).join("");
|
||||
return `<div class="panel fire-tools"><div class="logs">${logs}</div>
|
||||
<span class="tag" title="Fire and XP per log">${glyph("stopwatch", "#98a1b4")} ${dur(fk.minutes * 60 / speed)} · ${perLog(pick)} XP</span>
|
||||
<span class="tag" title="Most fuel you can bank in a fire">${glyph("campfire", "#98a1b4")} ${dur(fk.bank * 60 / speed)}</span></div>
|
||||
<div class="fire-grid">${Object.keys(C.fires).map((id) => fireCard(id, pick)).join("")}</div>`;
|
||||
<span class="tag" title="Most fuel you can bank in a fire">${glyph("campfire", "#98a1b4")} ${dur(fk.bank * 60 / speed)}</span>
|
||||
${tendingAll ? `<button class="btn danger" data-stop>Stop</button>`
|
||||
: `<button class="btn primary" data-start="${all}" ${allWhy ? "disabled" : ""} title="${esc(allWhy || "Each log goes on the lowest fire with room in your pile")}">🔥 Tend all</button>`}</div>
|
||||
<div class="fire-grid">${Object.keys(C.fires).map((id) => fireCard(id, pick, tendAllTarget())).join("")}</div>`;
|
||||
}
|
||||
|
||||
function fireCard(id, pick) {
|
||||
function fireCard(id, pick, target) {
|
||||
const me = S.me, spec = C.fires[id], f = S.city.fires[id], n = fireNow(id), skill = skillOf(spec.skill);
|
||||
const mine = me.action?.id.startsWith(`tend_${id}_`);
|
||||
const mine = me.action?.id.startsWith(`tend_${id}_`) || target === id;
|
||||
const start = `tend_${id}_${C.firewood[pick]}`, why = mine ? "" : me.blocked[start];
|
||||
const crafting = f.users.filter((u) => !u.action.startsWith("tend_"));
|
||||
const doing = (u) => C.actions.find((a) => a.id === u.action);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue