fix: unify guardian system references across pact-utils, SpireSummaryTab, PactDebug, and PactDebugSection
- pact-utils.ts: Replace GUARDIANS[floor] with getGuardianForFloor() so pact multipliers work for extended guardians (floors 110+) - SpireSummaryTab.tsx: Use getGuardianForFloor()/getAllGuardianFloors() instead of static GUARDIANS constant; update type annotations to GuardianDef - PactDebug.tsx: Use unified guardian lookup; add null guards for getGuardianForFloor return type - PactDebugSection.tsx: Use unified guardian lookup; add null guards for getGuardianForFloor return type
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# Circular Dependencies
|
# Circular Dependencies
|
||||||
Generated: 2026-05-22T16:18:31.266Z
|
Generated: 2026-05-23T11:46:22.135Z
|
||||||
Found: 4 circular chain(s) — these MUST be fixed before modifying involved files.
|
Found: 4 circular chain(s) — these MUST be fixed before modifying involved files.
|
||||||
|
|
||||||
1. Processed 129 files (1.5s) (3 warnings)
|
1. Processed 129 files (1.5s) (3 warnings)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"generated": "2026-05-22T16:18:29.615Z",
|
"generated": "2026-05-23T11:46:20.479Z",
|
||||||
"description": "Import dependency graph for src/lib/game. Keys are files, values are arrays of files they import.",
|
"description": "Import dependency graph for src/lib/game. Keys are files, values are arrays of files they import.",
|
||||||
"usage": "To find what a file affects, search for its path in the VALUES. To find what a file depends on, look at its KEY entry."
|
"usage": "To find what a file affects, search for its path in the VALUES. To find what a file depends on, look at its KEY entry."
|
||||||
},
|
},
|
||||||
@@ -359,6 +359,7 @@
|
|||||||
"data/golems/types.ts"
|
"data/golems/types.ts"
|
||||||
],
|
],
|
||||||
"data/guardian-encounters.ts": [
|
"data/guardian-encounters.ts": [
|
||||||
|
"constants/guardians.ts",
|
||||||
"types.ts"
|
"types.ts"
|
||||||
],
|
],
|
||||||
"data/loot-drops.ts": [
|
"data/loot-drops.ts": [
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Bug } from 'lucide-react';
|
import { Bug } from 'lucide-react';
|
||||||
import { usePrestigeStore, useManaStore, useUIStore, useGameStore } from '@/lib/game/stores';
|
import { usePrestigeStore, useManaStore, useUIStore, useGameStore } from '@/lib/game/stores';
|
||||||
import { GUARDIANS, ELEMENTS } from '@/lib/game/constants';
|
import { ELEMENTS } from '@/lib/game/constants';
|
||||||
|
import { getGuardianForFloor, getAllGuardianFloors } from '@/lib/game/data/guardian-encounters';
|
||||||
|
|
||||||
// ─── Guardian Pact Row ───────────────────────────────────────────────────────
|
// ─── Guardian Pact Row ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -14,7 +15,8 @@ function GuardianPactRow({ floor, isSigned, onForceSign, onRemove }: {
|
|||||||
onForceSign: () => void;
|
onForceSign: () => void;
|
||||||
onRemove: () => void;
|
onRemove: () => void;
|
||||||
}) {
|
}) {
|
||||||
const guardian = GUARDIANS[floor];
|
const guardian = getGuardianForFloor(floor);
|
||||||
|
if (!guardian) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -56,7 +58,7 @@ function GuardianPactList({ signedPacts, onForceSign, onRemove }: {
|
|||||||
onForceSign: (floor: number) => void;
|
onForceSign: (floor: number) => void;
|
||||||
onRemove: (floor: number) => void;
|
onRemove: (floor: number) => void;
|
||||||
}) {
|
}) {
|
||||||
const guardianFloors = Object.keys(GUARDIANS || {}).map(Number).sort((a, b) => a - b);
|
const guardianFloors = getAllGuardianFloors();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2">
|
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2">
|
||||||
@@ -90,11 +92,11 @@ export function PactDebug() {
|
|||||||
const addLog = useUIStore((s) => s.addLog);
|
const addLog = useUIStore((s) => s.addLog);
|
||||||
|
|
||||||
const forcePact = (floor: number) => {
|
const forcePact = (floor: number) => {
|
||||||
const guardian = GUARDIANS[floor];
|
const guardian = getGuardianForFloor(floor);
|
||||||
if (!guardian) return;
|
if (!guardian) return;
|
||||||
|
|
||||||
if (signedPacts.includes(floor)) {
|
if (signedPacts.includes(floor)) {
|
||||||
addLog(`⚠️ Already signed pact with ${guardian.name}!`);
|
addLog(`\u26a0\ufe0f Already signed pact with ${guardian.name}!`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +123,7 @@ export function PactDebug() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const removePactHandler = (floor: number) => {
|
const removePactHandler = (floor: number) => {
|
||||||
const guardian = GUARDIANS[floor];
|
const guardian = getGuardianForFloor(floor);
|
||||||
|
|
||||||
removePact(floor);
|
removePact(floor);
|
||||||
|
|
||||||
@@ -129,7 +131,7 @@ export function PactDebug() {
|
|||||||
delete newSignedPactDetails[floor];
|
delete newSignedPactDetails[floor];
|
||||||
debugSetPactDetails(newSignedPactDetails);
|
debugSetPactDetails(newSignedPactDetails);
|
||||||
|
|
||||||
addLog(`📜 DEBUG: Removed pact with ${guardian?.name || 'Unknown'}!`);
|
addLog(`\ud83d\udcdc DEBUG: Removed pact with ${guardian ? guardian.name : 'Unknown'}!`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearAllPacts = () => {
|
const clearAllPacts = () => {
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Bug } from 'lucide-react';
|
import { Bug } from 'lucide-react';
|
||||||
import { usePrestigeStore, useManaStore, useUIStore, useGameStore } from '@/lib/game/stores';
|
import { usePrestigeStore, useManaStore, useUIStore, useGameStore } from '@/lib/game/stores';
|
||||||
import { GUARDIANS, ELEMENTS } from '@/lib/game/constants';
|
import { ELEMENTS } from '@/lib/game/constants';
|
||||||
|
import { getGuardianForFloor, getAllGuardianFloors } from '@/lib/game/data/guardian-encounters';
|
||||||
|
|
||||||
// ─── Guardian Pact Row ───────────────────────────────────────────────────────
|
// ─── Guardian Pact Row ───────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -14,7 +15,8 @@ function GuardianPactRow({ floor, isSigned, onForceSign, onRemove }: {
|
|||||||
onForceSign: () => void;
|
onForceSign: () => void;
|
||||||
onRemove: () => void;
|
onRemove: () => void;
|
||||||
}) {
|
}) {
|
||||||
const guardian = GUARDIANS[floor];
|
const guardian = getGuardianForFloor(floor);
|
||||||
|
if (!guardian) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -65,10 +67,10 @@ export function PactDebugSection() {
|
|||||||
|
|
||||||
const addLog = useUIStore((s) => s.addLog);
|
const addLog = useUIStore((s) => s.addLog);
|
||||||
|
|
||||||
const guardianFloors = Object.keys(GUARDIANS || {}).map(Number).sort((a, b) => a - b);
|
const guardianFloors = getAllGuardianFloors();
|
||||||
|
|
||||||
const forcePact = (floor: number) => {
|
const forcePact = (floor: number) => {
|
||||||
const guardian = GUARDIANS[floor];
|
const guardian = getGuardianForFloor(floor);
|
||||||
if (!guardian) return;
|
if (!guardian) return;
|
||||||
|
|
||||||
if (signedPacts.includes(floor)) {
|
if (signedPacts.includes(floor)) {
|
||||||
@@ -99,7 +101,7 @@ export function PactDebugSection() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const removePactHandler = (floor: number) => {
|
const removePactHandler = (floor: number) => {
|
||||||
const guardian = GUARDIANS[floor];
|
const guardian = getGuardianForFloor(floor);
|
||||||
|
|
||||||
removePact(floor);
|
removePact(floor);
|
||||||
|
|
||||||
@@ -107,7 +109,7 @@ export function PactDebugSection() {
|
|||||||
delete newSignedPactDetails[floor];
|
delete newSignedPactDetails[floor];
|
||||||
debugSetPactDetails(newSignedPactDetails);
|
debugSetPactDetails(newSignedPactDetails);
|
||||||
|
|
||||||
addLog(`📜 DEBUG: Removed pact with ${guardian?.name || 'Unknown'}!`);
|
addLog(`\ud83d\udcdc DEBUG: Removed pact with ${guardian ? guardian.name : 'Unknown'}!`);
|
||||||
};
|
};
|
||||||
|
|
||||||
const signAllPacts = () => {
|
const signAllPacts = () => {
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
import { useState, useEffect, useMemo } from 'react';
|
import { useState, useEffect, useMemo } from 'react';
|
||||||
import { useShallow } from 'zustand/react/shallow';
|
import { useShallow } from 'zustand/react/shallow';
|
||||||
import { useCombatStore, usePrestigeStore, fmt } from '@/lib/game/stores';
|
import { useCombatStore, usePrestigeStore, fmt } from '@/lib/game/stores';
|
||||||
import { GUARDIANS, ELEMENT_OPPOSITES, FLOOR_ELEM_CYCLE } from '@/lib/game/constants';
|
import { ELEMENT_OPPOSITES, FLOOR_ELEM_CYCLE } from '@/lib/game/constants';
|
||||||
|
import { getGuardianForFloor, getAllGuardianFloors } from '@/lib/game/data/guardian-encounters';
|
||||||
|
import type { GuardianDef } from '@/lib/game/types';
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Badge } from '@/components/ui/badge';
|
import { Badge } from '@/components/ui/badge';
|
||||||
@@ -14,9 +16,7 @@ import { Mountain } from 'lucide-react';
|
|||||||
|
|
||||||
// ─── Guardian Data ────────────────────────────────────────────────────────────
|
// ─── Guardian Data ────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const GUARDIAN_FLOORS = Object.keys(GUARDIANS)
|
const GUARDIAN_FLOORS = getAllGuardianFloors();
|
||||||
.map(Number)
|
|
||||||
.sort((a, b) => a - b);
|
|
||||||
|
|
||||||
// ─── Helper: Get Counter Element ─────────────────────────────────────────────
|
// ─── Helper: Get Counter Element ─────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -56,7 +56,7 @@ function FloorProgressBar({ maxFloor, clearedFloors }: { maxFloor: number; clear
|
|||||||
<div key={row[0]} className="flex gap-1">
|
<div key={row[0]} className="flex gap-1">
|
||||||
{row.map((floor) => {
|
{row.map((floor) => {
|
||||||
const isCleared = clearedSet.has(floor);
|
const isCleared = clearedSet.has(floor);
|
||||||
const isGuardian = !!GUARDIANS[floor];
|
const isGuardian = !!getGuardianForFloor(floor);
|
||||||
const isCurrent = floor === maxFloor;
|
const isCurrent = floor === maxFloor;
|
||||||
|
|
||||||
let bgClass = 'bg-gray-800';
|
let bgClass = 'bg-gray-800';
|
||||||
@@ -76,8 +76,8 @@ function FloorProgressBar({ maxFloor, clearedFloors }: { maxFloor: number; clear
|
|||||||
isGuardian ? 'font-bold' : ''
|
isGuardian ? 'font-bold' : ''
|
||||||
}`}
|
}`}
|
||||||
title={
|
title={
|
||||||
GUARDIANS[floor]
|
getGuardianForFloor(floor)
|
||||||
? `Floor ${floor} — ${GUARDIANS[floor].name} (${GUARDIANS[floor].element})`
|
? `Floor ${floor} — ${getGuardianForFloor(floor)!.name} (${getGuardianForFloor(floor)!.element})`
|
||||||
: `Floor ${floor}${isCleared ? ' (cleared)' : ''}`
|
: `Floor ${floor}${isCleared ? ' (cleared)' : ''}`
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -148,7 +148,7 @@ function StatCell({ value, label, color }: { value: number | string; label: stri
|
|||||||
|
|
||||||
// ─── Next Guardian Card ──────────────────────────────────────────────────────
|
// ─── Next Guardian Card ──────────────────────────────────────────────────────
|
||||||
|
|
||||||
function NextGuardianCard({ nextGuardian, nextGuardianData }: { nextGuardian: number; nextGuardianData: (typeof GUARDIANS)[number] }) {
|
function NextGuardianCard({ nextGuardian, nextGuardianData }: { nextGuardian: number; nextGuardianData: GuardianDef }) {
|
||||||
const counterElement = getCounterElement(nextGuardianData.element);
|
const counterElement = getCounterElement(nextGuardianData.element);
|
||||||
const nextFloorElement = FLOOR_ELEM_CYCLE[(nextGuardian - 1) % FLOOR_ELEM_CYCLE.length];
|
const nextFloorElement = FLOOR_ELEM_CYCLE[(nextGuardian - 1) % FLOOR_ELEM_CYCLE.length];
|
||||||
|
|
||||||
@@ -244,16 +244,19 @@ function GuardianRoster({ clearedFloors }: { clearedFloors: Record<number, boole
|
|||||||
<SectionHeader title="🏛️ Guardian Roster" />
|
<SectionHeader title="🏛️ Guardian Roster" />
|
||||||
<CardContent className="pt-0">
|
<CardContent className="pt-0">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
{GUARDIAN_FLOORS.map((floor) => (
|
{GUARDIAN_FLOORS.map((floor) => {
|
||||||
<GuardianRosterItem key={floor} floor={floor} guardian={GUARDIANS[floor]} isDefeated={!!clearedFloors[floor]} />
|
const guardian = getGuardianForFloor(floor);
|
||||||
))}
|
return guardian ? (
|
||||||
|
<GuardianRosterItem key={floor} floor={floor} guardian={guardian} isDefeated={!!clearedFloors[floor]} />
|
||||||
|
) : null;
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function GuardianRosterItem({ floor, guardian, isDefeated }: { floor: number; guardian: (typeof GUARDIANS)[number]; isDefeated: boolean }) {
|
function GuardianRosterItem({ floor, guardian, isDefeated }: { floor: number; guardian: GuardianDef; isDefeated: boolean }) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`flex items-center justify-between p-2 rounded border ${
|
className={`flex items-center justify-between p-2 rounded border ${
|
||||||
@@ -338,7 +341,7 @@ export function SpireSummaryTab() {
|
|||||||
return GUARDIAN_FLOORS.find((floor) => !clearedFloors[floor]) || null;
|
return GUARDIAN_FLOORS.find((floor) => !clearedFloors[floor]) || null;
|
||||||
}, [clearedFloors]);
|
}, [clearedFloors]);
|
||||||
|
|
||||||
const nextGuardianData = nextGuardian ? GUARDIANS[nextGuardian] : null;
|
const nextGuardianData = nextGuardian ? getGuardianForFloor(nextGuardian) : null;
|
||||||
|
|
||||||
const totalFloorsCleared = useMemo(() => {
|
const totalFloorsCleared = useMemo(() => {
|
||||||
return Object.values(clearedFloors).filter(Boolean).length;
|
return Object.values(clearedFloors).filter(Boolean).length;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// ─── Pact Utility Functions ───────────────────────────────────────────────────
|
// ─── Pact Utility Functions ───────────────────────────────────────────────────
|
||||||
|
|
||||||
import { GUARDIANS } from '../constants';
|
import { getGuardianForFloor } from '../data/guardian-encounters';
|
||||||
|
|
||||||
export function computePactMultiplier(state: {
|
export function computePactMultiplier(state: {
|
||||||
signedPacts: number[];
|
signedPacts: number[];
|
||||||
@@ -12,7 +12,7 @@ export function computePactMultiplier(state: {
|
|||||||
|
|
||||||
let baseMult = 1.0;
|
let baseMult = 1.0;
|
||||||
for (const floor of signedPacts) {
|
for (const floor of signedPacts) {
|
||||||
const guardian = GUARDIANS[floor];
|
const guardian = getGuardianForFloor(floor);
|
||||||
if (guardian) {
|
if (guardian) {
|
||||||
baseMult *= guardian.damageMultiplier;
|
baseMult *= guardian.damageMultiplier;
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ export function computePactInsightMultiplier(state: {
|
|||||||
|
|
||||||
let mult = 1.0;
|
let mult = 1.0;
|
||||||
for (const floor of signedPacts) {
|
for (const floor of signedPacts) {
|
||||||
const guardian = GUARDIANS[floor];
|
const guardian = getGuardianForFloor(floor);
|
||||||
if (guardian) {
|
if (guardian) {
|
||||||
mult *= guardian.insightMultiplier;
|
mult *= guardian.insightMultiplier;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user