'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 (
Increases the power of all enchantments by {((upgradeEffects?.enchantmentPowerMultiplier || 1) - 1) * 100}%. Multiplier applied to all enchantment effects.