// ─── Disenchanting Actions ───────────────────────────────────────────────── import type { CraftingState } from '../stores/craftingStore.types'; export function disenchantEquipment( instanceId: string, get: () => CraftingState, set: (fn: (state: CraftingState) => Partial) => void ) { const state = get(); const instance = state.equipmentInstances[instanceId]; if (!instance || instance.enchantments.length === 0) return; const disenchantLevel = 0; const recoveryRate = 0.1 + disenchantLevel * 0.2; let totalRecovered = 0; for (const ench of instance.enchantments) { totalRecovered += Math.floor(ench.actualCost * recoveryRate); } set((s) => ({ equipmentInstances: { ...s.equipmentInstances, [instanceId]: { ...instance, enchantments: [], usedCapacity: 0, }, }, log: [`✨ Disenchanted ${instance.name}, recovered ${totalRecovered} mana.`], })); }