fix: lootInventory, prestige, golemancy, attunementStore export, debug components
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m21s
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 1m21s
This commit is contained in:
@@ -37,6 +37,11 @@ export interface CraftingState {
|
||||
equipmentInstances: Record<string, EquipmentInstance>;
|
||||
// Equipped instances (slot -> instanceId or null)
|
||||
equippedInstances: Record<string, string | null>;
|
||||
// Loot inventory
|
||||
lootInventory: {
|
||||
materials: Record<string, number>;
|
||||
blueprints: string[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface CraftingActions {
|
||||
@@ -68,6 +73,10 @@ export interface CraftingActions {
|
||||
// Enchantment preparation actions
|
||||
startPreparing: (equipmentInstanceId: string) => boolean;
|
||||
cancelPreparation: () => void;
|
||||
|
||||
// Loot inventory actions
|
||||
deleteMaterial: (materialId: string, amount: number) => void;
|
||||
deleteEquipmentInstance: (instanceId: string) => void;
|
||||
}
|
||||
|
||||
export type CraftingStore = CraftingState & CraftingActions;
|
||||
@@ -85,6 +94,10 @@ export const useCraftingStore = create<CraftingStore>()(
|
||||
unlockedEffects: [],
|
||||
equipmentInstances: {},
|
||||
equippedInstances: {},
|
||||
lootInventory: {
|
||||
materials: {},
|
||||
blueprints: [],
|
||||
},
|
||||
|
||||
// Actions
|
||||
setDesignProgress: (progress) => set({ designProgress: progress }),
|
||||
@@ -221,6 +234,47 @@ export const useCraftingStore = create<CraftingStore>()(
|
||||
PreparationActions.cancelPreparation(set);
|
||||
useGameStore.setState({ currentAction: 'meditate' });
|
||||
},
|
||||
|
||||
// Loot inventory actions
|
||||
deleteMaterial: (materialId: string, amount: number) => {
|
||||
set((state) => {
|
||||
const newMaterials = { ...state.lootInventory.materials };
|
||||
const currentAmount = newMaterials[materialId] || 0;
|
||||
const newAmount = Math.max(0, currentAmount - amount);
|
||||
|
||||
if (newAmount <= 0) {
|
||||
delete newMaterials[materialId];
|
||||
} else {
|
||||
newMaterials[materialId] = newAmount;
|
||||
}
|
||||
|
||||
return {
|
||||
lootInventory: {
|
||||
...state.lootInventory,
|
||||
materials: newMaterials,
|
||||
},
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
deleteEquipmentInstance: (instanceId: string) => {
|
||||
set((state) => {
|
||||
let newEquipped = { ...state.equippedInstances };
|
||||
for (const [slot, id] of Object.entries(newEquipped)) {
|
||||
if (id === instanceId) {
|
||||
newEquipped[slot as any] = null;
|
||||
}
|
||||
}
|
||||
|
||||
const newInstances = { ...state.equipmentInstances };
|
||||
delete newInstances[instanceId];
|
||||
|
||||
return {
|
||||
equippedInstances: newEquipped,
|
||||
equipmentInstances: newInstances,
|
||||
};
|
||||
});
|
||||
},
|
||||
}),
|
||||
{
|
||||
name: 'mana-loop-crafting',
|
||||
@@ -234,6 +288,7 @@ export const useCraftingStore = create<CraftingStore>()(
|
||||
unlockedEffects: state.unlockedEffects,
|
||||
equipmentInstances: state.equipmentInstances,
|
||||
equippedInstances: state.equippedInstances,
|
||||
lootInventory: state.lootInventory,
|
||||
}),
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user