Update inventoryService.ts
All checks were successful
Build / build (22) (pull_request) Successful in 39s
Build / build (18) (pull_request) Successful in 59s
Build / build (20) (pull_request) Successful in 1m9s

This commit is contained in:
AMelonInsideLemon 2025-02-22 10:28:37 +01:00
parent 23f8818257
commit c69625e43d

View File

@ -380,7 +380,13 @@ export const addItem = async (
}
};
} else {
inventory.LevelKeys.push({ ItemType: typeName, ItemCount: quantity });
const itemIndex = inventory.LevelKeys.findIndex(i => i.ItemType === typeName);
if (itemIndex !== -1) {
inventory.LevelKeys[itemIndex].ItemCount += quantity;
} else {
inventory.LevelKeys.push({ ItemType: typeName, ItemCount: quantity });
}
return {
InventoryChanges: {
LevelKeys: [