'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 (
{skillDisplayName} {currentTier > 1 && ( Tier {currentTier} ({fmtDec(tierMultiplier, 0)}x) )} {level > 0 && Lv.{level}} {selectedUpgrades.length > 0 && (
{selectedL5.length > 0 && ( L5: {selectedL5.length} )} {selectedL10.length > 0 && ( L10: {selectedL10.length} )}
)}
{def.desc}{currentTier > 1 && ` (Tier ${currentTier}: ${fmtDec(tierMultiplier, 0)}x effect)`}
{!prereqMet && def.req && (
Requires: {Object.entries(def.req).map(([r, rl]) => `${SKILLS_DEF[r]?.name} Lv.${rl}`).join(', ')}
)}
1 ? 'text-green-400' : ''}> Study: {formatStudyTime(effectiveStudyTime)}{effectiveSpeedMult > 1 && ({Math.round(effectiveSpeedMult * 100)}% speed)} {' • '} Cost: {fmt(cost)} mana{studyCostMult < 1 && ({Math.round(studyCostMult * 100)}% cost)}
{milestoneInfo && (
⭐ Level {milestoneInfo.milestone} milestone: {milestoneInfo.selectedCount}/2 upgrades selected
)}
{/* Level dots */}
{Array.from({ length: def.max }).map((_, i) => (
))}
{isStudying ? (
{formatStudyTime(store.currentStudyTarget?.progress || 0)}/{formatStudyTime(tierStudyTime)}
) : milestoneInfo ? ( ) : canTierUp ? ( ) : maxed ? ( Maxed ) : (
{!canStudy && isAnyStudyInProgress && !isStudying && (

Cannot switch topics while studying {SKILLS_DEF[store.currentStudyTarget?.id || '']?.name || 'another skill'}

)}
{/* Parallel Study button */} {hasParallelStudy && store.currentStudyTarget && !store.parallelStudyTarget && store.currentStudyTarget.id !== tieredSkillId && canStudy && (

Study in parallel (50% speed)

)}
)}
); }