Browse Source

resource stacking update

lakebane-master
FatBoy-DOTC 9 months ago
parent
commit
44cd8d0013
  1. 10
      src/engine/objects/CharacterItemManager.java

10
src/engine/objects/CharacterItemManager.java

@ -1245,14 +1245,24 @@ public class CharacterItemManager {
return false; return false;
} }
if (i.getItemBase().getType().equals(ItemType.RESOURCE) && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) { if (i.getItemBase().getType().equals(ItemType.RESOURCE) && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) {
boolean added = false;
for(Item item : this.getInventory()){ for(Item item : this.getInventory()){
if(item.getItemBaseID() == i.getItemBaseID()){ if(item.getItemBaseID() == i.getItemBaseID()){
if(item.getNumOfItems() + i.getNumOfItems() <= Warehouse.getMaxResources().get(item.getItemBaseID())) { if(item.getNumOfItems() + i.getNumOfItems() <= Warehouse.getMaxResources().get(item.getItemBaseID())) {
item.setNumOfItems(item.getNumOfItems() + i.getNumOfItems()); item.setNumOfItems(item.getNumOfItems() + i.getNumOfItems());
updateInventory(); 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 { }else {
this.inventory.add(i); this.inventory.add(i);
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal()); this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());

Loading…
Cancel
Save