[priority: high] Disciplines not reset when restarting the loop #187

Closed
opened 2026-05-28 15:57:23 +02:00 by Anexim · 1 comment
Owner

Bug: Disciplines persist through loop restart instead of being reset

Description

When the loop ends and the player starts a new loop (via Insight/prestige), disciplines from the previous loop are NOT reset. They retain their XP, active state, and processed perks.

Root Cause Analysis

In gameLoopActions.tscreateStartNewLoop():

export const createStartNewLoop = (set: ...) => () => {
  // ... computes insight, resets UI, prestige, mana, combat ...
  
  usePrestigeStore.getState().resetPrestigeForNewLoop(total, pu);
  useManaStore.getState().resetMana(pu);
  useCombatStore.setState({ ... });
  
  // NOTE: No call to reset discipline store!
  set({ day: 1, hour: 0, ... });
};

The discipline store (useDisciplineStore) is NEVER reset. It persists via localStorage (it uses persist middleware with name: 'mana-loop-discipline-store'), so disciplines from the previous loop carry over.

Affected Files

  • src/lib/game/stores/gameLoopActions.tscreateStartNewLoop function
  • src/lib/game/stores/discipline-slice.ts — discipline store (needs a resetDisciplines action)

Steps to Reproduce

  1. Start practicing a discipline and accumulate XP
  2. Let the loop end (day 30) or trigger prestige
  3. Start a new loop
  4. Observe that discipline XP and active state persist

Expected Behavior

  • All disciplines should be reset to initial state (XP=0, paused=true) when a new loop starts
  • Active discipline slots should be cleared
  • Concurrent limit should reset to base value
  • Processed perks should be cleared

Suggested Fix Direction

  1. Add a resetDisciplines() action to discipline-slice.ts
  2. Call it in createStartNewLoop before resetting other stores
  3. The reset should clear all discipline XP, active IDs, processed perks, and concurrent limit
## Bug: Disciplines persist through loop restart instead of being reset ### Description When the loop ends and the player starts a new loop (via Insight/prestige), disciplines from the previous loop are NOT reset. They retain their XP, active state, and processed perks. ### Root Cause Analysis In `gameLoopActions.ts` → `createStartNewLoop()`: ```ts export const createStartNewLoop = (set: ...) => () => { // ... computes insight, resets UI, prestige, mana, combat ... usePrestigeStore.getState().resetPrestigeForNewLoop(total, pu); useManaStore.getState().resetMana(pu); useCombatStore.setState({ ... }); // NOTE: No call to reset discipline store! set({ day: 1, hour: 0, ... }); }; ``` The discipline store (`useDisciplineStore`) is NEVER reset. It persists via localStorage (it uses `persist` middleware with `name: 'mana-loop-discipline-store'`), so disciplines from the previous loop carry over. ### Affected Files - `src/lib/game/stores/gameLoopActions.ts` — `createStartNewLoop` function - `src/lib/game/stores/discipline-slice.ts` — discipline store (needs a `resetDisciplines` action) ### Steps to Reproduce 1. Start practicing a discipline and accumulate XP 2. Let the loop end (day 30) or trigger prestige 3. Start a new loop 4. Observe that discipline XP and active state persist ### Expected Behavior - All disciplines should be reset to initial state (XP=0, paused=true) when a new loop starts - Active discipline slots should be cleared - Concurrent limit should reset to base value - Processed perks should be cleared ### Suggested Fix Direction 1. Add a `resetDisciplines()` action to `discipline-slice.ts` 2. Call it in `createStartNewLoop` before resetting other stores 3. The reset should clear all discipline XP, active IDs, processed perks, and concurrent limit
Anexim added the ai:todo label 2026-05-28 15:57:23 +02:00
n8n-gitea was assigned by Anexim 2026-05-28 15:57:23 +02:00
Author
Owner

Fix applied for issue #187: Disciplines not reset when restarting the loop

Changes:

  1. src/lib/game/stores/discipline-slice.ts — Added resetDisciplines() action to DisciplineStoreActions interface and implementation. Resets all disciplines to empty, clears active resets, concurrent limit, total XP, and processed perks.

  2. src/lib/game/stores/gameLoopActions.ts — Imported useDisciplineStore and added useDisciplineStore.getState().resetDisciplines() call in createStartNewLoop(), placed after useManaStore.getState().resetMana(pu) and before combat reset.

Verification:

  • Start practicing a discipline → accumulate XP → end loop → new loop starts with discipline XP = 0, no active disciplines, concurrent limit reset to base value.
## Fix applied for issue #187: Disciplines not reset when restarting the loop ### Changes: 1. **`src/lib/game/stores/discipline-slice.ts`** — Added `resetDisciplines()` action to `DisciplineStoreActions` interface and implementation. Resets all disciplines to empty, clears active resets, concurrent limit, total XP, and processed perks. 2. **`src/lib/game/stores/gameLoopActions.ts`** — Imported `useDisciplineStore` and added `useDisciplineStore.getState().resetDisciplines()` call in `createStartNewLoop()`, placed after `useManaStore.getState().resetMana(pu)` and before combat reset. ### Verification: - Start practicing a discipline → accumulate XP → end loop → new loop starts with discipline XP = 0, no active disciplines, concurrent limit reset to base value.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Anexim/Mana-Loop#187