'use client'; import { useGameStore, fmt, fmtDec } from '@/lib/game/store'; import { SKILLS_DEF, SKILL_CATEGORIES } from '@/lib/game/constants'; import { getNextTierSkill, getTierMultiplier } from '@/lib/game/skill-evolution'; import { computeEffects } from '@/lib/game/upgrade-effects'; import { useStudyStats } from '@/lib/game/hooks/useGameDerived'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'; import { formatStudyTime, hasMilestoneUpgrade, getSkillDisplayInfo } from './skills-utils'; interface SkillRowProps { skillId: string; onUpgradeClick: (skillId: string, milestone: 5 | 10) => void; } export function SkillRow({ skillId, onUpgradeClick }: SkillRowProps) { const store = useGameStore(); const { studySpeedMult, studyCostMult, hasParallelStudy } = useStudyStats(); const skillInfo = getSkillDisplayInfo(store, skillId); const { currentTier, tieredSkillId, tierMultiplier, level, maxed, isStudying, skillDisplayName, prereqMet, def } = skillInfo; // Apply skill modifiers const studyEffects = computeEffects(store.skillUpgrades || {}, store.skillTiers || {}); const effectiveSpeedMult = studySpeedMult * studyEffects.studySpeedMultiplier; const tierStudyTime = def.studyTime * currentTier; const effectiveStudyTime = tierStudyTime / effectiveSpeedMult; const baseCost = def.base * (level + 1) * currentTier; const cost = Math.floor(baseCost * studyCostMult); // Check if any study is in progress (prevent switching topics) const isAnyStudyInProgress = store.currentAction === 'study' && store.currentStudyTarget; // Can only study if: not maxed, prereqs met, has mana, and either no study in progress or already studying this skill const canStudy = !maxed && prereqMet && store.rawMana >= cost && (!isAnyStudyInProgress || isStudying); const milestoneInfo = hasMilestoneUpgrade(store, tieredSkillId, level); const nextTierSkill = getNextTierSkill(tieredSkillId); const canTierUp = maxed && nextTierSkill; const selectedUpgrades = store.skillUpgrades[tieredSkillId] || []; const selectedL5 = selectedUpgrades.filter(u => u.includes('_l5')); const selectedL10 = selectedUpgrades.filter(u => u.includes('_l10')); return (
Cannot switch topics while studying {SKILLS_DEF[store.currentStudyTarget?.id || '']?.name || 'another skill'}
Study in parallel (50% speed)