Browse Source

merchant resource stacking

lakebane-master
FatBoy-DOTC 6 months ago
parent
commit
2ca51d6a83
  1. 26
      src/engine/net/client/ClientMessagePump.java

26
src/engine/net/client/ClientMessagePump.java

@ -1464,6 +1464,31 @@ public class ClientMessagePump implements NetMsgHandler { @@ -1464,6 +1464,31 @@ public class ClientMessagePump implements NetMsgHandler {
ChatManager.chatSystemError(sourcePlayer, "Failed To Buy Item");
return;
}
if(me.getItemBase().getType().equals(ItemType.RESOURCE)){
boolean stacked = false;
for(Item item : itemMan.getInventory()){
int itemID = item.getItemBaseID();
int meID = me.getItemBase().getUUID();
if(itemID == meID){
int maxStack = Warehouse.maxResources.get(meID);
if(maxStack > item.getNumOfItems() + 1){
item.setNumOfItems(item.getNumOfItems() + 1);
stacked = true;
itemMan.updateInventory();
item.updateDatabase();
break;
}
}
}
if(!stacked){
buy = Item.createItemForPlayer(sourcePlayer, ib);
if (buy != null) {
me.transferEnchants(buy);
itemMan.addItemToInventory(buy);
//itemMan.updateInventory();
}
}
}else {
buy = Item.createItemForPlayer(sourcePlayer, ib);
if (buy != null) {
me.transferEnchants(buy);
@ -1472,6 +1497,7 @@ public class ClientMessagePump implements NetMsgHandler { @@ -1472,6 +1497,7 @@ public class ClientMessagePump implements NetMsgHandler {
}
}
}
}
} else if (msg.getItemType() == GameObjectType.Item.ordinal()) {
CharacterItemManager npcCim = npc.getCharItemManager();

Loading…
Cancel
Save