refactor: tick pipeline pattern — read all → compute all → write all (issue #103)
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m19s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m19s
- New tick-pipeline.ts: TickContext/TickWrites types + buildTickContext/applyTickWrites orchestrator
- gameStore.ts tick(): refactored to 3-phase pipeline (read snapshot → compute updates → batch writes)
- combat-actions.ts: accept signedPacts as parameter instead of usePrestigeStore.getState() in combat loop
- combatStore.ts/combat-state.types.ts: updated processCombatTick signature for signedPacts passthrough
- craftingStore.ts: removed tempState = { ...get(), rawMana } as any anti-pattern
- preparation-actions.ts: accept rawMana as explicit parameter instead of GameState bag
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
// ─── Enchantment Preparation Actions ────────────────────────────────────────
|
||||
|
||||
import type { GameState } from '../types';
|
||||
import type { CraftingState } from '../stores/craftingStore.types';
|
||||
import * as CraftingPrep from '../crafting-prep';
|
||||
|
||||
export function startPreparing(
|
||||
equipmentInstanceId: string,
|
||||
get: () => GameState,
|
||||
set: (fn: (state: GameState) => Partial<GameState>) => void
|
||||
rawMana: number,
|
||||
get: () => CraftingState,
|
||||
set: (partial: Partial<CraftingState>) => void
|
||||
): boolean {
|
||||
const state = get();
|
||||
const instance = state.equipmentInstances[equipmentInstanceId];
|
||||
@@ -21,24 +22,22 @@ export function startPreparing(
|
||||
|
||||
const costs = CraftingPrep.calculatePreparationCosts(instance.totalCapacity);
|
||||
|
||||
if (state.rawMana < costs.manaTotal) return false;
|
||||
if (rawMana < costs.manaTotal) return false;
|
||||
|
||||
set(() => ({
|
||||
currentAction: 'prepare' as const,
|
||||
set({
|
||||
preparationProgress: CraftingPrep.initializePreparationProgress(
|
||||
equipmentInstanceId,
|
||||
instance.totalCapacity
|
||||
),
|
||||
}));
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
export function cancelPreparation(
|
||||
set: (fn: (state: GameState) => Partial<GameState>) => void
|
||||
set: (partial: Partial<CraftingState>) => void
|
||||
) {
|
||||
set(() => ({
|
||||
currentAction: 'meditate' as const,
|
||||
set({
|
||||
preparationProgress: null,
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user