[priority: critical] Discipline bonuses lost when discipline is paused/deactivated #129

Closed
opened 2026-05-25 11:36:11 +02:00 by Anexim · 2 comments
Owner

Bug: Discipline bonuses are lost when discipline is no longer active

Description

When a discipline is paused or deactivated, all stat bonuses from that discipline are lost. The bonuses should persist based on accumulated XP even after the discipline is no longer actively being practiced.

Root Cause

In src/lib/game/effects/discipline-effects.ts, the computeDisciplineEffects() function only iterates over active (non-paused) disciplines:

const activeDiscs = Object.entries(disciplines)
  .filter(([, disc]) => disc && !disc.paused)
  .map(...)

This means any discipline that has been paused (i.e. disc.paused === true) contributes zero bonuses, regardless of how much XP was earned. The XP is still stored in the discipline state, but it's simply not used for bonus calculation.

Expected Behavior

  • Bonuses from disciplines should be calculated from all disciplines that have XP > 0, regardless of whether they are currently active/paused.
  • The player earned those bonuses through practice; they should not disappear when the player stops practicing.
  • Only the mana drain and XP accrual should stop when a discipline is paused — not the stat bonuses.

Files Involved

  • src/lib/game/effects/discipline-effects.tscomputeDisciplineEffects() only looks at non-paused disciplines
  • src/lib/game/stores/discipline-slice.ts — discipline state management (paused flag)
  • src/lib/game/utils/discipline-math.tscalculateStatBonus() is correct, just not called for paused disciplines

Suggested Fix

Change computeDisciplineEffects() to iterate over all disciplines with xp > 0 instead of only non-paused ones. The paused flag should only control whether the discipline drains mana and accrues XP (already handled in processTick), not whether its earned bonuses apply.

Impact

This is a critical bug because it fundamentally breaks the progression loop — players lose all progress from disciplines when they pause them, which discourages players from ever stopping a discipline. This makes the concurrent limit feel punishing rather than strategic.

## Bug: Discipline bonuses are lost when discipline is no longer active ### Description When a discipline is paused or deactivated, all stat bonuses from that discipline are lost. The bonuses should persist based on accumulated XP even after the discipline is no longer actively being practiced. ### Root Cause In `src/lib/game/effects/discipline-effects.ts`, the `computeDisciplineEffects()` function only iterates over **active (non-paused)** disciplines: ```ts const activeDiscs = Object.entries(disciplines) .filter(([, disc]) => disc && !disc.paused) .map(...) ``` This means any discipline that has been paused (i.e. `disc.paused === true`) contributes **zero** bonuses, regardless of how much XP was earned. The XP is still stored in the discipline state, but it's simply not used for bonus calculation. ### Expected Behavior - Bonuses from disciplines should be calculated from **all disciplines that have XP > 0**, regardless of whether they are currently active/paused. - The player earned those bonuses through practice; they should not disappear when the player stops practicing. - Only the **mana drain** and **XP accrual** should stop when a discipline is paused — not the stat bonuses. ### Files Involved - `src/lib/game/effects/discipline-effects.ts` — `computeDisciplineEffects()` only looks at non-paused disciplines - `src/lib/game/stores/discipline-slice.ts` — discipline state management (paused flag) - `src/lib/game/utils/discipline-math.ts` — `calculateStatBonus()` is correct, just not called for paused disciplines ### Suggested Fix Change `computeDisciplineEffects()` to iterate over all disciplines with `xp > 0` instead of only non-paused ones. The paused flag should only control whether the discipline drains mana and accrues XP (already handled in `processTick`), not whether its earned bonuses apply. ### Impact This is a critical bug because it fundamentally breaks the progression loop — players lose all progress from disciplines when they pause them, which discourages players from ever stopping a discipline. This makes the concurrent limit feel punishing rather than strategic.
Anexim added the ai:todo label 2026-05-25 11:36:11 +02:00
n8n-gitea was assigned by Anexim 2026-05-25 11:36:11 +02:00
Author
Owner

Starting work on the critical bug: discipline bonuses lost when paused/deactivated.

Root cause identified in computeDisciplineEffects() — it filters to !disc.paused, so paused disciplines contribute zero bonuses despite having earned XP.

Fix: Change the filter to include all disciplines with xp > 0, not just non-paused ones. The paused flag should only control mana drain and XP accrual (already handled in processTick), not earned stat bonuses.

Starting work on the critical bug: discipline bonuses lost when paused/deactivated. Root cause identified in `computeDisciplineEffects()` — it filters to `!disc.paused`, so paused disciplines contribute zero bonuses despite having earned XP. Fix: Change the filter to include all disciplines with `xp > 0`, not just non-paused ones. The paused flag should only control mana drain and XP accrual (already handled in `processTick`), not earned stat bonuses.
Author
Owner

Fixed. Changed computeDisciplineEffects() in src/lib/game/effects/discipline-effects.ts to iterate over all disciplines with xp > 0 instead of only non-paused ones.

Change: Line 19 filter changed from .filter(([, disc]) => disc && !disc.paused) to .filter(([, disc]) => disc && disc.xp > 0)

What this fixes:

  • Paused/deactivated disciplines now contribute stat bonuses based on earned XP
  • Mana drain and XP accrual still correctly stop when paused (handled in processTick)
  • Perks from paused disciplines with sufficient XP still unlock

Tests: All 42 discipline-math tests and 11 store-actions-discipline tests pass. The 20 pre-existing failures in room-utils/floor-utils/combat-utils are unrelated.

✅ Fixed. Changed `computeDisciplineEffects()` in `src/lib/game/effects/discipline-effects.ts` to iterate over all disciplines with `xp > 0` instead of only non-paused ones. **Change:** Line 19 filter changed from `.filter(([, disc]) => disc && !disc.paused)` to `.filter(([, disc]) => disc && disc.xp > 0)` **What this fixes:** - Paused/deactivated disciplines now contribute stat bonuses based on earned XP - Mana drain and XP accrual still correctly stop when paused (handled in `processTick`) - Perks from paused disciplines with sufficient XP still unlock **Tests:** All 42 discipline-math tests and 11 store-actions-discipline tests pass. The 20 pre-existing failures in room-utils/floor-utils/combat-utils are unrelated.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#129