Dungeons wait for the leader to start

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-10-25 19:21:37 +00:00
parent e43611e618
commit cf91cbce3c
4 changed files with 60 additions and 15 deletions

View file

@ -916,11 +916,15 @@ function combatFrame() {
</div>`;
const you = unit(S.uid, esc(me.name)) + others.map((m) => unit(m.id, esc(m.name))).join("");
const run = a?.run;
// A dungeon run: where you are in it, and (for the leader, while resting) the button to go in early.
// A dungeon run: where you are in it, and (for the leader) the button to start it, or to go in early while resting.
const lead = run?.leader === S.uid;
const stage = run ? `<div class="run-head"><b>${esc(run.dungeon)}</b>
<span class="muted small">${run.pull} / ${run.of} · ${esc(run.next)}${run.wipes ? ` · wipes ${run.wipes} / ${C.dungeon_wipes}` : ""}</span>
${f && run.leader === S.uid ? `<button class="btn sm" data-pull data-pull-btn>Pull now</button>` : ""}</div>` : "";
let foe = `<div class="foe-idle muted">${run?.away?.length ? `Waiting for ${run.away.map(esc).join(", ")} to come back`
${!run.started && lead ? `<button class="btn sm primary" data-start-run title="No one can join once you start">Start</button>`
: f && lead ? `<button class="btn sm" data-pull data-pull-btn>Pull now</button>` : ""}</div>` : "";
const group = run && [S.uid, ...(a.with || [])].map((uid) => uid === S.uid ? "You" : esc(playerName(uid))).join(", ");
let foe = `<div class="foe-idle muted">${run && !run.started ? `👥 ${run.size} / ${C.dungeon_size} · ${group}<br>${lead ? "Start when everyone's in" : `${esc(playerName(run.leader))} starts the run`}`
: run?.away?.length ? `Waiting for ${run.away.map(esc).join(", ")} to come back`
: run ? `Ready: ${esc(run.next)}` : waiting ? `👥 Waiting for a group · 1 / ${C.group_size}` : "Not fighting."}</div>`;
if (f) {
const mine = C.styles[me.fighter.style || "sword"]?.damage || me.fighter.damage;
@ -2341,6 +2345,7 @@ document.addEventListener("click", (e) => {
}
if (d.mode) return act("/api/manual", { id: d.mode, on: !S.me.manual.includes(d.mode) });
if ("pull" in d) return act("/api/pull", {});
if ("startRun" in d) return act("/api/run", {});
if (d.learn) return act("/api/learn", { item: d.learn });
if (d.eat !== undefined) return act("/api/eat", { below: Number(d.eat) });
if (d.aim) {
@ -2603,7 +2608,7 @@ document.addEventListener("visibilitychange", () => { if (!document.hidden) refr
return;
}
setInterval(() => {
if (!document.hidden && Date.now() - polledAt >= (S?.me?.action?.fight ? FIGHT_POLL_MS : POLL_MS)) refresh();
if (!document.hidden && Date.now() - polledAt >= (S?.me?.action?.fight || S?.me?.action?.run ? FIGHT_POLL_MS : POLL_MS)) refresh();
}, 500);
requestAnimationFrame(loop);
})();