🐛 Disciplines don't accumulate XP or drain mana when active #119
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug
When a discipline is activated, it does not accumulate XP or drain mana over time.
Investigation
The discipline tick processing logic in
src/lib/game/stores/discipline-slice.ts(processTickmethod) appears correct on paper — it iterates overactiveIds, checks mana availability, drains mana, and increments XP. However, there are several potential issues:activate()early-returns if id is already inactiveIds: The guardif (s.activeIds.includes(id)) return s;prevents re-activation of a discipline that was auto-paused byprocessTick(when mana runs out). The discipline stays inactiveIdswithpaused: true, soactivate()no-ops. This means once a discipline is auto-paused due to insufficient mana, the user cannot re-activate it.The
processTickmethod may not be called correctly from the tick pipeline: Need to verify thatstores/tick-pipeline.tscorrectly callsprocessTickon the discipline store and passes the current mana state.Mana drain calculation:
calculateManaDrain(def.drainBase, disc.xp, def.difficultyFactor)— ifdrainBaseis 0 or very low for some disciplines, the drain may be imperceptible.Files Involved
src/lib/game/stores/discipline-slice.ts(activate, deactivate, processTick)src/lib/game/stores/tick-pipeline.ts(tick orchestration)src/lib/game/utils/discipline-math.ts(calculateManaDrain)src/components/game/tabs/DisciplinesTab.tsx(UI)Suggested Fix
activate()to check!s.disciplines[id]?.pausedinstead of justactiveIds.includes(id), so auto-paused disciplines can be re-activated.processTickto confirm it's being called and disciplines are being processed each tick.✅ Fixed. Changes made:
discipline-slice.ts —
activate()now checks if the discipline is already inactiveIdsbut paused. If so, it un-pauses it (setspaused: false) instead of returning early. This allows re-activation of disciplines that were auto-paused byprocessTickwhen mana ran out.Previously:
if (s.activeIds.includes(id)) return s;— this blocked re-activation of auto-paused disciplines because they remained inactiveIds.Now: If the discipline is in
activeIdsand paused, it gets un-paused. If it's already active and not paused, it returns early (no-op).✅ Fixed discipline XP accumulation - activate() now properly handles auto-paused disciplines