polats Claude Opus 4.8 (1M context) commited on
Commit
f467b2b
·
1 Parent(s): 2394094

Rebuild comboBattler: combat HUD (adrenaline + threat)

Browse files

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. web/comboBattler.js +43 -2
web/comboBattler.js CHANGED
@@ -6172,7 +6172,16 @@ function mountComboBattler(pixi, host, opts = {}) {
6172
  window.removeEventListener("pointerup", onUp);
6173
  };
6174
  }
6175
- let skillRowEl = null;
 
 
 
 
 
 
 
 
 
6176
  function roundBtn(label, on, big) {
6177
  const b = document.createElement("button");
6178
  b.textContent = label;
@@ -6187,16 +6196,29 @@ function mountComboBattler(pixi, host, opts = {}) {
6187
  function rebuildSkillButtons() {
6188
  if (!skillRowEl) return;
6189
  skillRowEl.replaceChildren();
 
6190
  const bar = pa()?.bar || [];
6191
  bar.forEach((s, i) => {
 
6192
  const b = roundBtn(String(i + 1), () => {
6193
  req.skill = i + 1;
6194
  }, false);
6195
- b.title = s.name || "";
6196
  skillRowEl.appendChild(b);
 
6197
  });
6198
  skillRowEl.style.display = bar.length ? "flex" : "none";
6199
  }
 
 
 
 
 
 
 
 
 
 
6200
  function setHeroSkills(skills) {
6201
  const p = pa();
6202
  if (!p) return;
@@ -6265,11 +6287,26 @@ function mountComboBattler(pixi, host, opts = {}) {
6265
  skills.style.cssText = "display:flex;gap:8px;align-items:flex-end";
6266
  skillRowEl = skills;
6267
  rebuildSkillButtons();
 
 
 
 
 
 
 
 
 
 
 
 
6268
  pad.appendChild(skills);
6269
  pad.appendChild(roundBtn("\u2694", () => {
6270
  req.attack = true;
6271
  }, true));
6272
  wrap.appendChild(pad);
 
 
 
6273
  wrap._cleanup = () => {
6274
  window.removeEventListener("pointerup", up);
6275
  window.removeEventListener("pointercancel", up);
@@ -6381,6 +6418,7 @@ function mountComboBattler(pixi, host, opts = {}) {
6381
  }
6382
  }
6383
  updateEmotes(dt);
 
6384
  drawRings();
6385
  drawMarkers();
6386
  drawNav();
@@ -6501,6 +6539,9 @@ function mountComboBattler(pixi, host, opts = {}) {
6501
  }
6502
  controlsEl = null;
6503
  skillRowEl = null;
 
 
 
6504
  try {
6505
  markers?.destroy();
6506
  } catch {
 
6172
  window.removeEventListener("pointerup", onUp);
6173
  };
6174
  }
6175
+ let skillRowEl = null, adrFill = null, threatBadge = null;
6176
+ const skillBtns = [];
6177
+ function skillReady(a, s) {
6178
+ if (!a || !s) return false;
6179
+ if (s.cost?.adrenaline && a.adrenaline < s.cost.adrenaline) return false;
6180
+ if (s.cost?.energy && a.energy < s.cost.energy) return false;
6181
+ const rc = a.recharge?.[s.id];
6182
+ if (rc && battle && rc > battle.t) return false;
6183
+ return true;
6184
+ }
6185
  function roundBtn(label, on, big) {
6186
  const b = document.createElement("button");
6187
  b.textContent = label;
 
6196
  function rebuildSkillButtons() {
6197
  if (!skillRowEl) return;
6198
  skillRowEl.replaceChildren();
6199
+ skillBtns.length = 0;
6200
  const bar = pa()?.bar || [];
6201
  bar.forEach((s, i) => {
6202
+ const cost = s.cost?.adrenaline ? `${s.cost.adrenaline}adr` : s.cost?.energy ? `${s.cost.energy}en` : "";
6203
  const b = roundBtn(String(i + 1), () => {
6204
  req.skill = i + 1;
6205
  }, false);
6206
+ b.title = `${s.name || ""}${cost ? " \xB7 " + cost : ""}`;
6207
  skillRowEl.appendChild(b);
6208
+ skillBtns.push({ el: b, skill: s });
6209
  });
6210
  skillRowEl.style.display = bar.length ? "flex" : "none";
6211
  }
6212
+ function updateHud() {
6213
+ const p = pa();
6214
+ if (adrFill) adrFill.style.width = (p ? Math.round(p.adrenaline / 25 * 100) : 0) + "%";
6215
+ for (const sb of skillBtns) {
6216
+ const ok = skillReady(p, sb.skill);
6217
+ sb.el.style.opacity = ok ? "1" : "0.4";
6218
+ sb.el.style.borderColor = ok ? "#c9a227" : "#20262e";
6219
+ }
6220
+ if (threatBadge) threatBadge.textContent = `\u2694 ${runState.kills} THREAT ${runState.diff.toFixed(1)}\xD7`;
6221
+ }
6222
  function setHeroSkills(skills) {
6223
  const p = pa();
6224
  if (!p) return;
 
6287
  skills.style.cssText = "display:flex;gap:8px;align-items:flex-end";
6288
  skillRowEl = skills;
6289
  rebuildSkillButtons();
6290
+ const adrWrap = document.createElement("div");
6291
+ adrWrap.style.cssText = "width:150px;pointer-events:none";
6292
+ const adrLab = document.createElement("div");
6293
+ adrLab.textContent = "ADRENALINE";
6294
+ adrLab.style.cssText = "font:600 8px monospace;letter-spacing:.12em;color:#c9a227;text-align:right;margin-bottom:2px";
6295
+ const adrTrack = document.createElement("div");
6296
+ adrTrack.style.cssText = "height:6px;border-radius:4px;background:rgba(20,24,33,.7);border:1px solid #20262e;overflow:hidden";
6297
+ adrFill = document.createElement("div");
6298
+ adrFill.style.cssText = "height:100%;width:0%;background:linear-gradient(90deg,#c9a227,#ffe082);transition:width .1s linear";
6299
+ adrTrack.append(adrFill);
6300
+ adrWrap.append(adrLab, adrTrack);
6301
+ pad.appendChild(adrWrap);
6302
  pad.appendChild(skills);
6303
  pad.appendChild(roundBtn("\u2694", () => {
6304
  req.attack = true;
6305
  }, true));
6306
  wrap.appendChild(pad);
6307
+ threatBadge = document.createElement("div");
6308
+ threatBadge.style.cssText = "position:absolute;top:14px;left:50%;transform:translateX(-50%);pointer-events:none;padding:5px 12px;border-radius:999px;background:rgba(20,24,33,.8);border:1px solid #2a3340;color:#e8e8e8;font:700 12px monospace;letter-spacing:.04em";
6309
+ wrap.appendChild(threatBadge);
6310
  wrap._cleanup = () => {
6311
  window.removeEventListener("pointerup", up);
6312
  window.removeEventListener("pointercancel", up);
 
6418
  }
6419
  }
6420
  updateEmotes(dt);
6421
+ updateHud();
6422
  drawRings();
6423
  drawMarkers();
6424
  drawNav();
 
6539
  }
6540
  controlsEl = null;
6541
  skillRowEl = null;
6542
+ adrFill = null;
6543
+ threatBadge = null;
6544
+ skillBtns.length = 0;
6545
  try {
6546
  markers?.destroy();
6547
  } catch {