50a9a62060
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m21s
- Issue 70: Fix discipline-slice.ts nested element mutation (use immutable spread) - Issue 71: Add persist middleware to uiStore for paused/gameOver/victory - Issue 72: Wire discipline effects into calcDamage (spell-casting, void-manipulation) - Issue 73: Fix useGameLoop interval recreation (use getState() + empty deps) - Issue 74: Fix use-toast.ts listener leak (change [state] dep to []) - Issue 75: Reduce page.tsx re-renders with useShallow for multi-field subscriptions - Issue 76: Fix createGatherMana hardcoded click mana (use computeClickMana with discipline effects) - Issue 77: Pass discipline effects to computeMaxMana/computeRegen/calcInsight in tick() - Export DisciplineBonuses type and useDisciplineStore from barrel exports - Update tests to match new function signatures
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
import { computeMaxMana, computeClickMana } from '../utils';
|
|
import { useUIStore } from './uiStore';
|
|
import { usePrestigeStore } from './prestigeStore';
|
|
import { useManaStore } from './manaStore';
|
|
import { useCombatStore } from './combatStore';
|
|
import { computeDisciplineEffects } from '../effects/discipline-effects';
|
|
import { useDisciplineStore } from './discipline-slice';
|
|
|
|
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-combat-storage');
|
|
localStorage.removeItem('mana-loop-game-storage');
|
|
localStorage.removeItem('mana-loop-crafting-storage');
|
|
localStorage.removeItem('mana-loop-attunement-storage');
|
|
localStorage.removeItem('mana-loop-discipline-store');
|
|
}
|
|
|
|
const startFloor = 1;
|
|
|
|
useUIStore.getState().reset();
|
|
usePrestigeStore.getState().resetPrestige();
|
|
useManaStore.getState().resetMana({}, {}, {}, {});
|
|
useCombatStore.getState().resetCombat(startFloor);
|
|
|
|
set({
|
|
...initialState,
|
|
initialized: true,
|
|
});
|
|
};
|
|
|
|
export const createGatherMana = () => () => {
|
|
const prestigeState = usePrestigeStore.getState();
|
|
const disciplineEffects = computeDisciplineEffects(useDisciplineStore.getState() as any);
|
|
|
|
// Compute click mana with discipline bonuses (mana-channeling → clickManaMultiplier)
|
|
const cm = computeClickMana(
|
|
{ skills: {} },
|
|
disciplineEffects,
|
|
);
|
|
|
|
const max = computeMaxMana(
|
|
{
|
|
skills: {},
|
|
prestigeUpgrades: prestigeState.prestigeUpgrades,
|
|
skillUpgrades: {},
|
|
skillTiers: {}
|
|
},
|
|
undefined,
|
|
disciplineEffects,
|
|
);
|
|
|
|
useManaStore.getState().gatherMana(cm, max);
|
|
};
|