'use client';
import { useState, useCallback } from 'react';
import { useShallow } from 'zustand/react/shallow';
import { usePrestigeStore, useGameStore } from '@/lib/game/stores';
import { PRESTIGE_DEF } from '@/lib/game/constants/prestige';
import { Card, CardContent } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { ScrollArea } from '@/components/ui/scroll-area';
import { SectionHeader } from '@/components/ui/section-header';
import { DebugName } from '@/components/game/debug/debug-context';
import { fmt } from '@/lib/game/stores';
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from '@/components/ui/alert-dialog';
// ─── Stat Cell ────────────────────────────────────────────────────────────────
function PrestigeStatCell({ value, label, color }: { value: string | number; label: string; color: string }) {
return (
);
}
// ─── Insight Summary ──────────────────────────────────────────────────────────
function InsightSummary({ insight, totalInsight, loopCount, loopInsight }: {
insight: number;
totalInsight: number;
loopCount: number;
loopInsight: number;
}) {
return (
);
}
// ─── Pacts Card ───────────────────────────────────────────────────────────────
function PactsCard({ signedPacts, pactSlots, defeatedGuardians }: {
signedPacts: number[];
pactSlots: number;
defeatedGuardians: number[];
}) {
return (
Guardian pacts signed. Slots: {signedPacts.length}/{pactSlots}
{defeatedGuardians.length > 0 && (
Defeated guardians: {defeatedGuardians.map((f) => `F${f}`).join(', ')}
)}
{signedPacts.length === 0 ? (
No pacts signed yet.
) : (
{signedPacts.map((f) => (
✓ Floor {f} — Pact signed
))}
)}
);
}
// ─── Upgrade Card ─────────────────────────────────────────────────────────────
interface UpgradeCardProps {
id: string;
name: string;
desc: string;
max: number;
cost: number;
currentLevel: number;
insight: number;
onPurchase: (id: string) => void;
}
function UpgradeCard({ id, name, desc, max, cost, currentLevel, insight, onPurchase }: UpgradeCardProps) {
const isMaxed = currentLevel >= max;
const canAfford = insight >= cost;
const disabled = isMaxed || !canAfford;
return (
{name}
{currentLevel}/{max}
{desc}
Cost: {fmt(cost)} insight
);
}
// ─── Reset Loop Section ──────────────────────────────────────────────────────
function ResetLoopSection({ loopInsight, onReset }: { loopInsight: number; onReset: () => void }) {
return (
Reset Loop
End the current loop and gain {fmt(loopInsight)} insight. Your prestige upgrades and pacts are preserved.
Reset the Loop?
This will end your current loop and award you {fmt(loopInsight)} insight.
Your prestige upgrades and pacts will be preserved.
Day, hour, mana, floor progress, and combat state will be reset.
Cancel
Confirm Reset
);
}
// ─── Main Component ───────────────────────────────────────────────────────────
export function PrestigeTab() {
const {
insight,
totalInsight,
loopInsight,
loopCount,
prestigeUpgrades,
pactSlots,
signedPacts,
defeatedGuardians,
doPrestige,
} = usePrestigeStore(useShallow((s) => ({
insight: s.insight,
totalInsight: s.totalInsight,
loopInsight: s.loopInsight,
loopCount: s.loopCount,
prestigeUpgrades: s.prestigeUpgrades,
pactSlots: s.pactSlots,
signedPacts: s.signedPacts,
defeatedGuardians: s.defeatedGuardians,
doPrestige: s.doPrestige,
})));
const startNewLoop = useGameStore((s) => s.startNewLoop);
const handlePurchase = useCallback((id: string) => {
doPrestige(id);
}, [doPrestige]);
const handleResetLoop = useCallback(() => {
startNewLoop();
}, [startNewLoop]);
const upgradeEntries = Object.entries(PRESTIGE_DEF);
return (
{upgradeEntries.map(([id, def]) => (
))}
);
}
PrestigeTab.displayName = 'PrestigeTab';