From 0add3d6260df7e29c9ce6f97f804eac6c46487a3 Mon Sep 17 00:00:00 2001 From: n8n-gitea Date: Fri, 12 Jun 2026 19:00:24 +0200 Subject: [PATCH] fix: auto-resume disciplines + stop bonuses while paused (bug #380) Bug 1 - No auto-resume: Replaced 'if (disc.autoPaused) continue' with a check that tests whether sufficient mana is now available. If so, clears autoPaused and processes the tick normally. Mana regen runs before discipline processing, so updated mana values are already available. Bug 2 - Bonuses while paused: Added '&& !disc.autoPaused' filter in discipline-effects.ts so paused disciplines no longer contribute stat bonuses, conversion rates, or perk effects. All 1196 tests pass. --- docs/circular-deps.txt | 2 +- docs/dependency-graph.json | 2 +- src/lib/game/effects/discipline-effects.ts | 2 +- src/lib/game/stores/discipline-slice.ts | 24 +++++++++++++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/docs/circular-deps.txt b/docs/circular-deps.txt index d9b7e3b..c879161 100644 --- a/docs/circular-deps.txt +++ b/docs/circular-deps.txt @@ -1,5 +1,5 @@ # Circular Dependencies -Generated: 2026-06-12T12:18:22.789Z +Generated: 2026-06-12T16:57:09.913Z Found: 4 circular chain(s) — these MUST be fixed before modifying involved files. 1. 1) data/guardian-encounters.ts > data/guardian-procedural.ts diff --git a/docs/dependency-graph.json b/docs/dependency-graph.json index c03d7e6..58155b3 100644 --- a/docs/dependency-graph.json +++ b/docs/dependency-graph.json @@ -1,6 +1,6 @@ { "_meta": { - "generated": "2026-06-12T12:18:20.580Z", + "generated": "2026-06-12T16:57:07.675Z", "description": "Import dependency graph for src/lib/game. Keys are files, values are arrays of files they import.", "usage": "To find what a file affects, search for its path in the VALUES. To find what a file depends on, look at its KEY entry." }, diff --git a/src/lib/game/effects/discipline-effects.ts b/src/lib/game/effects/discipline-effects.ts index 24d43d9..b275aea 100644 --- a/src/lib/game/effects/discipline-effects.ts +++ b/src/lib/game/effects/discipline-effects.ts @@ -77,7 +77,7 @@ export interface DisciplineEffectsResult { export function computeDisciplineEffects(_state?: DisciplineStoreState): DisciplineEffectsResult { const { disciplines } = useDisciplineStore.getState(); const activeDiscs = Object.entries(disciplines) - .filter(([, disc]) => disc && disc.xp > 0) + .filter(([, disc]) => disc && disc.xp > 0 && !disc.autoPaused) .map(([id, disc]) => ({ id, disc, def: ALL_DISCIPLINES.find(d => d.id === id) })) .filter((entry): entry is { id: string; disc: DisciplineState; def: NonNullable } => !!entry.def); diff --git a/src/lib/game/stores/discipline-slice.ts b/src/lib/game/stores/discipline-slice.ts index 84d388e..197f1ea 100644 --- a/src/lib/game/stores/discipline-slice.ts +++ b/src/lib/game/stores/discipline-slice.ts @@ -207,7 +207,29 @@ export const useDisciplineStore = create()( const disc = newDisciplines[id]; if (!disc) continue; if (disc.paused) continue; - if (disc.autoPaused) continue; // already auto-paused, don't re-process + + // Auto-resume: if this discipline was auto-paused due to insufficient mana, + // check whether enough mana is now available. If so, clear autoPaused and + // process normally this tick. Mana regen runs before discipline processing + // in the tick pipeline, so the mana values passed here are already updated. + if (disc.autoPaused) { + const def = DISCIPLINE_MAP[id]; + if (def) { + const drain = calculateManaDrain(def.drainBase, disc.xp, def.difficultyFactor); + const hasEnoughMana = + def.manaType === 'raw' + ? rawMana >= drain + : elements[def.manaType] && elements[def.manaType].current >= drain; + if (hasEnoughMana) { + // Mana restored — clear autoPaused and fall through to normal processing + newDisciplines[id] = { ...disc, autoPaused: false }; + } else { + continue; // still not enough mana, skip + } + } else { + continue; // no definition, skip + } + } const def = DISCIPLINE_MAP[id]; if (!def) continue;