fix: discipline reset on mana depletion and re-activation after stop
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m35s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m35s
- #143: processTick now removes drained disciplines from activeIds and calls onStopPracticing so currentAction resets to 'meditate' - #144: Removed paused guard from canProceedDiscipline so stopped disciplines can be re-activated - Updated test to match new expected behavior for paused disciplines
This commit is contained in:
@@ -154,6 +154,7 @@ export const useDisciplineStore = create<DisciplineStore>()(
|
||||
const newUnlockedEffects: string[] = [];
|
||||
const newProcessedPerks = [...s.processedPerks];
|
||||
|
||||
const drainedIds: string[] = [];
|
||||
for (const id of s.activeIds) {
|
||||
const disc = newDisciplines[id];
|
||||
if (!disc) continue;
|
||||
@@ -168,6 +169,7 @@ export const useDisciplineStore = create<DisciplineStore>()(
|
||||
|
||||
if (!available || available < drain) {
|
||||
newDisciplines[id] = { ...disc, paused: true };
|
||||
drainedIds.push(id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -206,8 +208,15 @@ export const useDisciplineStore = create<DisciplineStore>()(
|
||||
MAX_CONCURRENT_DISCIPLINES + 3
|
||||
);
|
||||
|
||||
// Remove mana-drained disciplines from activeIds so onStopPracticing fires
|
||||
const newActiveIds = s.activeIds.filter((aid) => !drainedIds.includes(aid));
|
||||
if (newActiveIds.length === 0 && s.activeIds.length > 0) {
|
||||
get().practicingCallbacks?.onStopPracticing?.();
|
||||
}
|
||||
|
||||
set({
|
||||
disciplines: newDisciplines,
|
||||
activeIds: newActiveIds,
|
||||
totalXP: newXP,
|
||||
concurrentLimit: Math.max(s.concurrentLimit, newLimit),
|
||||
processedPerks: newProcessedPerks,
|
||||
|
||||
Reference in New Issue
Block a user