Browse Source

resource stacking update

lakebane-master
FatBoy-DOTC 10 months ago
parent
commit
84a75f6b83
  1. 2
      src/engine/devcmd/cmds/SimulateBootyCmd.java
  2. 37
      src/engine/objects/CharacterItemManager.java

2
src/engine/devcmd/cmds/SimulateBootyCmd.java

@ -51,7 +51,7 @@ public class SimulateBootyCmd extends AbstractDevCmd { @@ -51,7 +51,7 @@ public class SimulateBootyCmd extends AbstractDevCmd {
int failures = 0;
int goldAmount = 0;
for (int i = 0; i < 1000; ++i) {
for (int i = 0; i < 10000; ++i) {
try {
mob.loadInventory();

37
src/engine/objects/CharacterItemManager.java

@ -1244,34 +1244,23 @@ public class CharacterItemManager { @@ -1244,34 +1244,23 @@ public class CharacterItemManager {
return false;
}
this.inventory.add(i);
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
ItemBase ib = i.getItemBase();
if (ib != null)
this.inventoryWeight += ib.getWeight();
if (i.getItemBase().getType().equals(ItemType.RESOURCE) && this.getOwner().getObjectType().equals(GameObjectType.PlayerCharacter)) {
int count = i.getNumOfItems();
ArrayList<Item> purge = new ArrayList<>();
for (Item it : this.getInventory()) {
if (it.getItemBase().equals(i.getItemBase()) && it.getNumOfItems() + i.getNumOfItems() <= Warehouse.getMaxResources().get(it.getItemBaseID())) {
purge.add(it);
count += it.getNumOfItems();
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();
}
}
}
if (count <= Warehouse.getMaxResources().get(i.getItemBaseID())) {
MobLoot ml = new MobLoot(this.getOwner(), i.getItemBase(), count, false);
for (Item p : purge) {
this.removeItemFromInventory(p);
}
this.addItemToInventory(ml.promoteToItem((PlayerCharacter) this.getOwner()), 1);
this.updateInventory(ml.promoteToItem((PlayerCharacter) this.getOwner()),true);
return true;
}
}
}else {
this.inventory.add(i);
this.itemIDtoType.put(i.getObjectUUID(), i.getObjectType().ordinal());
ItemBase ib = i.getItemBase();
if (ib != null)
this.inventoryWeight += ib.getWeight();
}
return true;
}

Loading…
Cancel
Save