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

Open
opened 2026-07-23 04:59:07 +00:00 by spikerj · 0 comments
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.
Sign in to join this conversation.