forked from MagicBane/Server
Initial warehouse refactor
This commit is contained in:
@@ -86,7 +86,6 @@ public class ItemFactory {
|
||||
|
||||
boolean useWarehouse = false;
|
||||
|
||||
ItemBase ib = ItemBase.getItemBase(templateID);
|
||||
ItemTemplate template = ItemTemplate.itemTemplates.get(templateID);
|
||||
|
||||
if (template == null)
|
||||
@@ -112,6 +111,7 @@ public class ItemFactory {
|
||||
|
||||
if (city == null)
|
||||
return null;
|
||||
|
||||
MobLoot ml = null;
|
||||
city.transactionLock.writeLock().lock();
|
||||
|
||||
@@ -123,7 +123,7 @@ public class ItemFactory {
|
||||
// ROLL BANE SCROLL.
|
||||
|
||||
if (templateID > 910010 && templateID < 910019) {
|
||||
ConcurrentHashMap<ItemBase, Integer> resources = cityWarehouse.resources;
|
||||
ConcurrentHashMap<Enum.ResourceType, Integer> resources = cityWarehouse.resources;
|
||||
|
||||
|
||||
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, template.item_value);
|
||||
@@ -135,7 +135,7 @@ public class ItemFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, Enum.ResourceType.GOLD)) {
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + " " + template.item_base_name);
|
||||
return null;
|
||||
@@ -162,12 +162,12 @@ public class ItemFactory {
|
||||
}
|
||||
|
||||
if (overdraft > 0)
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GOLD, overdraft, true)) {
|
||||
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
|
||||
ml = new MobLoot(npc, ib, false);
|
||||
ml = new MobLoot(npc, template, false);
|
||||
|
||||
ml.containerType = Enum.ItemContainerType.FORGE;
|
||||
ml.setValue(0);
|
||||
@@ -179,7 +179,7 @@ public class ItemFactory {
|
||||
time = (20 - rate);
|
||||
time *= MBServerStatics.ONE_MINUTE;
|
||||
|
||||
if (ml.getItemBase().getUUID() > 910010 && ml.getItemBase().getUUID() < 910019) {
|
||||
if (ml.templsteID > 910010 && ml.templsteID < 910019) {
|
||||
rank = ml.getTemplsteID() - 910010;
|
||||
time = rank * 60 * 60 * 3 * 1000;
|
||||
|
||||
@@ -213,14 +213,13 @@ public class ItemFactory {
|
||||
return ml;
|
||||
}
|
||||
|
||||
|
||||
int galvorAmount = 0;
|
||||
int wormwoodAmount = 0;
|
||||
int prefixCost = 0;
|
||||
int suffixCost = 0;
|
||||
|
||||
|
||||
if (template.item_type.equals(ItemType.WEAPON) && ib.getPercentRequired() == 110) {
|
||||
if (template.item_type.equals(ItemType.WEAPON) && template.item_skill_required.isEmpty() == false &&
|
||||
template.item_skill_required.values().iterator().next() == 110) {
|
||||
switch (template.item_skill_used) {
|
||||
case "Bow":
|
||||
case "Crossbow":
|
||||
@@ -243,9 +242,6 @@ public class ItemFactory {
|
||||
}
|
||||
}
|
||||
|
||||
ItemBase galvor = ItemBase.getItemBase(1580017);
|
||||
ItemBase wormwood = ItemBase.getItemBase(1580018);
|
||||
|
||||
if (galvorAmount > 0 || wormwoodAmount > 0)
|
||||
if (!useWarehouse) {
|
||||
if (pc != null)
|
||||
@@ -255,13 +251,13 @@ public class ItemFactory {
|
||||
}
|
||||
|
||||
if (galvorAmount > 0) {
|
||||
if (Warehouse.isResourceLocked(cityWarehouse, galvor)) {
|
||||
if (Warehouse.isResourceLocked(cityWarehouse, Enum.ResourceType.GALVOR)) {
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (cityWarehouse.resources.get(galvor) < galvorAmount) {
|
||||
if (cityWarehouse.resources.get(Enum.ResourceType.GALVOR) < galvorAmount) {
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + template.item_base_name);
|
||||
return null;
|
||||
@@ -269,21 +265,23 @@ public class ItemFactory {
|
||||
}
|
||||
|
||||
if (wormwoodAmount > 0) {
|
||||
if (Warehouse.isResourceLocked(cityWarehouse, wormwood)) {
|
||||
if (Warehouse.isResourceLocked(cityWarehouse, Enum.ResourceType.WORMWOOD)) {
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Wormwood is locked." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (cityWarehouse.resources.get(wormwood) < wormwoodAmount) {
|
||||
if (cityWarehouse.resources.get(Enum.ResourceType.WORMWOOD) < wormwoodAmount) {
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Wormwood in warehouse to roll this item." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
ConcurrentHashMap<ItemBase, Integer> suffixResourceCosts = null;
|
||||
ConcurrentHashMap<ItemBase, Integer> prefixResourceCosts = null;
|
||||
ConcurrentHashMap<Enum.ResourceType, Integer> suffixResourceCosts = null;
|
||||
ConcurrentHashMap<Enum.ResourceType, Integer> prefixResourceCosts = null;
|
||||
|
||||
EffectsBase prefix = null;
|
||||
|
||||
if (pToken != 0) {
|
||||
|
||||
if (!useWarehouse) {
|
||||
@@ -303,7 +301,6 @@ public class ItemFactory {
|
||||
int total = baseCost * 10 + effectCost;
|
||||
|
||||
prefixCost = effectCost;
|
||||
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, total);
|
||||
int overdraft = BuildingManager.GetOverdraft(forge, total);
|
||||
|
||||
if (overdraft > 0 && !useWarehouse) {
|
||||
@@ -312,31 +309,29 @@ public class ItemFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, Enum.ResourceType.GOLD)) {
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
|
||||
if (overdraft > cityWarehouse.resources.get(Enum.ResourceType.GOLD)) {
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
prefixResourceCosts = prefix.getResourcesForEffect();
|
||||
for (ItemBase ibResources : prefixResourceCosts.keySet()) {
|
||||
|
||||
for (Enum.ResourceType ibResources : prefixResourceCosts.keySet()) {
|
||||
int warehouseAmount = cityWarehouse.resources.get(ibResources);
|
||||
int creationAmount = prefixResourceCosts.get(ibResources);
|
||||
//ChatManager.chatInfoError(pc, "Prefix : " + ibResources.getName() + " / " + creationAmount);
|
||||
if (warehouseAmount < creationAmount) {
|
||||
//ChatManager.chatInfoError(pc, "You need at least " + creationAmount + " " + ibResources.getName() + " to Create this item.");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (warehouseAmount < creationAmount)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
EffectsBase suffix = null;
|
||||
|
||||
if (sToken != 0) {
|
||||
|
||||
if (!useWarehouse) {
|
||||
@@ -366,7 +361,7 @@ public class ItemFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, Enum.ResourceType.GOLD)) {
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name);
|
||||
return null;
|
||||
@@ -379,22 +374,17 @@ public class ItemFactory {
|
||||
}
|
||||
|
||||
|
||||
for (ItemBase ibResources : suffixResourceCosts.keySet()) {
|
||||
for (Enum.ResourceType ibResources : suffixResourceCosts.keySet()) {
|
||||
int warehouseAmount = cityWarehouse.resources.get(ibResources);
|
||||
int creationAmount = suffixResourceCosts.get(ibResources);
|
||||
if (warehouseAmount < creationAmount) {
|
||||
// if (pc != null)
|
||||
// ChatManager.chatInfoError(pc, "You need at least " + creationAmount + " " + ibResources.getName() + " to Create this item.");
|
||||
|
||||
if (warehouseAmount < creationAmount)
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Check if Total suffix and prefix costs + itemCost can be withdrawn.
|
||||
|
||||
int costToCreate = suffixCost + prefixCost + template.item_value;
|
||||
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, costToCreate);
|
||||
|
||||
@@ -406,13 +396,13 @@ public class ItemFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (overdraft > 0 && useWarehouse && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||
if (overdraft > 0 && useWarehouse && Warehouse.isResourceLocked(cityWarehouse, Enum.ResourceType.GOLD)) {
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (useWarehouse && overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
|
||||
if (useWarehouse && overdraft > cityWarehouse.resources.get(Enum.ResourceType.GOLD)) {
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name);
|
||||
return null;
|
||||
@@ -440,7 +430,7 @@ public class ItemFactory {
|
||||
}
|
||||
|
||||
if (overdraft > 0 && useWarehouse)
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GOLD, overdraft, true)) {
|
||||
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
||||
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
|
||||
return null;
|
||||
@@ -455,7 +445,7 @@ public class ItemFactory {
|
||||
}
|
||||
|
||||
|
||||
for (ItemBase ibResources : prefixResourceCosts.keySet()) {
|
||||
for (Enum.ResourceType ibResources : prefixResourceCosts.keySet()) {
|
||||
|
||||
int creationAmount = prefixResourceCosts.get(ibResources);
|
||||
|
||||
@@ -478,7 +468,7 @@ public class ItemFactory {
|
||||
|
||||
if (suffix != null) {
|
||||
|
||||
for (ItemBase ibResources : suffixResourceCosts.keySet()) {
|
||||
for (Enum.ResourceType ibResources : suffixResourceCosts.keySet()) {
|
||||
int creationAmount = suffixResourceCosts.get(ibResources);
|
||||
|
||||
if (Warehouse.isResourceLocked(cityWarehouse, ibResources) == true) {
|
||||
@@ -488,8 +478,10 @@ public class ItemFactory {
|
||||
|
||||
int oldAmount = cityWarehouse.resources.get(ibResources);
|
||||
int amount = creationAmount;
|
||||
|
||||
if (oldAmount < amount)
|
||||
amount = oldAmount;
|
||||
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, ibResources, amount, true)) {
|
||||
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
||||
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
|
||||
@@ -514,14 +506,14 @@ public class ItemFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||
if (overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, Enum.ResourceType.GOLD)) {
|
||||
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (useWarehouse && overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
|
||||
if (useWarehouse && overdraft > cityWarehouse.resources.get(Enum.ResourceType.GOLD)) {
|
||||
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name);
|
||||
@@ -536,7 +528,7 @@ public class ItemFactory {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name);
|
||||
return null;
|
||||
} else {
|
||||
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
|
||||
if (overdraft > cityWarehouse.resources.get(Enum.ResourceType.GOLD)) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
@@ -544,7 +536,7 @@ public class ItemFactory {
|
||||
}
|
||||
|
||||
if (overdraft > 0)
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GOLD, overdraft, true)) {
|
||||
//ChatManager.chatGuildError(pc, "Failed to create Item");
|
||||
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + template.item_base_name);
|
||||
return null;
|
||||
@@ -553,7 +545,7 @@ public class ItemFactory {
|
||||
// ChatManager.chatGuildInfo(pc, "Gold Cost = " + total);
|
||||
|
||||
if (galvorAmount > 0) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, galvor, galvorAmount, true)) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GALVOR, galvorAmount, true)) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + template.item_base_name);
|
||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||
return null;
|
||||
@@ -561,14 +553,14 @@ public class ItemFactory {
|
||||
}
|
||||
|
||||
if (wormwoodAmount > 0) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, wormwood, wormwoodAmount, true)) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.WORMWOOD, wormwoodAmount, true)) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse!" + template.item_base_name);
|
||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
ml = new MobLoot(npc, ib, false);
|
||||
ml = new MobLoot(npc, template, false);
|
||||
|
||||
ml.containerType = Enum.ItemContainerType.FORGE;
|
||||
ml.setName(customName);
|
||||
@@ -767,18 +759,14 @@ public class ItemFactory {
|
||||
return toRoll;
|
||||
}
|
||||
|
||||
public static MobLoot produceRandomRoll(NPC npc, PlayerCharacter pc, String prefixString, String suffixString, int itemID) {
|
||||
public static MobLoot produceRandomRoll(NPC npc, PlayerCharacter pc, String prefixString, String suffixString, int templateID) {
|
||||
|
||||
boolean useWarehouse = false;
|
||||
|
||||
if (npc == null)
|
||||
return null;
|
||||
|
||||
ItemBase ib = ItemBase.getItemBase(itemID);
|
||||
ItemTemplate template = ItemTemplate.itemTemplates.get(itemID);
|
||||
|
||||
if (ib == null)
|
||||
return null;
|
||||
ItemTemplate template = ItemTemplate.itemTemplates.get(templateID);
|
||||
|
||||
Building forge = npc.getBuilding();
|
||||
|
||||
@@ -806,7 +794,7 @@ public class ItemFactory {
|
||||
if (cityWarehouse != null && forge.assetIsProtected())
|
||||
useWarehouse = true;
|
||||
|
||||
ConcurrentHashMap<ItemBase, Integer> resources = null;
|
||||
ConcurrentHashMap<Enum.ResourceType, Integer> resources = null;
|
||||
|
||||
if (useWarehouse)
|
||||
resources = cityWarehouse.resources;
|
||||
@@ -814,7 +802,8 @@ public class ItemFactory {
|
||||
int galvorAmount = 0;
|
||||
int wormwoodAmount = 0;
|
||||
|
||||
if (template.item_type.equals(ItemType.WEAPON) && ib.getPercentRequired() == 110) {
|
||||
if (template.item_type.equals(ItemType.WEAPON) && template.item_skill_required.isEmpty() == false &&
|
||||
template.item_skill_required.values().iterator().next() == 110) {
|
||||
switch (template.item_skill_used) {
|
||||
case "Bow":
|
||||
case "Crossbow":
|
||||
@@ -837,33 +826,30 @@ public class ItemFactory {
|
||||
}
|
||||
}
|
||||
|
||||
ItemBase galvor = ItemBase.getItemBase(1580017);
|
||||
ItemBase wormwood = ItemBase.getItemBase(1580018);
|
||||
|
||||
//Cant roll 110% weapons that require resources if not allowed to use warehouse.
|
||||
if (galvorAmount > 0 || wormwoodAmount > 0)
|
||||
if (!useWarehouse)
|
||||
return null;
|
||||
|
||||
if (galvorAmount > 0) {
|
||||
if (Warehouse.isResourceLocked(cityWarehouse, galvor)) {
|
||||
if (Warehouse.isResourceLocked(cityWarehouse, Enum.ResourceType.GALVOR)) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (cityWarehouse.resources.get(galvor) < galvorAmount) {
|
||||
if (cityWarehouse.resources.get(Enum.ResourceType.GALVOR) < galvorAmount) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (wormwoodAmount > 0) {
|
||||
if (Warehouse.isResourceLocked(cityWarehouse, wormwood)) {
|
||||
if (Warehouse.isResourceLocked(cityWarehouse, Enum.ResourceType.WORMWOOD)) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (cityWarehouse.resources.get(wormwood) < wormwoodAmount) {
|
||||
if (cityWarehouse.resources.get(Enum.ResourceType.WORMWOOD) < wormwoodAmount) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
@@ -877,8 +863,6 @@ public class ItemFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemBase goldIB = ItemBase.getGoldItemBase();
|
||||
|
||||
int baseCost = template.item_value;
|
||||
int total = (int) (baseCost + baseCost * .10);
|
||||
|
||||
@@ -902,13 +886,13 @@ public class ItemFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||
if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, Enum.ResourceType.GOLD)) {
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (useWarehouse && overdraft > resources.get(goldIB)) {
|
||||
if (useWarehouse && overdraft > resources.get(Enum.ResourceType.GOLD)) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
@@ -920,7 +904,7 @@ public class ItemFactory {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name);
|
||||
return null;
|
||||
} else {
|
||||
if (overdraft > resources.get(goldIB)) {
|
||||
if (overdraft > resources.get(Enum.ResourceType.GOLD)) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
@@ -930,12 +914,12 @@ public class ItemFactory {
|
||||
// there was an overdraft, withdraw the rest from warehouse.
|
||||
if (overdraft > 0) {
|
||||
if (pc != null) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, pc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, pc, Enum.ResourceType.GOLD, overdraft, false, true)) {
|
||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GOLD, overdraft, true)) {
|
||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||
return null;
|
||||
}
|
||||
@@ -953,13 +937,13 @@ public class ItemFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
|
||||
if (useWarehouse && overdraft > 0 && Warehouse.isResourceLocked(cityWarehouse, Enum.ResourceType.GOLD)) {
|
||||
if (pc != null)
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (useWarehouse && overdraft > resources.get(goldIB)) {
|
||||
if (useWarehouse && overdraft > resources.get(Enum.ResourceType.GOLD)) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
@@ -971,7 +955,7 @@ public class ItemFactory {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + template.item_base_name);
|
||||
return null;
|
||||
} else {
|
||||
if (overdraft > resources.get(goldIB)) {
|
||||
if (overdraft > resources.get(Enum.ResourceType.GOLD)) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + template.item_base_name);
|
||||
return null;
|
||||
}
|
||||
@@ -981,12 +965,12 @@ public class ItemFactory {
|
||||
if (overdraft > 0 && useWarehouse) {
|
||||
|
||||
if (pc != null) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, pc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, pc, Enum.ResourceType.GOLD, overdraft, false, true)) {
|
||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GOLD, overdraft, true)) {
|
||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||
return null;
|
||||
}
|
||||
@@ -996,7 +980,7 @@ public class ItemFactory {
|
||||
|
||||
if (galvorAmount > 0 && useWarehouse) {
|
||||
//ChatManager.chatGuildInfo(pc, "Withdrawing " + galvorAmount + " galvor from warehouse");
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, galvor, galvorAmount, true)) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.GALVOR, galvorAmount, true)) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + template.item_base_name);
|
||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||
return null;
|
||||
@@ -1005,7 +989,7 @@ public class ItemFactory {
|
||||
|
||||
if (wormwoodAmount > 0 && useWarehouse) {
|
||||
//ChatManager.chatGuildInfo(pc, "Withdrawing " + wormwoodAmount + " wormwood from warehouse");
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, wormwood, wormwoodAmount, true)) {
|
||||
if (!Warehouse.withdraw(cityWarehouse, npc, Enum.ResourceType.WORMWOOD, wormwoodAmount, true)) {
|
||||
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse for " + template.item_base_name);
|
||||
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
|
||||
|
||||
@@ -1013,7 +997,7 @@ public class ItemFactory {
|
||||
}
|
||||
}
|
||||
|
||||
ml = new MobLoot(npc, ib, false);
|
||||
ml = new MobLoot(npc, template, false);
|
||||
|
||||
ml.containerType = Enum.ItemContainerType.FORGE;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user