refactor: remove GUARDIANS constant, consolidate into guardian-data.ts

- Delete src/lib/game/constants/guardians.ts (the old static GUARDIANS constant)
- Create src/lib/game/data/guardian-data.ts with BASE_GUARDIANS (same data, new home)
- Remove GUARDIANS export from constants/index.ts
- Update all 11 files that imported GUARDIANS to use getGuardianForFloor() or BASE_GUARDIANS:
  - useGameDerived.ts, combat-actions.ts, gameStore.ts, prestigeStore.ts
  - combat-utils.ts, room-utils.ts, floor-utils.ts, spire-utils.ts
  - SpireCombatPage.tsx, SpireHeader.tsx
- Update 4 test files to use getGuardianForFloor() instead of GUARDIANS constant
- guardian-encounters.ts now imports BASE_GUARDIANS from guardian-data.ts
- Split room-utils.test.ts (505 lines) into room-utils.test.ts + room-utils-floor-state.test.ts
This commit is contained in:
2026-05-23 16:09:19 +02:00
parent d7b822d965
commit 513cab81a3
21 changed files with 228 additions and 217 deletions
+8 -11
View File
@@ -265,27 +265,24 @@ export function getExtendedGuardian(floor: number): GuardianDef | null {
}
// ─── Unified Guardian System ─────────────────────────────────────────────────
// Merges the static GUARDIANS constant (floors 10100) with the extended
// procedural system (compound 110, exotic 120140, combo 150+).
// For floors 90100 the static definitions take precedence (canonical names).
// Merges the base guardians (floors 10100) with the extended procedural system
// (compound 110, exotic 120140, combo 150+).
import { GUARDIANS } from '../constants/guardians';
import { BASE_GUARDIANS } from './guardian-data';
/** Get the guardian for any floor, merging static and extended systems. */
export function getGuardianForFloor(floor: number): GuardianDef | null {
// Static GUARDIANS take precedence for floors 10100 (canonical definitions)
if (GUARDIANS[floor]) {
return { ...GUARDIANS[floor] };
if (BASE_GUARDIANS[floor]) {
return { ...BASE_GUARDIANS[floor] };
}
// Extended system for floors beyond 100 (and compound floors not in GUARDIANS)
return getExtendedGuardian(floor);
}
/** All guardian floors — merged from static + extended. */
/** All guardian floors — merged from base + extended. */
export function getAllGuardianFloors(): number[] {
const staticFloors = Object.keys(GUARDIANS).map(Number);
const baseFloors = Object.keys(BASE_GUARDIANS).map(Number);
const extendedFloors = [110, 120, 130, 140, ...Array.from({ length: 10 }, (_, i) => 150 + i * 10)];
const all = new Set([...staticFloors, ...extendedFloors]);
const all = new Set([...baseFloors, ...extendedFloors]);
return Array.from(all).sort((a, b) => a - b);
}