Boss.selectBossType() is a broken dead stub — throws on any call (empty bossTypesForFloor) #810

Closed
opened 2026-07-23 04:59:07 +00:00 by spikerj · 1 comment
Owner

Bug (found via coverage wave 3, spikersoft-angular PR #551).

Boss.selectBossType(floor, rng) in projects/spikersoft/src/app/_components/_games/dungeon-crawler/models/boss.model.ts (~line 192) is an unfinished stub:

const bossTypesForFloor = [
  // Get 3 boss types for this floor
];
const selectedType = bossTypesForFloor[Math.floor(rng() * bossTypesForFloor.length)];
selectedType.name = this.translate(selectedType.translationKey); // TypeError: selectedType is undefined

bossTypesForFloor is always [], so selectedType is undefined and the next line throws Cannot set properties of undefined (setting name). The method can never succeed.

Currently dead — no caller (grep .selectBossType( finds none); the constructor uses the standalone selectRandomBossType(floor, rng) from boss-type.model.ts instead. So no runtime breakage today, but the method is a latent trap if anything ever calls it.

Fix: either delete the dead method, or implement it (populate bossTypesForFloor from getBossTypesForFloor(floor) and guard the empty case) and route the constructor through it.

Pinned as a characterization test in PR #551 (boss.model.spec.ts) asserting it currently throws, referencing this ticket; update when fixed.

**Bug (found via coverage wave 3, spikersoft-angular PR #551).** `Boss.selectBossType(floor, rng)` in `projects/spikersoft/src/app/_components/_games/dungeon-crawler/models/boss.model.ts` (~line 192) is an unfinished stub: ```ts const bossTypesForFloor = [ // Get 3 boss types for this floor ]; const selectedType = bossTypesForFloor[Math.floor(rng() * bossTypesForFloor.length)]; selectedType.name = this.translate(selectedType.translationKey); // TypeError: selectedType is undefined ``` `bossTypesForFloor` is always `[]`, so `selectedType` is `undefined` and the next line throws `Cannot set properties of undefined (setting name)`. The method can never succeed. Currently **dead** — no caller (`grep .selectBossType(` finds none); the constructor uses the standalone `selectRandomBossType(floor, rng)` from `boss-type.model.ts` instead. So no runtime breakage today, but the method is a latent trap if anything ever calls it. **Fix:** either delete the dead method, or implement it (populate `bossTypesForFloor` from `getBossTypesForFloor(floor)` and guard the empty case) and route the constructor through it. Pinned as a characterization test in PR #551 (`boss.model.spec.ts`) asserting it currently throws, referencing this ticket; update when fixed.
Author
Owner

Migrated to spikerj/spikersoft-angular#636 as part of the umbrella-tracker breakup.

Verified 2026-08-07 against the synced default branch.

  • Code: spikersoft-angular@8e5a4048 — still broken. projects/spikersoft/src/app/_components/_games/dungeon-crawler/models/boss.model.ts:194-199 still has the empty const bossTypesForFloor = [ /* Get 3 boss types for this floor */ ]; followed by an unguarded index and selectedType.name = ....
  • Live: Dead code — no caller (selectRandomBossType from boss-type.model.ts is used instead), so no runtime symptom to probe.
  • Remaining: Delete the dead method, or implement it (populate from getBossTypesForFloor(floor), guard the empty case) and route the constructor through it. Then update the characterization test in boss.model.spec.ts that currently asserts it throws.

Status: still broken — full detail carried over to the new issue.

Closing here. Work now lives in the repo that holds the fix, so fixes #636 in a PR will
auto-close it on merge. The umbrella tracker keeps cross-repo epics only.

— Opus 5 Agent

Migrated to **spikerj/spikersoft-angular#636** as part of the umbrella-tracker breakup. Verified 2026-08-07 against the synced default branch. - **Code:** `spikersoft-angular@8e5a4048` — still broken. `projects/spikersoft/src/app/_components/_games/dungeon-crawler/models/boss.model.ts:194-199` still has the empty `const bossTypesForFloor = [ /* Get 3 boss types for this floor */ ];` followed by an unguarded index and `selectedType.name = ...`. - **Live:** Dead code — no caller (`selectRandomBossType` from `boss-type.model.ts` is used instead), so no runtime symptom to probe. - **Remaining:** Delete the dead method, or implement it (populate from `getBossTypesForFloor(floor)`, guard the empty case) and route the constructor through it. Then update the characterization test in `boss.model.spec.ts` that currently asserts it throws. Status: still broken — full detail carried over to the new issue. Closing here. Work now lives in the repo that holds the fix, so `fixes #636` in a PR will auto-close it on merge. The umbrella tracker keeps cross-repo epics only. — Opus 5 Agent
Sign in to join this conversation.