feat: add material crafting recipes to Fabricator
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 4m25s

This commit is contained in:
2026-05-27 14:13:46 +02:00
parent cbeb0b50ad
commit 3f20991d2d
12 changed files with 579 additions and 64 deletions
+15 -19
View File
@@ -22,6 +22,7 @@ import {
deductMaterials,
makeFabricatorProgress,
} from '../crafting-fabricator';
import { craftMaterial as craftMaterialAction } from '../crafting-actions/crafting-material-actions';
export const useCraftingStore = create<CraftingStore>()(
persist(
@@ -198,45 +199,29 @@ export const useCraftingStore = create<CraftingStore>()(
useCombatStore.setState({ currentAction: 'meditate' });
},
// Equipment crafting actions
startCraftingEquipment: (blueprintId: string) => {
const state = get();
const rawMana = useManaStore.getState().rawMana;
const currentAction = useCombatStore.getState().currentAction;
// Check if we can start crafting
const check = CraftingEquipment.canStartEquipmentCrafting(
blueprintId,
state.lootInventory.blueprints.includes(blueprintId),
state.lootInventory.materials,
rawMana,
currentAction
currentAction,
);
if (!check.canCraft) return false;
// Initialize crafting
const result = CraftingEquipment.initializeEquipmentCrafting(
blueprintId,
state.lootInventory.materials,
rawMana
rawMana,
);
// Update crafting store state
set((s) => ({
lootInventory: {
...s.lootInventory,
materials: result.newMaterials,
},
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;
},
@@ -274,6 +259,17 @@ export const useCraftingStore = create<CraftingStore>()(
return true;
},
// Material crafting — instant crafting of materials
craftMaterial: (recipeId: string) => {
const state = get();
const result = craftMaterialAction(recipeId, state.lootInventory.materials);
if (!result.success) return false;
if (result.newMaterials) {
set((s) => ({ lootInventory: { ...s.lootInventory, materials: result.newMaterials! } }));
}
return true;
},
// Enchantment selection actions
setSelectedEquipmentType: (type) => {
set((s) => ({ enchantmentSelection: { ...s.enchantmentSelection, selectedEquipmentType: type }}));
@@ -62,6 +62,7 @@ export interface CraftingActions {
unequipItem: (slot: EquipmentSlot) => void;
startCraftingEquipment: (blueprintId: string) => boolean;
startFabricatorCrafting: (recipeId: string) => boolean;
craftMaterial: (recipeId: string) => boolean;
cancelEquipmentCrafting: () => void;
setSelectedEquipmentType: (type: string | null) => void;
setSelectedEffects: (effects: DesignEffect[]) => void;