Warehosue cleanup

This commit is contained in:
2024-01-24 20:03:27 -06:00
parent 92d8ed9e3f
commit cc1e0d8986
20 changed files with 1038 additions and 1425 deletions
+47 -47
View File
@@ -119,7 +119,7 @@ public class ItemFactory {
// ROLL BANE SCROLL.
if (ib.getUUID() > 910010 && ib.getUUID() < 910019) {
ConcurrentHashMap<ItemBase, Integer> resources = cityWarehouse.getResources();
ConcurrentHashMap<ItemBase, Integer> resources = cityWarehouse.resources;
int buildingWithdraw = BuildingManager.GetWithdrawAmountForRolling(forge, ib.getBaseValue());
@@ -131,7 +131,7 @@ public class ItemFactory {
return null;
}
if (overdraft > 0 && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
if (overdraft > 0 && WarehouseManager.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + " " + ib.getName());
return null;
@@ -167,9 +167,9 @@ public class ItemFactory {
}
if (overdraft > 0)
if (!cityWarehouse.withdraw(npc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.getUID() + " Failed to Create Item." + ib.getName());
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName());
return null;
}
@@ -263,13 +263,13 @@ public class ItemFactory {
}
if (galvorAmount > 0) {
if (cityWarehouse.isResourceLocked(galvor)) {
if (WarehouseManager.isResourceLocked(cityWarehouse, galvor)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName());
return null;
}
if (cityWarehouse.getResources().get(galvor) < galvorAmount) {
if (cityWarehouse.resources.get(galvor) < galvorAmount) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + ib.getName());
return null;
@@ -277,13 +277,13 @@ public class ItemFactory {
}
if (wormwoodAmount > 0) {
if (cityWarehouse.isResourceLocked(wormwood)) {
if (WarehouseManager.isResourceLocked(cityWarehouse, wormwood)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Wormwood is locked." + ib.getName());
return null;
}
if (cityWarehouse.getResources().get(wormwood) < wormwoodAmount) {
if (cityWarehouse.resources.get(wormwood) < wormwoodAmount) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Wormwood in warehouse to roll this item." + ib.getName());
return null;
@@ -320,20 +320,20 @@ public class ItemFactory {
return null;
}
if (overdraft > 0 && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
if (overdraft > 0 && WarehouseManager.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
return null;
}
if (overdraft > cityWarehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) {
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName());
return null;
}
prefixResourceCosts = prefix.getResourcesForEffect();
for (ItemBase ibResources : prefixResourceCosts.keySet()) {
int warehouseAmount = cityWarehouse.getResources().get(ibResources);
int warehouseAmount = cityWarehouse.resources.get(ibResources);
int creationAmount = prefixResourceCosts.get(ibResources);
//ChatManager.chatInfoError(pc, "Prefix : " + ibResources.getName() + " / " + creationAmount);
if (warehouseAmount < creationAmount) {
@@ -374,13 +374,13 @@ public class ItemFactory {
return null;
}
if (overdraft > 0 && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
if (overdraft > 0 && WarehouseManager.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
return null;
}
if (overdraft > cityWarehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) {
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName());
return null;
@@ -388,7 +388,7 @@ public class ItemFactory {
for (ItemBase ibResources : suffixResourceCosts.keySet()) {
int warehouseAmount = cityWarehouse.getResources().get(ibResources);
int warehouseAmount = cityWarehouse.resources.get(ibResources);
int creationAmount = suffixResourceCosts.get(ibResources);
if (warehouseAmount < creationAmount) {
// if (pc != null)
@@ -414,13 +414,13 @@ public class ItemFactory {
return null;
}
if (overdraft > 0 && useWarehouse && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
if (overdraft > 0 && useWarehouse && WarehouseManager.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
return null;
}
if (useWarehouse && overdraft > cityWarehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) {
if (useWarehouse && overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName());
return null;
@@ -440,7 +440,7 @@ public class ItemFactory {
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + ib.getName());
return null;
} else {
if (overdraft > cityWarehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) {
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + ib.getName());
return null;
}
@@ -448,9 +448,9 @@ public class ItemFactory {
}
if (overdraft > 0 && useWarehouse)
if (!cityWarehouse.withdraw(npc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.getUID() + " Failed to Create Item." + ib.getName());
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName());
return null;
}
@@ -467,18 +467,18 @@ public class ItemFactory {
int creationAmount = prefixResourceCosts.get(ibResources);
if (cityWarehouse.isResourceLocked(ibResources) == true)
if (WarehouseManager.isResourceLocked(cityWarehouse, ibResources) == true)
return null;
int oldAmount = cityWarehouse.getResources().get(ibResources);
int oldAmount = cityWarehouse.resources.get(ibResources);
int amount = creationAmount;
if (oldAmount < amount)
amount = oldAmount;
if (!cityWarehouse.withdraw(npc, ibResources, amount, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, npc, ibResources, amount, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.getUID() + " Failed to Create Item." + ib.getName());
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName());
return null;
}
}
@@ -489,18 +489,18 @@ public class ItemFactory {
for (ItemBase ibResources : suffixResourceCosts.keySet()) {
int creationAmount = suffixResourceCosts.get(ibResources);
if (cityWarehouse.isResourceLocked(ibResources) == true) {
if (WarehouseManager.isResourceLocked(cityWarehouse, ibResources) == true) {
ChatManager.chatSystemError(pc, ibResources.getName() + " is locked!" + ib.getName());
return null;
}
int oldAmount = cityWarehouse.getResources().get(ibResources);
int oldAmount = cityWarehouse.resources.get(ibResources);
int amount = creationAmount;
if (oldAmount < amount)
amount = oldAmount;
if (!cityWarehouse.withdraw(npc, ibResources, amount, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, npc, ibResources, amount, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.getUID() + " Failed to Create Item." + ib.getName());
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName());
return null;
}
}
@@ -522,14 +522,14 @@ public class ItemFactory {
return null;
}
if (overdraft > 0 && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
if (overdraft > 0 && WarehouseManager.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
return null;
}
if (useWarehouse && overdraft > cityWarehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) {
if (useWarehouse && overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse for overdraft." + ib.getName());
@@ -544,7 +544,7 @@ public class ItemFactory {
ErrorPopupMsg.sendErrorMsg(pc, "Building does not have enough gold to produce this item." + ib.getName());
return null;
} else {
if (overdraft > cityWarehouse.getResources().get(ItemBase.GOLD_ITEM_BASE)) {
if (overdraft > cityWarehouse.resources.get(ItemBase.GOLD_ITEM_BASE)) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Gold in Warehouse to produce this item." + ib.getName());
return null;
}
@@ -552,16 +552,16 @@ public class ItemFactory {
}
if (overdraft > 0)
if (!cityWarehouse.withdraw(npc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
//ChatManager.chatGuildError(pc, "Failed to create Item");
Logger.error("Warehouse With UID of " + cityWarehouse.getUID() + " Failed to Create Item." + ib.getName());
Logger.error("Warehouse With UID of " + cityWarehouse.UID + " Failed to Create Item." + ib.getName());
return null;
}
// ChatManager.chatGuildInfo(pc, "Gold Cost = " + total);
if (galvorAmount > 0) {
if (!cityWarehouse.withdraw(npc, galvor, galvorAmount, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, npc, galvor, galvorAmount, true)) {
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + ib.getName());
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
return null;
@@ -569,7 +569,7 @@ public class ItemFactory {
}
if (wormwoodAmount > 0) {
if (!cityWarehouse.withdraw(npc, wormwood, wormwoodAmount, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, npc, wormwood, wormwoodAmount, true)) {
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse!" + ib.getName());
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
return null;
@@ -815,7 +815,7 @@ public class ItemFactory {
ConcurrentHashMap<ItemBase, Integer> resources = null;
if (useWarehouse)
resources = cityWarehouse.getResources();
resources = cityWarehouse.resources;
int galvorAmount = 0;
int wormwoodAmount = 0;
@@ -852,24 +852,24 @@ public class ItemFactory {
return null;
if (galvorAmount > 0) {
if (cityWarehouse.isResourceLocked(galvor)) {
if (WarehouseManager.isResourceLocked(cityWarehouse, galvor)) {
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName());
return null;
}
if (cityWarehouse.getResources().get(galvor) < galvorAmount) {
if (cityWarehouse.resources.get(galvor) < galvorAmount) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + ib.getName());
return null;
}
}
if (wormwoodAmount > 0) {
if (cityWarehouse.isResourceLocked(wormwood)) {
if (WarehouseManager.isResourceLocked(cityWarehouse, wormwood)) {
ErrorPopupMsg.sendErrorMsg(pc, "Galvor is locked." + ib.getName());
return null;
}
if (cityWarehouse.getResources().get(wormwood) < wormwoodAmount) {
if (cityWarehouse.resources.get(wormwood) < wormwoodAmount) {
ErrorPopupMsg.sendErrorMsg(pc, "Not enough Galvor in warehouse to roll this item." + ib.getName());
return null;
}
@@ -908,7 +908,7 @@ public class ItemFactory {
return null;
}
if (useWarehouse && overdraft > 0 && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
if (useWarehouse && overdraft > 0 && WarehouseManager.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
return null;
@@ -936,12 +936,12 @@ public class ItemFactory {
// there was an overdraft, withdraw the rest from warehouse.
if (overdraft > 0) {
if (pc != null) {
if (!cityWarehouse.withdraw(pc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, pc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
return null;
}
} else {
if (!cityWarehouse.withdraw(npc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
return null;
}
@@ -959,7 +959,7 @@ public class ItemFactory {
return null;
}
if (useWarehouse && overdraft > 0 && cityWarehouse.isResourceLocked(ItemBase.GOLD_ITEM_BASE)) {
if (useWarehouse && overdraft > 0 && WarehouseManager.isResourceLocked(cityWarehouse, ItemBase.GOLD_ITEM_BASE)) {
if (pc != null)
ErrorPopupMsg.sendErrorMsg(pc, "Warehouse gold is barred! Overdraft cannot be withdrawn from warehouse." + ib.getName());
return null;
@@ -987,12 +987,12 @@ public class ItemFactory {
if (overdraft > 0 && useWarehouse) {
if (pc != null) {
if (!cityWarehouse.withdraw(pc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, pc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
return null;
}
} else {
if (!cityWarehouse.withdraw(npc, ItemBase.GOLD_ITEM_BASE, overdraft, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, npc, ItemBase.GOLD_ITEM_BASE, overdraft, true)) {
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
return null;
}
@@ -1002,7 +1002,7 @@ public class ItemFactory {
if (galvorAmount > 0 && useWarehouse) {
//ChatManager.chatGuildInfo(pc, "Withdrawing " + galvorAmount + " galvor from warehouse");
if (!cityWarehouse.withdraw(npc, galvor, galvorAmount, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, npc, galvor, galvorAmount, true)) {
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Galvor from warehouse!" + ib.getName());
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");
return null;
@@ -1011,7 +1011,7 @@ public class ItemFactory {
if (wormwoodAmount > 0 && useWarehouse) {
//ChatManager.chatGuildInfo(pc, "Withdrawing " + wormwoodAmount + " wormwood from warehouse");
if (!cityWarehouse.withdraw(npc, wormwood, wormwoodAmount, false, true)) {
if (!WarehouseManager.withdraw(cityWarehouse, npc, wormwood, wormwoodAmount, true)) {
ErrorPopupMsg.sendErrorMsg(pc, "Failed to withdraw Wormwood from warehouse for " + ib.getName());
Logger.error("Warehouse with UID of" + cityWarehouse.getObjectUUID() + "Failed to Withdrawl ");