From 44cd8d00132acd11f1352bed886090ea925923f1 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Mon, 19 Feb 2024 18:41:47 -0600 Subject: [PATCH] resource stacking update --- src/engine/objects/CharacterItemManager.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/engine/objects/CharacterItemManager.java b/src/engine/objects/CharacterItemManager.java index 2213007f..8e80fabd 100644 --- a/src/engine/objects/CharacterItemManager.java +++ b/src/engine/objects/CharacterItemManager.java @@ -1245,14 +1245,24 @@ public class CharacterItemManager { return false; } if (i.getItemBase().getType().equals(ItemType.RESOURCE) && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) { + boolean added = false; for(Item item : this.getInventory()){ if(item.getItemBaseID() == i.getItemBaseID()){ if(item.getNumOfItems() + i.getNumOfItems() <= Warehouse.getMaxResources().get(item.getItemBaseID())) { item.setNumOfItems(item.getNumOfItems() + i.getNumOfItems()); updateInventory(); + added = true; } } } + if(!added){ + this.inventory.add(i); + this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); + + ItemBase ib = i.getItemBase(); + if (ib != null) + this.inventoryWeight += ib.getWeight(); + } }else { this.inventory.add(i); this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());