Combat: rewards on the kill, 1s pause, swing timer runs on between enemies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
4cb6ff5ec0
commit
60b7b23a05
3 changed files with 61 additions and 15 deletions
|
|
@ -478,9 +478,17 @@ function fightLine(e, enemy) {
|
|||
}
|
||||
|
||||
function animateFight(now) {
|
||||
const panel = $("[data-fight]"), a = S.me?.action, f = a?.fight;
|
||||
if (!panel || !f) return;
|
||||
const a = S.me?.action, f = a?.fight;
|
||||
if (!f) return;
|
||||
const t = now - a.start;
|
||||
{
|
||||
let i = -1;
|
||||
while (i + 1 < f.events.length && f.events[i + 1][0] <= t) i++;
|
||||
const left = i >= 0 ? f.events[i][5] : f.enemy_hp;
|
||||
for (const el of document.querySelectorAll("[data-progress]")) el.style.width = `${left / f.enemy_hp * 100}%`;
|
||||
}
|
||||
const panel = $("[data-fight]");
|
||||
if (!panel) return;
|
||||
let shown = -1;
|
||||
while (shown + 1 < f.events.length && f.events[shown + 1][0] <= t) shown++;
|
||||
const last = f.events[shown];
|
||||
|
|
@ -506,7 +514,7 @@ function animateFight(now) {
|
|||
const lines = f.events.slice(Math.max(0, shown - 5), shown + 1).reverse().map((e) => fightLine(e, f.enemy));
|
||||
if (over) lines.unshift(f.result === "won" ? `<li class="good"><b>${esc(f.enemy)} is beaten.</b> The next one is coming…</li>`
|
||||
: `<li class="bad"><b>You fall back.</b></li>`);
|
||||
el.innerHTML = lines.join("") || `<li class="muted">Squaring up…</li>`;
|
||||
el.innerHTML = lines.join("") || `<li class="muted">${t < 0 ? "The next one is coming…" : "Squaring up…"}</li>`;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -634,7 +642,8 @@ function actionCard(a) {
|
|||
${io ? `<div class="io">${io}</div>` : ""}
|
||||
${extra}
|
||||
${me.action?.plot2 && (active || second) ? `<div class="small muted">Plot ${active ? 1 : 2}${growingNow ? " · growing now" : " · next"}</div>` : ""}
|
||||
${growingNow ? `<div class="bar thick"><span data-progress></span></div>` : ""}
|
||||
${growingNow && !a.enemy ? `<div class="bar thick"><span data-progress></span></div>` : ""}
|
||||
${active && a.enemy ? `<div><span class="tag gold">⚔️ Fighting</span></div>` : ""}
|
||||
${active && me.action.left ? `<div class="small muted">Just one${me.action.resume ? `, then back to ${esc(C.actions.find((x) => x.id === me.action.resume).name.toLowerCase())}` : ""}</div>` : ""}
|
||||
<div class="foot">
|
||||
<span class="why">${!active && !second && why ? esc(why) : ""}</span>
|
||||
|
|
@ -1158,7 +1167,8 @@ function animate() {
|
|||
animateFight(now);
|
||||
if (a) {
|
||||
const pct = Math.min(1, (now - a.start) / a.duration);
|
||||
for (const el of document.querySelectorAll("[data-progress]")) el.style.width = (pct * 100) + "%";
|
||||
// In a fight the bar is the enemy's health (set by animateFight), not a timer.
|
||||
if (!a.fight) for (const el of document.querySelectorAll("[data-progress]")) el.style.width = (pct * 100) + "%";
|
||||
if (pct >= 1 && refreshedFor !== a.start) {
|
||||
refreshedFor = a.start;
|
||||
setTimeout(refresh, 150);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue