dungeon ExperienceBarHUD: required=0 fill disagrees between updateState and resize #1091

Closed
opened 2026-08-13 13:56:24 +00:00 by spikerj · 1 comment
Owner

Wave 8 coverage a3 (ExperienceBarHUD in projects/spikersoft/src/app/_components/_games/dungeon-crawler/hud/experience-bar-hud.ts).

updateState and buildUI disagree when required is 0:

  • updateState: uValue = clamp(xp / (required || 1)) → 50 XP / 0 required paints a full bar (1).
  • buildUI (constructor + resize): ratio = required > 0 ? xp / required : 0 → the same state paints an empty bar (0).

Repro (unit, jsdom, mocked troika — no GPU):

  1. Construct ExperienceBarHUD(800, 600).
  2. updateState(50, 0) → uValue === 1, label "50 / 0".
  3. resize(1024, 768) → uValue === 0, label still "50 / 0".

Expected: one rule for a zero requirement (treat as 1, or force empty, or hide the bar) so a window resize cannot empty a bar that updateState just filled.

Covered by experience-bar-hud.spec.ts (“treats required=0 as 1 in updateState… but resize rebuilds to empty”).

Wave 8 coverage a3 (`ExperienceBarHUD` in `projects/spikersoft/src/app/_components/_games/dungeon-crawler/hud/experience-bar-hud.ts`). `updateState` and `buildUI` disagree when `required` is 0: - `updateState`: `uValue = clamp(xp / (required || 1))` → 50 XP / 0 required paints a **full** bar (`1`). - `buildUI` (constructor + `resize`): `ratio = required > 0 ? xp / required : 0` → the same state paints an **empty** bar (`0`). Repro (unit, jsdom, mocked troika — no GPU): 1. Construct `ExperienceBarHUD(800, 600)`. 2. `updateState(50, 0)` → `uValue === 1`, label `"50 / 0"`. 3. `resize(1024, 768)` → `uValue === 0`, label still `"50 / 0"`. Expected: one rule for a zero requirement (treat as 1, or force empty, or hide the bar) so a window resize cannot empty a bar that `updateState` just filled. Covered by `experience-bar-hud.spec.ts` (“treats required=0 as 1 in updateState… but resize rebuilds to empty”).
Author
Owner

Resolved in spikersoft-angular PR #819 (merged to master). ExperienceBarHUD required=0 fill agrees between updateState and resize. Closing.

Resolved in spikersoft-angular [PR #819](https://git.spikersoft.com/spikerj/spikersoft-angular/pulls/819) (merged to `master`). ExperienceBarHUD required=0 fill agrees between updateState and resize. Closing.
Sign in to join this conversation.