Debug discipline XP buttons don't update totalXP or concurrentLimit #253

Closed
opened 2026-06-01 15:07:38 +02:00 by Anexim · 2 comments
Owner

Steps to reproduce:

  1. Open Debug tab → Disciplines section
  2. Click "+1K" on any discipline (e.g., Raw Mana Mastery)
  3. Observe "Active: X / Y" display

Expected: After adding 1000 XP, concurrentLimit should increase from 1 to 3 (formula: 1 + floor(totalXP / 500), max 4). With 2000+ total XP, limit should be 3.

Actual: "Active: 1 / 1" stays at limit 1 regardless of how much XP is added. The concurrentLimit never updates.

Root cause: The handleAddXP function in DisciplineDebugSection.tsx updates discipline XP directly via useDisciplineStore.setState(), but it only modifies disciplines[id].xp. It does NOT update totalXP or recalculate concurrentLimit. These values are only updated during processTick() in the discipline store, which only runs during the game tick loop (every 200ms). Since the game was paused during testing, no ticks fired.

Fix: In handleAddXP, also update totalXP by the same amount, and recalculate concurrentLimit using the formula Math.min(MAX_CONCURRENT_DISCIPLINES + Math.floor(newTotalXP / 500), MAX_CONCURRENT_DISCIPLINES + 3).

Affected file: src/components/game/tabs/DebugTab/DisciplineDebugSection.tsx (the handleAddXP function)

Store: useDisciplineStore (disciplines, totalXP, concurrentLimit)

**Steps to reproduce:** 1. Open Debug tab → Disciplines section 2. Click "+1K" on any discipline (e.g., Raw Mana Mastery) 3. Observe "Active: X / Y" display **Expected:** After adding 1000 XP, `concurrentLimit` should increase from 1 to 3 (formula: `1 + floor(totalXP / 500)`, max 4). With 2000+ total XP, limit should be 3. **Actual:** "Active: 1 / 1" stays at limit 1 regardless of how much XP is added. The `concurrentLimit` never updates. **Root cause:** The `handleAddXP` function in `DisciplineDebugSection.tsx` updates discipline XP directly via `useDisciplineStore.setState()`, but it only modifies `disciplines[id].xp`. It does NOT update `totalXP` or recalculate `concurrentLimit`. These values are only updated during `processTick()` in the discipline store, which only runs during the game tick loop (every 200ms). Since the game was paused during testing, no ticks fired. **Fix:** In `handleAddXP`, also update `totalXP` by the same amount, and recalculate `concurrentLimit` using the formula `Math.min(MAX_CONCURRENT_DISCIPLINES + Math.floor(newTotalXP / 500), MAX_CONCURRENT_DISCIPLINES + 3)`. **Affected file:** `src/components/game/tabs/DebugTab/DisciplineDebugSection.tsx` (the `handleAddXP` function) **Store:** `useDisciplineStore` (disciplines, totalXP, concurrentLimit)
Anexim added the ai:todo label 2026-06-01 15:07:38 +02:00
n8n-gitea was assigned by Anexim 2026-06-01 15:07:38 +02:00
Author
Owner

Starting fix. handleAddXP in DisciplineDebugSection.tsx only updates disciplines[id].xp but not totalXP or concurrentLimit. Fix: also update totalXP and recalculate concurrentLimit using the same formula as processTick.

Starting fix. handleAddXP in DisciplineDebugSection.tsx only updates disciplines[id].xp but not totalXP or concurrentLimit. Fix: also update totalXP and recalculate concurrentLimit using the same formula as processTick.
Author
Owner

Fixed: handleAddXP in DisciplineDebugSection.tsx now updates totalXP and recalculates concurrentLimit alongside disciplines[id].xp. The formula matches processTick: Math.min(MAX_CONCURRENT_DISCIPLINES + Math.floor(newTotalXP / 500), MAX_CONCURRENT_DISCIPLINES + 3). All 97 tests pass across DebugTab, discipline-math, and store-actions-discipline suites.

Fixed: handleAddXP in DisciplineDebugSection.tsx now updates totalXP and recalculates concurrentLimit alongside disciplines[id].xp. The formula matches processTick: `Math.min(MAX_CONCURRENT_DISCIPLINES + Math.floor(newTotalXP / 500), MAX_CONCURRENT_DISCIPLINES + 3)`. All 97 tests pass across DebugTab, discipline-math, and store-actions-discipline suites.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#253