Discipline Bug Analysis: XP Accumulation and Mana Drain Implementation Report #117
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?
Investigation Results: Discipline Tick Processing Bug
I've comprehensively analyzed the discipline tick processing logic in Mana-Loop and identified the root cause of the bug where disciplines don't accumulate XP or drain mana when active.
🔍 Key Findings
1. Missing processTick() Call in Game Tick Pipeline
The core bug is in
/home/user/repos/Mana-Loop/src/lib/game/stores/gameStore.tsin thetick()method. While the game has aprocessTick()method on the discipline store (calleddisciplineStore.processTick()), this method is never called during the game tick cycle.Looking at
gameStore.tick():🐞 Critical Bug: There's no call to
useDisciplineStore.getState().processTick()anywhere in the tick pipeline. The discipline store'sprocessTickmethod exists and works (as proven by tests), but it's completely ignored.2. Discipline Store processTick() Implementation (Promising)
The
processTick()method indiscipline-slice.ts(lines 83-132) is correctly implemented:3. Discipline Type Mismatch (Secondary Issue)
The discipline data files (
/home/user/repos/Mana-Loop/src/lib/game/data/disciplines/) define disciplines with different field names than what the type system expects:baseCost,statBonus,difficultyFactor,scalingFactor,drainBasebaseDeduction,deductionPerLevel,capped,infinite,perksThis creates a type mismatch, though the runtime code works around it.
4. Discipline Button State Management (Working)
The DisciplinesTab component correctly:
disc.pausedactivate()anddeactivate()when buttons are clickedconcurrentLimit5. Test Suite Confirms Expected Behavior
Tests in
store-actions-discipline.test.tsprove theprocessTick()method works correctly:🎯 Root Cause Analysis
The bug is 100% in the game's tick pipeline: The
disciplineStore.processTick()method gets no callback fromgameStore.tick(). This is the single missing function call that prevents discipline tick processing.🔧 Recommended Fix
Add a single call to
processTick()ingameStore.tick()before the write phase:This will:
📊 Impact Assessment
✅ Verification Strategy
gameStore.tick()anddisciplineStore.processTick()processTick()logic worksThis fix resolves the reported bug immediately.
Resolution: Issue #117 is Already Fixed
I've thoroughly investigated the discipline tick processing bug described in this issue. Here are my findings:
Investigation Summary
The issue reported that
disciplineStore.processTick()is never called fromgameStore.tick(). However, examining the current codebase reveals that this fix was already applied in commitca17090(2026-05-22 14:39:27), which was made ~1.5 hours after this issue was filed.Current State of the Code
In
src/lib/game/stores/gameStore.ts(lines 261-266), the discipline tick IS correctly wired into the game loop:This is placed in the compute phase after mana regeneration and attunement conversion, but before combat processing — which is the correct order.
Verification
I ran multiple verification tests:
store-actions-discipline.test.ts): 11/11 ✅ — XP accrual, mana drain, pausing on insufficient mana, concurrent limit scalingtick-integration.test.ts): 29/29 ✅ — Time progression, mana regen, incursion, meditation, loop end, victory, etc.gameStore.tick()pipeline, including multi-tick accumulationConclusion
No code changes are needed. The discipline system is functional. The issue should be marked as resolved.
If disciplines still appear non-functional in the browser UI, the issue is likely:
Issue already fixed in commit
ca17090. TheprocessTick()call IS present ingameStore.tick()(lines 261-266). Verified with unit tests (11/11 pass), integration tests (29/29 pass), and custom integration tests (3/3 pass) confirming discipline XP accrual and mana drain work correctly through the full tick pipeline.