Browse Source

merchant resource stacking

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

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

@ -1464,11 +1464,37 @@ public class ClientMessagePump implements NetMsgHandler {
ChatManager.chatSystemError(sourcePlayer, "Failed To Buy Item"); ChatManager.chatSystemError(sourcePlayer, "Failed To Buy Item");
return; return;
} }
buy = Item.createItemForPlayer(sourcePlayer, ib); if(me.getItemBase().getType().equals(ItemType.RESOURCE)){
if (buy != null) { boolean stacked = false;
me.transferEnchants(buy); for(Item item : itemMan.getInventory()){
itemMan.addItemToInventory(buy); int itemID = item.getItemBaseID();
//itemMan.updateInventory(); 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);
itemMan.addItemToInventory(buy);
//itemMan.updateInventory();
}
} }
} }
} }

Loading…
Cancel
Save