'use client'; import { ELEMENTS, GUARDIANS } from '@/lib/game/constants'; import { getTierMultiplier } from '@/lib/game/skill-evolution'; import { hasSpecial, SPECIAL_EFFECTS } from '@/lib/game/effects'; import { getUnifiedEffects } from '@/lib/game/effects'; import { fmt, fmtDec, computeMaxMana, computeRegen, computeClickMana, getMeditationBonus, getIncursionStrength, getStudySpeedMultiplier, getStudyCostMultiplier } from '@/lib/game/stores'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Separator } from '@/components/ui/separator'; import { FlaskConical, Trophy, RotateCcw } from 'lucide-react'; import { ManaStatsSection } from '../stats/ManaStatsSection'; import { ManaTypeBreakdown } from '../stats/ManaTypeBreakdown'; import { CombatStatsSection } from '../stats/CombatStatsSection'; import { StudyStatsSection } from '../stats/StudyStatsSection'; import { UpgradeEffectsSection } from '../stats/UpgradeEffectsSection'; // Modular stores import { useCombatStore, useManaStore, useSkillStore, usePrestigeStore, useGameStore } from '@/lib/game/stores'; export function StatsTab() { // Get state from modular stores const skills = useSkillStore((s) => s.skills); const skillTiers = useSkillStore((s) => s.skillTiers); const skillUpgrades = useSkillStore((s) => s.skillUpgrades); const prestigeUpgrades = usePrestigeStore((s) => s.prestigeUpgrades); const loopCount = usePrestigeStore((s) => s.loopCount); const insight = usePrestigeStore((s) => s.insight); const totalInsight = usePrestigeStore((s) => s.totalInsight); const memorySlots = usePrestigeStore((s) => s.memorySlots); const signedPacts = usePrestigeStore((s) => s.signedPacts); const elements = useManaStore((s) => s.elements); const totalManaGathered = useManaStore((s) => s.totalManaGathered); const rawMana = useManaStore((s) => s.rawMana); const meditateTicks = useManaStore((s) => s.meditateTicks); const maxFloorReached = useCombatStore((s) => s.maxFloorReached); const spells = useCombatStore((s) => s.spells); // Compute unified effects const upgradeEffects = getUnifiedEffects({ skillUpgrades, skillTiers, equippedInstances: {}, equipmentInstances: {} }); // Compute derived stats const maxMana = computeMaxMana({ skills, prestigeUpgrades, skillUpgrades, skillTiers }, upgradeEffects); const baseRegen = computeRegen({ skills, prestigeUpgrades, skillUpgrades, skillTiers }, upgradeEffects); const clickMana = computeClickMana({ skills, prestigeUpgrades, skillUpgrades, skillTiers }); const meditationMultiplier = getMeditationBonus(meditateTicks, skills, upgradeEffects.meditationEfficiency); const day = useGameStore((s) => s.day); const hour = useGameStore((s) => s.hour); const incursionStrength = getIncursionStrength(day, hour); // Effective regen with incursion penalty const effectiveRegenWithSpecials = baseRegen * (1 - incursionStrength); // Mana Cascade bonus const manaCascadeBonus = hasSpecial(upgradeEffects, SPECIAL_EFFECTS.MANA_CASCADE) ? Math.floor(maxMana / 100) * 0.1 : 0; // Mana Waterfall bonus const manaWaterfallBonus = hasSpecial(upgradeEffects, SPECIAL_EFFECTS.MANA_WATERFALL) ? Math.floor(maxMana / 100) * 0.25 : 0; // Effective regen const effectiveRegen = (effectiveRegenWithSpecials + manaCascadeBonus + manaWaterfallBonus) * meditationMultiplier; // Get study speed/cost multipliers const studySpeedMult = getStudySpeedMultiplier(skills); const studyCostMult = getStudyCostMultiplier(skills); // Check special effects const hasManaWaterfall = hasSpecial(upgradeEffects, SPECIAL_EFFECTS.MANA_WATERFALL); const hasFlowSurge = hasSpecial(upgradeEffects, SPECIAL_EFFECTS.FLOW_SURGE); const hasManaOverflow = hasSpecial(upgradeEffects, SPECIAL_EFFECTS.MANA_OVERFLOW); const hasEternalFlow = hasSpecial(upgradeEffects, SPECIAL_EFFECTS.ETERNAL_FLOW); // Compute element max const elemMax = (() => { const ea = skillTiers?.elemAttune || 1; const tieredSkillId = ea > 1 ? `elemAttune_t${ea}` : 'elemAttune'; const level = skills[tieredSkillId] || skills.elemAttune || 0; const tierMult = getTierMultiplier(tieredSkillId); return 10 + level * 50 * tierMult + (prestigeUpgrades.elementalAttune || 0) * 25; })(); return (
{/* Mana Stats */} {/* Mana Type Breakdown */} {/* Combat Stats */} {/* Study Stats */} {/* Element Stats */} Element Stats
Element Capacity: {elemMax}
Elem. Attunement Bonus: {(() => { const ea = skillTiers?.elemAttune || 1; const tieredSkillId = ea > 1 ? `elemAttune_t${ea}` : 'elemAttune'; const level = skills[tieredSkillId] || skills.elemAttune || 0; const tierMult = getTierMultiplier(tieredSkillId); return `+${level * 50 * tierMult}`; })()}
Prestige Attunement: +{(prestigeUpgrades.elementalAttune || 0) * 25}
Unlocked Elements: {Object.values(elements).filter(e => e.unlocked).length} / {Object.keys(ELEMENTS).length}
Elem. Crafting Bonus: ×{fmtDec(1 + (skills.elemCrafting || 0) * 0.25, 2)}
Elemental Mana Pools:
{Object.entries(elements) .filter(([, state]) => state.unlocked) .map(([id, state]) => { const def = ELEMENTS[id]; return (
{def?.sym}
{state.current}/{state.max}
); })}
{/* Active Upgrades */} {/* Enchantment Power */} ✨ Enchantment Power
Enchantment Power: {upgradeEffects?.enchantmentPowerMultiplier?.toFixed(2) || '1.0'}×

Increases the power of all enchantments by {((upgradeEffects?.enchantmentPowerMultiplier || 1) - 1) * 100}%. Multiplier applied to all enchantment effects.

{/* Pact Bonuses */} Signed Pacts ({signedPacts.length}/10) {signedPacts.length === 0 ? (
No pacts signed yet. Defeat guardians to earn pacts.
) : (
{signedPacts.map((floor) => { const guardian = GUARDIANS[floor]; if (!guardian) return null; return (
{guardian.name}
Floor {floor}
{guardian.pact}x multiplier
); })}
Combined Pact Multiplier: ×{fmtDec(signedPacts.reduce((m, f) => m * (GUARDIANS[f]?.pact || 1), 1), 2)}
)}
{/* Loop Stats */} Loop Stats
{loopCount}
Loops Completed
{fmt(insight)}
Current Insight
{fmt(totalInsight)}
Total Insight
{maxFloorReached}
Max Floor
{Object.values(spells).filter(s => s.learned).length}
Spells Learned
{Object.values(skills).reduce((a, b) => a + b, 0)}
Total Skill Levels
{fmt(totalManaGathered)}
Total Mana Gathered
{memorySlots}
Memory Slots
); } StatsTab.displayName = "StatsTab";