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:
@@ -29,8 +29,9 @@ describe('Tab barrel export', () => {
|
||||
|
||||
describe('Guardian data', () => {
|
||||
it('all guardians have required fields', async () => {
|
||||
const { GUARDIANS } = await import('@/lib/game/constants/guardians');
|
||||
for (const [floor, def] of Object.entries(GUARDIANS)) {
|
||||
const { getGuardianForFloor } = await import('@/lib/game/data/guardian-encounters');
|
||||
for (const floor of [10, 20, 30, 40, 50, 60, 80, 90, 100]) {
|
||||
const def = getGuardianForFloor(floor)!;
|
||||
expect(def.name).toBeTruthy();
|
||||
expect(def.element).toBeTruthy();
|
||||
expect(def.hp).toBeGreaterThan(0);
|
||||
@@ -49,10 +50,10 @@ describe('Guardian data', () => {
|
||||
});
|
||||
|
||||
it('guardians are defined at expected floors', async () => {
|
||||
const { GUARDIANS } = await import('@/lib/game/constants/guardians');
|
||||
const { getGuardianForFloor } = await import('@/lib/game/data/guardian-encounters');
|
||||
const expectedFloors = [10, 20, 30, 40, 50, 60, 80, 90, 100];
|
||||
for (const floor of expectedFloors) {
|
||||
expect(GUARDIANS[floor]).toBeDefined();
|
||||
expect(getGuardianForFloor(floor)).not.toBeNull();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -62,8 +63,9 @@ describe('Guardian data', () => {
|
||||
'critChance', 'critDamage', 'spellEfficiency', 'manaGain', 'insightGain',
|
||||
'studySpeed', 'prestigeInsight',
|
||||
];
|
||||
const { GUARDIANS } = await import('@/lib/game/constants/guardians');
|
||||
for (const def of Object.values(GUARDIANS)) {
|
||||
const { getGuardianForFloor } = await import('@/lib/game/data/guardian-encounters');
|
||||
for (const floor of [10, 20, 30, 40, 50, 60, 80, 90, 100]) {
|
||||
const def = getGuardianForFloor(floor)!;
|
||||
for (const boon of def.boons) {
|
||||
expect(validBoonTypes).toContain(boon.type);
|
||||
expect(boon.value).toBeGreaterThan(0);
|
||||
|
||||
Reference in New Issue
Block a user