forked from MagicBane/Server
More itembase refactor work
This commit is contained in:
@@ -1243,17 +1243,16 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
Item buy = null;
|
||||
|
||||
if (msg.getItemType() == GameObjectType.MobEquipment.ordinal()) {
|
||||
|
||||
ArrayList<MobEquipment> sellInventory = npc.getContract().getSellInventory();
|
||||
|
||||
if (sellInventory == null)
|
||||
return;
|
||||
|
||||
for (MobEquipment me : sellInventory) {
|
||||
|
||||
if (me.getObjectUUID() == msg.getItemID()) {
|
||||
|
||||
ItemBase ib = me.getItemBase();
|
||||
|
||||
if (ib == null)
|
||||
return;
|
||||
|
||||
//test room available for item
|
||||
if (!itemMan.hasRoomInventory(me.template.item_wt))
|
||||
return;
|
||||
@@ -1275,22 +1274,22 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
Building building = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
|
||||
if (b != null && b.getProtectionState().equals(ProtectionState.NPC))
|
||||
b = null;
|
||||
if (building != null && building.getProtectionState().equals(ProtectionState.NPC))
|
||||
building = null;
|
||||
int buildingDeposit = cost - me.getMagicValue();
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold()) {
|
||||
if (building != null && (building.getStrongboxValue() + buildingDeposit) > building.getMaxGold()) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 206);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemMan.buyFromNPC(b, cost, buildingDeposit)) {
|
||||
if (!itemMan.buyFromNPC(building, cost, buildingDeposit)) {
|
||||
// chatMan.chatSystemInfo(pc, "" + "You Failed to buy the item.");
|
||||
return;
|
||||
}
|
||||
|
||||
buy = Item.createItemForPlayer(sourcePlayer, ib);
|
||||
buy = Item.createItemForPlayer(sourcePlayer, me.templateID);
|
||||
|
||||
if (buy != null) {
|
||||
me.transferEnchants(buy);
|
||||
@@ -1344,20 +1343,20 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
Building building = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
|
||||
if (b != null)
|
||||
if (b.getProtectionState().equals(ProtectionState.NPC))
|
||||
b = null;
|
||||
if (building != null)
|
||||
if (building.getProtectionState().equals(ProtectionState.NPC))
|
||||
building = null;
|
||||
|
||||
int buildingDeposit = cost;
|
||||
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold()) {
|
||||
if (building != null && (building.getStrongboxValue() + buildingDeposit) > building.getMaxGold()) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 206);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemMan.buyFromNPC(b, cost, buildingDeposit)) {
|
||||
if (!itemMan.buyFromNPC(building, cost, buildingDeposit)) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 110);
|
||||
return;
|
||||
}
|
||||
@@ -1391,24 +1390,23 @@ public class ClientMessagePump implements NetMsgHandler {
|
||||
int cost = buy.getMagicValue();
|
||||
cost *= npc.getSellPercent(sourcePlayer);
|
||||
|
||||
|
||||
if (gold.getNumOfItems() - cost < 0) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 128); // Insufficient Gold
|
||||
return;
|
||||
}
|
||||
|
||||
Building b = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
Building building = (!npc.isStatic()) ? npc.getBuilding() : null;
|
||||
|
||||
if (b != null && b.getProtectionState().equals(ProtectionState.NPC))
|
||||
b = null;
|
||||
if (building != null && building.getProtectionState().equals(ProtectionState.NPC))
|
||||
building = null;
|
||||
int buildingDeposit = cost;
|
||||
|
||||
if (b != null && (b.getStrongboxValue() + buildingDeposit) > b.getMaxGold()) {
|
||||
if (building != null && (building.getStrongboxValue() + buildingDeposit) > building.getMaxGold()) {
|
||||
ErrorPopupMsg.sendErrorPopup(sourcePlayer, 206);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemMan.buyFromNPC(b, cost, buildingDeposit))
|
||||
if (!itemMan.buyFromNPC(building, cost, buildingDeposit))
|
||||
return;
|
||||
|
||||
if (buy != null)
|
||||
|
||||
@@ -523,9 +523,9 @@ public class Item extends AbstractWorldObject {
|
||||
writer.putIntAt(serialized, indexPosition);
|
||||
}
|
||||
|
||||
public static Item createItemForPlayer(PlayerCharacter pc, ItemBase ib) {
|
||||
public static Item createItemForPlayer(PlayerCharacter pc, int templateID) {
|
||||
|
||||
Item item = new Item(ib.getUUID());
|
||||
Item item = new Item(templateID);
|
||||
item.ownerID = pc.getObjectUUID();
|
||||
item.ownerType = OwnerType.PlayerCharacter;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user