fix: guard localStorage for SSR, fix currentAction written to wrong store
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 2m5s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 2m5s
This commit is contained in:
@@ -15,6 +15,7 @@ import { hasSpecial, SPECIAL_EFFECTS } from '../special-effects';
|
||||
// Import other stores to access required state
|
||||
import { useSkillStore } from './skillStore';
|
||||
import { useGameStore } from './gameStore';
|
||||
import { useCombatStore } from './combatStore';
|
||||
|
||||
// Import action modules
|
||||
import * as ApplicationActions from '../crafting-actions/application-actions';
|
||||
@@ -140,8 +141,8 @@ export const useCraftingStore = create<CraftingStore>()(
|
||||
effects,
|
||||
},
|
||||
};
|
||||
// Update currentAction in gameStore
|
||||
useGameStore.setState({ currentAction: 'design' });
|
||||
// Update currentAction in combatStore
|
||||
useCombatStore.setState({ currentAction: 'design' });
|
||||
} else if (hasEnchantMastery && !state.designProgress2) {
|
||||
updates = {
|
||||
designProgress2: {
|
||||
@@ -167,7 +168,7 @@ export const useCraftingStore = create<CraftingStore>()(
|
||||
set({ designProgress2: null });
|
||||
} else {
|
||||
set({ designProgress: null });
|
||||
useGameStore.setState({ currentAction: 'meditate' });
|
||||
useCombatStore.setState({ currentAction: 'meditate' });
|
||||
}
|
||||
},
|
||||
|
||||
@@ -189,8 +190,8 @@ export const useCraftingStore = create<CraftingStore>()(
|
||||
set((s) => ({
|
||||
enchantmentDesigns: [...s.enchantmentDesigns, design],
|
||||
designProgress: null,
|
||||
currentAction: 'meditate' as const,
|
||||
}));
|
||||
useCombatStore.setState({ currentAction: 'meditate' });
|
||||
}
|
||||
},
|
||||
|
||||
@@ -214,7 +215,7 @@ export const useCraftingStore = create<CraftingStore>()(
|
||||
|
||||
cancelApplication: () => {
|
||||
ApplicationActions.cancelApplication(set);
|
||||
useGameStore.setState({ currentAction: 'meditate' });
|
||||
useCombatStore.setState({ currentAction: 'meditate' });
|
||||
},
|
||||
|
||||
// Preparation actions
|
||||
@@ -232,7 +233,7 @@ export const useCraftingStore = create<CraftingStore>()(
|
||||
|
||||
cancelPreparation: () => {
|
||||
PreparationActions.cancelPreparation(set);
|
||||
useGameStore.setState({ currentAction: 'meditate' });
|
||||
useCombatStore.setState({ currentAction: 'meditate' });
|
||||
},
|
||||
|
||||
// Loot inventory actions
|
||||
|
||||
@@ -8,12 +8,14 @@ import { useCombatStore } from './combatStore';
|
||||
|
||||
export const createResetGame = (set: (state: any) => void, initialState: any) => () => {
|
||||
// Clear all persisted state
|
||||
if (typeof window !== 'undefined') {
|
||||
localStorage.removeItem('mana-loop-ui-storage');
|
||||
localStorage.removeItem('mana-loop-prestige-storage');
|
||||
localStorage.removeItem('mana-loop-mana-storage');
|
||||
localStorage.removeItem('mana-loop-skill-storage');
|
||||
localStorage.removeItem('mana-loop-combat-storage');
|
||||
localStorage.removeItem('mana-loop-game-storage');
|
||||
}
|
||||
|
||||
const startFloor = 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user