fix: auto-resume disciplines + stop bonuses while paused (bug #380)
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m24s

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.
This commit is contained in:
2026-06-12 19:00:24 +02:00
parent 4863dbc324
commit 0add3d6260
4 changed files with 26 additions and 4 deletions
+1 -1
View File
@@ -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<typeof ALL_DISCIPLINES[0]> } => !!entry.def);
+23 -1
View File
@@ -207,7 +207,29 @@ export const useDisciplineStore = create<DisciplineStore>()(
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;