Queue: +Q from anything, After Q / Skip Q
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
54f703341e
commit
6e48c72d95
5 changed files with 93 additions and 15 deletions
|
|
@ -806,7 +806,7 @@ function queuePanel() {
|
|||
${now ? `<div class="qp-row now">${now.icon}<span class="qp-name">${esc(now.name)}<span class="muted small">${fmt(me.action.left)} left</span></span>
|
||||
<button class="btn sm" data-queue-skip title="Drop this make, on to the next">Skip</button></div>` : ""}
|
||||
${rows ? `<ol class="qp-list">${rows}</ol>` : `<p class="muted small">Empty. +Q on a recipe adds to it.</p>`}
|
||||
<div class="qp-foot"><span class="muted small">Then ${back ? `back to ${esc(back.name.toLowerCase())}` : "idle"}</span>
|
||||
<div class="qp-foot"><span class="muted small qp-then">After queue: ${back ? `${esc(back.name)}${now ? `<button class="x" data-queue-then title="Idle after the queue">✕</button>` : ""}` : "idle"}</span>
|
||||
${q.length ? `<button class="btn sm" data-queue-clear>Clear</button>` : ""}</div>
|
||||
</div>`;
|
||||
}
|
||||
|
|
@ -825,6 +825,15 @@ function queueRow() {
|
|||
}).join(`<span class="arrow">→</span>`)}</div>`;
|
||||
}
|
||||
|
||||
// Start, or while a make runs: After Q sets what comes once it and the queue are done,
|
||||
// and on that one, Skip Q drops them and starts it now.
|
||||
function startButton(a, size, why) {
|
||||
const making = S.me.action?.left, after = making && S.me.action.resume === a.id;
|
||||
const [label, title] = !making ? ["Start", ""] : after ? ["Skip Q", "Skip queue: drop the make and queue, start this now"]
|
||||
: ["After Q", "After queue: do this once the make and queue are done"];
|
||||
return `<button class="btn ${size} primary" data-start="${a.id}" ${after ? "data-skip" : ""} ${why ? "disabled" : ""} ${title ? `title="${title}"` : ""}>${label}</button>`;
|
||||
}
|
||||
|
||||
// The recipe you're after, under the top bar on every page: have / need for each input.
|
||||
function trackedBar() {
|
||||
const me = S.me, a = me.tracked && C.actions.find((x) => x.id === me.tracked);
|
||||
|
|
@ -834,7 +843,7 @@ function trackedBar() {
|
|||
return `<div class="tracked ${ready ? "ready" : ""}">
|
||||
<button class="tracked-name" data-nav="skill:${a.skill}" data-nav-group="${esc(a.group || "")}" title="${esc(a.name)}">${a.icon}<span class="label">${esc(a.name)}</span></button>
|
||||
<span class="io">${inputChips(a)}</span>
|
||||
${go ? `<button class="btn sm primary" data-start="${a.id}">Start</button>` : ""}
|
||||
${go ? startButton(a, "sm") : ""}
|
||||
<button class="pin on" data-track="${a.id}" title="Untrack">📌</button>
|
||||
</div>`;
|
||||
}
|
||||
|
|
@ -1715,8 +1724,13 @@ function actionCard(a) {
|
|||
&& me.action && C.actions.find((x) => x.id === me.action.id)?.skill === "farming" && !me.action.left;
|
||||
const why = me.blocked[a.id];
|
||||
const locked = isLocked(a);
|
||||
// Queue it behind the make that's running: materials only have to be there when its turn comes.
|
||||
const canQueue = me.action?.left && !active && me.queue_why[a.id] === null;
|
||||
// Queue it behind the make that's running (materials only have to be there when its turn comes),
|
||||
// or with nothing being made, start one: whatever you were doing is what comes after.
|
||||
const making = Boolean(me.action?.left);
|
||||
const canQueue = !active && me.queue_why[a.id] === null;
|
||||
const queueOff = making ? me.queue.length >= C.queue_max : Boolean(why);
|
||||
const queueTitle = making ? (queueOff ? `Queue full (${C.queue_max})` : "Queue: make this many after the current make")
|
||||
: why || "Make this many, then queue more behind it";
|
||||
const queued = me.queue.map((q, i) => q.id === a.id ? i + 1 : 0).filter(Boolean);
|
||||
const out = Object.keys(a.outputs)[0];
|
||||
const icon = a.icon;
|
||||
|
|
@ -1786,11 +1800,11 @@ function actionCard(a) {
|
|||
${second ? `<button class="btn" data-plot="">Clear plot 2</button>`
|
||||
: active ? `<button class="btn danger" data-stop>Stop</button>`
|
||||
: `<span class="btns">${!a.enemy && Object.keys(a.outputs).length
|
||||
? `<form data-form="make" data-id="${a.id}" class="make" title="Make this many, then resume"><button class="btn" ${why ? "disabled" : ""}>Make</button><input type="number" min="1" max="${C.make_max}" value="1" data-keep="make-${a.id}" ${why && !canQueue ? "disabled" : ""}>${canQueue
|
||||
? `<button class="btn q" data-q ${me.queue.length >= C.queue_max ? `disabled title="Queue full (${C.queue_max})"` : `title="Queue: make this many after the current make"`}>+Q</button>` : ""}</form>`
|
||||
? `<form data-form="make" data-id="${a.id}" class="make" title="Make this many, then resume"><button class="btn" ${why ? "disabled" : ""}>Make</button><input type="number" min="1" max="${C.make_max}" value="1" data-keep="make-${a.id}" ${why && (!canQueue || queueOff) ? "disabled" : ""}>${canQueue
|
||||
? `<button class="btn q" data-q ${queueOff ? "disabled" : ""} title="${esc(queueTitle)}">+Q</button>` : ""}</form>`
|
||||
: `<button class="btn" data-once="${a.id}" ${why ? "disabled" : ""} title="Once, then resume">${a.enemy ? "Fight once" : "Once"}</button>`}
|
||||
${canPlot ? `<button class="btn" data-plot="${a.id}" ${why ? "disabled" : ""} title="Grow in plot 2">Plot 2</button>` : ""}
|
||||
<button class="btn primary" data-start="${a.id}" ${why ? "disabled" : ""}>Start</button></span>`}
|
||||
${startButton(a, "", why)}</span>`}
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
|
@ -2876,7 +2890,15 @@ document.addEventListener("click", (e) => {
|
|||
animateFight(serverNow()); // the outline moves now; the server hears about it in the background
|
||||
return d.aim === S.uid ? undefined : act("/api/target", { id: d.aim });
|
||||
}
|
||||
if (d.start) return act("/api/action", { id: d.start });
|
||||
if (d.start) {
|
||||
// While a make runs, Start sets what comes after it and the queue; Skip Q starts it now.
|
||||
if ("skip" in d) return act("/api/action", { id: d.start, skip: true });
|
||||
const making = S.me?.action?.left;
|
||||
return act("/api/action", { id: d.start }).then(() => {
|
||||
if (making && S.me.action?.resume === d.start) toast(`After queue: ${C.actions.find((x) => x.id === d.start).name}`);
|
||||
});
|
||||
}
|
||||
if ("queueThen" in d) return act("/api/queue/then", {});
|
||||
if (d.once) return act("/api/action", { id: d.once, once: 1 });
|
||||
if ("stop" in d) return act("/api/stop", {});
|
||||
if (d.unqueue) return act("/api/queue/remove", { index: Number(d.unqueue) });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue