fix: Bug fixes #218 #222 #220 #223 #215 #216 - attunement free mana, transference circular ref, guardian defeat tracking, discipline negative mana, guardian data, crafting refunds
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m23s

This commit is contained in:
2026-05-30 22:28:45 +02:00
parent 737a23bec3
commit e4f4b297e8
10 changed files with 289 additions and 165 deletions
+4 -63
View File
@@ -11,19 +11,13 @@ import { useCombatStore } from './combatStore';
import { useUIStore } from './uiStore';
import * as ApplicationActions from '../crafting-actions/application-actions';
import * as PreparationActions from '../crafting-actions/preparation-actions';
import * as CraftingEquipment from '../crafting-equipment';
import { equipItem as equipItemAction, unequipItem as unequipItemAction } from '../crafting-actions/equipment-actions';
import { ErrorCode } from '../utils/result';
import { createSafeStorage } from '../utils/safe-persist';
import { createDefaultCraftingState } from './crafting-initial-state';
import {
getFabricatorRecipe,
deductFabricatorMana,
deductMaterials,
makeFabricatorProgress,
} from '../crafting-fabricator';
import { craftMaterial as craftMaterialAction } from '../crafting-actions/crafting-material-actions';
import { processEquipmentCraftingTick } from './crafting-equipment-tick';
import { startCraftingEquipment, cancelEquipmentCrafting, startFabricatorCrafting } from './pipelines/equipment-crafting';
export const useCraftingStore = create<CraftingStore>()(
persist(
@@ -179,65 +173,12 @@ export const useCraftingStore = create<CraftingStore>()(
useCombatStore.setState({ currentAction: 'meditate' });
},
startCraftingEquipment: (blueprintId: string) => {
const state = get();
const rawMana = useManaStore.getState().rawMana;
const currentAction = useCombatStore.getState().currentAction;
const check = CraftingEquipment.canStartEquipmentCrafting(
blueprintId,
state.lootInventory.blueprints.includes(blueprintId),
state.lootInventory.materials,
rawMana,
currentAction,
);
if (!check.canCraft) return false;
const result = CraftingEquipment.initializeEquipmentCrafting(
blueprintId,
state.lootInventory.materials,
rawMana,
);
set((s) => ({
lootInventory: { ...s.lootInventory, materials: result.newMaterials },
equipmentCraftingProgress: result.progress,
}));
useManaStore.setState((s) => ({ rawMana: s.rawMana - result.manaCost }));
useCombatStore.setState({ currentAction: 'craft' });
return true;
},
startCraftingEquipment: (blueprintId: string) => startCraftingEquipment(blueprintId, get, set),
cancelEquipmentCrafting: () => {
const progress = get().equipmentCraftingProgress;
if (!progress) return;
const cancelResult = CraftingEquipment.cancelEquipmentCrafting(progress.blueprintId, progress.manaSpent);
set({ equipmentCraftingProgress: null });
useManaStore.setState((s) => ({ rawMana: s.rawMana + cancelResult.manaRefund }));
useCombatStore.setState({ currentAction: 'meditate' });
useUIStore.getState().addLog(cancelResult.logMessage);
},
cancelEquipmentCrafting: () => cancelEquipmentCrafting(get, set),
// Fabricator crafting — uses elemental mana instead of raw mana
startFabricatorCrafting: (recipeId: string) => {
const state = get();
const currentAction = useCombatStore.getState().currentAction;
if (currentAction !== 'meditate') return false;
const recipe = getFabricatorRecipe(recipeId);
if (!recipe) return false;
const rawMana = useManaStore.getState().rawMana;
const elements = useManaStore.getState().elements;
const deducted = deductFabricatorMana(recipe, rawMana, elements);
if (!deducted) return false;
const newMaterials = deductMaterials(recipe, state.lootInventory.materials);
const progress = makeFabricatorProgress(recipeId, recipe.equipmentTypeId, recipe.craftTime, recipe.manaCost);
useManaStore.setState({ rawMana: deducted.rawMana, elements: deducted.elements });
set((s) => ({ lootInventory: { ...s.lootInventory, materials: newMaterials }, equipmentCraftingProgress: progress }));
useCombatStore.setState({ currentAction: 'craft' });
return true;
},
startFabricatorCrafting: (recipeId: string) => startFabricatorCrafting(recipeId, get, set),
// Material crafting — instant crafting of materials
craftMaterial: (recipeId: string) => {