Task 2: Research Locking - prevent switching topics while study in progress

This commit is contained in:
Refactoring Agent
2026-04-26 10:56:39 +02:00
parent fc9e4c8327
commit 229cb16c5d
+24 -10
View File
@@ -267,7 +267,10 @@ export function SkillsTab() {
const baseCost = def.base * (level + 1) * currentTier; const baseCost = def.base * (level + 1) * currentTier;
const cost = Math.floor(baseCost * studyCostMult); const cost = Math.floor(baseCost * studyCostMult);
const canStudy = !maxed && prereqMet && store.rawMana >= cost && !isStudying; // 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(tieredSkillId, level); const milestoneInfo = hasMilestoneUpgrade(tieredSkillId, level);
const nextTierSkill = getNextTierSkill(tieredSkillId); const nextTierSkill = getNextTierSkill(tieredSkillId);
@@ -369,15 +372,26 @@ export function SkillsTab() {
<Badge className="bg-green-900/50 text-green-300">Maxed</Badge> <Badge className="bg-green-900/50 text-green-300">Maxed</Badge>
) : ( ) : (
<div className="flex gap-1"> <div className="flex gap-1">
<Button <TooltipProvider>
size="sm" <Tooltip>
variant={canStudy ? 'default' : 'outline'} <TooltipTrigger asChild>
disabled={!canStudy} <Button
className={canStudy ? 'bg-purple-600 hover:bg-purple-700' : 'opacity-50'} size="sm"
onClick={() => store.startStudyingSkill(tieredSkillId)} variant={canStudy ? 'default' : 'outline'}
> disabled={!canStudy}
Study ({fmt(cost)}) className={canStudy ? 'bg-purple-600 hover:bg-purple-700' : 'opacity-50'}
</Button> onClick={() => store.startStudyingSkill(tieredSkillId)}
>
Study ({fmt(cost)})
</Button>
</TooltipTrigger>
{!canStudy && isAnyStudyInProgress && !isStudying && (
<TooltipContent>
<p>Cannot switch topics while studying {SKILLS_DEF[store.currentStudyTarget?.id || '']?.name || 'another skill'}</p>
</TooltipContent>
)}
</Tooltip>
</TooltipProvider>
{/* Parallel Study button */} {/* Parallel Study button */}
{hasParallelStudy && {hasParallelStudy &&
store.currentStudyTarget && store.currentStudyTarget &&