Fix: Add missing startCraftingEquipment and cancelEquipmentCrafting actions to craftingStore
Build and Publish Mana Loop Docker Image / build-and-publish (push) Failing after 1m37s

- Added startCraftingEquipment action that validates and initializes equipment crafting
- Added cancelEquipmentCrafting action that cancels crafting and refunds mana
- Used CraftingEquipment functions directly instead of deprecated wrapper actions
- Updated craftingStore imports to include useManaStore and useUIStore
- Fixed crafting/index.tsx barrel file export (removed non-existent type exports)
- Fixed syntax errors in craftingStore.ts (missing commas in function params)

Fixes issue where EquipmentCrafter component couldn't find these actions on craftingStore.
This commit is contained in:
2026-05-06 10:58:58 +02:00
parent a5ff32cb91
commit 17b3571a18
3 changed files with 69 additions and 24 deletions
+4 -4
View File
@@ -1,6 +1,6 @@
// Barrel file for crafting components // Barrel file for crafting components
export { EnchantmentDesigner, type EnchantmentDesignerProps } from './EnchantmentDesigner'; export { EnchantmentDesigner } from './EnchantmentDesigner';
export { EnchantmentPreparer, type EnchantmentPreparerProps } from './EnchantmentPreparer'; export { EnchantmentPreparer } from './EnchantmentPreparer';
export { EnchantmentApplier, type EnchantmentApplierProps } from './EnchantmentApplier'; export { EnchantmentApplier } from './EnchantmentApplier';
export { EquipmentCrafter, type EquipmentCrafterProps } from './EquipmentCrafter'; export { EquipmentCrafter } from './EquipmentCrafter';
@@ -1,8 +1,13 @@
// ─── Equipment Crafting Actions ──────────────────────────────────────────── // ─── Equipment Crafting Actions ────────────────────────────────────────────
// Note: The main implementation is now in craftingStore.ts
// These wrappers are kept for backward compatibility but are no longer used directly
import type { GameState } from '../types'; import type { GameState } from '../types';
import * as CraftingEquipment from '../crafting-equipment'; import * as CraftingEquipment from '../crafting-equipment';
// Wrapper functions kept for backward compatibility
// The actual implementation is in craftingStore.ts using CraftingEquipment functions directly
export function startCraftingEquipment( export function startCraftingEquipment(
blueprintId: string, blueprintId: string,
get: () => GameState, get: () => GameState,
+56 -16
View File
@@ -15,13 +15,15 @@ import { hasSpecial, SPECIAL_EFFECTS } from '../special-effects';
// Import other stores to access required state // Import other stores to access required state
import { useSkillStore } from './skillStore'; import { useSkillStore } from './skillStore';
import { useGameStore } from './gameStore'; import { useGameStore } from './gameStore';
import { useManaStore } from './manaStore';
import { useCombatStore } from './combatStore'; import { useCombatStore } from './combatStore';
import { useUIStore } from './uiStore';
// Import action modules // Import action modules
import * as ApplicationActions from '../crafting-actions/application-actions'; import * as ApplicationActions from '../crafting-actions/application-actions';
import * as CraftingApply from '../crafting-apply'; import * as CraftingApply from '../crafting-apply';
import * as PreparationActions from '../crafting-actions/preparation-actions'; import * as PreparationActions from '../crafting-actions/preparation-actions';
import * as EquipmentCraftingActions from '../crafting-actions/crafting-equipment-actions'; import * as CraftingEquipment from '../crafting-equipment';
export interface CraftingState { export interface CraftingState {
// Crafting progress // Crafting progress
@@ -243,30 +245,68 @@ export const useCraftingStore = create<CraftingStore>()(
// Equipment crafting actions // Equipment crafting actions
startCraftingEquipment: (blueprintId: string) => { startCraftingEquipment: (blueprintId: string) => {
// Get state needed for equipment crafting const state = get();
const rawMana = useManaStore.getState().rawMana; const rawMana = useManaStore.getState().rawMana;
const currentAction = useCombatStore.getState().currentAction; const currentAction = useCombatStore.getState().currentAction;
const lootInventory = get().lootInventory;
// Create a temporary state object with all required fields // Check if we can start crafting
const tempState = { const check = CraftingEquipment.canStartEquipmentCrafting(
...get(),
rawMana,
currentAction,
lootInventory,
} as any;
return EquipmentCraftingActions.startCraftingEquipment(
blueprintId, blueprintId,
() => tempState, state.lootInventory.blueprints.includes(blueprintId),
set state.lootInventory.materials,
rawMana,
currentAction
); );
if (!check.canCraft) return false;
// Initialize crafting
const result = CraftingEquipment.initializeEquipmentCrafting(
blueprintId,
state.lootInventory.materials,
rawMana
);
// Update crafting store state
set((s) => ({
lootInventory: {
...s.lootInventory,
materials: result.newMaterials,
},
equipmentCraftingProgress: result.progress,
}));
// Update mana store (deduct mana)
useManaStore.setState((s) => ({ rawMana: s.rawMana - result.manaCost }));
// Update combat store (set current action)
useCombatStore.setState({ currentAction: 'craft' });
return true;
}, },
cancelEquipmentCrafting: () => { cancelEquipmentCrafting: () => {
EquipmentCraftingActions.cancelEquipmentCrafting( const state = get();
get, const progress = state.equipmentCraftingProgress;
set if (!progress) return;
// Get cancel result (mana refund)
const cancelResult = CraftingEquipment.cancelEquipmentCrafting(
progress.blueprintId,
progress.manaSpent
); );
// Update crafting store state
set({ equipmentCraftingProgress: null });
// Refund mana to mana store
useManaStore.setState((s) => ({ rawMana: s.rawMana + cancelResult.manaRefund }));
// Update combat store (reset action)
useCombatStore.setState({ currentAction: 'meditate' }); useCombatStore.setState({ currentAction: 'meditate' });
// Add log message to UI store
useUIStore.getState().addLog(cancelResult.logMessage);
}, },
// Loot inventory actions // Loot inventory actions