8a7ddaae27
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m19s
- CombatState: split into CombatState (data) + CombatActions + CombatStore - PrestigeState: split into PrestigeState (data) + PrestigeActions + PrestigeStore - ManaState: split into ManaState (data) + ManaActions + ManaStore - GameState: deprecated, removed from barrel exports - crafting-actions: updated to use CraftingState instead of GameState - combat-utils/mana-utils: replaced Pick<GameState,...> with focused interfaces - DisciplineCardProps: split into Definition + Runtime + Callbacks - stores/index.ts: now exports both State and Actions types
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
// ─── Disenchanting Actions ─────────────────────────────────────────────────
|
|
|
|
import type { CraftingState } from '../stores/craftingStore.types';
|
|
|
|
export function disenchantEquipment(
|
|
instanceId: string,
|
|
get: () => CraftingState,
|
|
set: (fn: (state: CraftingState) => Partial<CraftingState>) => 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.`],
|
|
}));
|
|
}
|