From 2e37bd2472a1f397079d6a9134d57548df83d8c1 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Thu, 14 Mar 2024 13:58:51 -0400 Subject: [PATCH] deposit limits use type lookup --- src/engine/devcmd/cmds/MakeItemCmd.java | 45 ------------------- .../net/client/msg/ViewResourcesMessage.java | 2 +- src/engine/objects/Building.java | 8 ++-- src/engine/objects/Warehouse.java | 41 +++-------------- 4 files changed, 10 insertions(+), 86 deletions(-) diff --git a/src/engine/devcmd/cmds/MakeItemCmd.java b/src/engine/devcmd/cmds/MakeItemCmd.java index 8761a20c..6fabc1ce 100644 --- a/src/engine/devcmd/cmds/MakeItemCmd.java +++ b/src/engine/devcmd/cmds/MakeItemCmd.java @@ -9,7 +9,6 @@ package engine.devcmd.cmds; -import engine.Enum.ItemContainerType; import engine.Enum.ItemType; import engine.Enum.OwnerType; import engine.devcmd.AbstractDevCmd; @@ -30,50 +29,6 @@ public class MakeItemCmd extends AbstractDevCmd { protected void _doCmd(PlayerCharacter pc, String[] words, AbstractGameObject target) { - if (words[0].equals("resources")) { - - for (int ibID : Warehouse.getMaxResources().keySet()) { - - if (ibID == 7) - continue; - - ItemTemplate template = ItemTemplate.itemTemplates.get(ibID); - - int weight = template.item_wt; - - if (!pc.getCharItemManager().hasRoomInventory(weight)) { - throwbackError(pc, "Not enough room in inventory for any more of this item"); - pc.getCharItemManager().updateInventory(); - return; - } - - boolean worked = false; - Item item = new Item(template.template_id); - item.ownerID = pc.getObjectUUID(); - item.ownerType = OwnerType.PlayerCharacter; - item.containerType = ItemContainerType.INVENTORY; - - item.setNumOfItems(Warehouse.getMaxResources().get(ibID)); - - try { - item = DbManager.ItemQueries.PERSIST(item); - worked = true; - } catch (Exception e) { - throwbackError(pc, "DB error 1: Unable to create item. " + e.getMessage()); - return; - } - - if (item == null || !worked) { - throwbackError(pc, "DB error 2: Unable to create item."); - return; - } - - - //add item to inventory - pc.getCharItemManager().addItemToInventory(item); - } - return; - } if (words.length < 3 || words.length > 5) { this.sendUsage(pc); return; diff --git a/src/engine/net/client/msg/ViewResourcesMessage.java b/src/engine/net/client/msg/ViewResourcesMessage.java index f4ad9552..2897860a 100644 --- a/src/engine/net/client/msg/ViewResourcesMessage.java +++ b/src/engine/net/client/msg/ViewResourcesMessage.java @@ -110,7 +110,7 @@ public class ViewResourcesMessage extends ClientNetMsg { Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(ib.getUUID()); writer.putInt(resourceType.hash); writer.putInt(0); //available? - writer.putInt(Warehouse.getMaxResources().get(ib.getUUID())); //max? + writer.putInt(Enum.ResourceType.resourceLookup.get(ib.getUUID()).deposit_limit); //max? } GuildTag._serializeForDisplay(guild.getGuildTag(), writer); diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index 138d1ef5..5f6c44ba 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -1429,17 +1429,17 @@ public class Building extends AbstractWorldObject { if (this.getCity().getWarehouse() == null) return amount; - if (this.getCity().getWarehouse().resources.get(ItemBase.getGoldItemBase()) >= Warehouse.getMaxResources().get(ItemBase.getGoldItemBase().getUUID())) + if (this.getCity().getWarehouse().resources.get(ItemBase.getGoldItemBase()) >= Enum.ResourceType.resourceLookup.get(ResourceType.GOLD.templateID).deposit_limit) return amount; int profitAmount = (int) (amount * (taxAmount * .01f)); - if (this.getCity().getWarehouse().resources.get(ItemBase.getGoldItemBase()) + profitAmount <= Warehouse.getMaxResources().get(ItemBase.getGoldItemBase().getUUID())) { - Warehouse.depositProfitTax(ItemBase.getGoldItemBase(), profitAmount, this,this.getCity().getWarehouse()); + if (this.getCity().getWarehouse().resources.get(ItemBase.getGoldItemBase()) + profitAmount <= Enum.ResourceType.resourceLookup.get(ResourceType.GOLD.templateID).deposit_limit) { + Warehouse.depositProfitTax(ItemBase.getGoldItemBase(), profitAmount, this, this.getCity().getWarehouse()); return amount - profitAmount; } //overDrafting - int warehouseDeposit = Warehouse.getMaxResources().get(ItemBase.getGoldItemBase().getUUID()) - this.getCity().getWarehouse().resources.get(ItemBase.getGoldItemBase()); + int warehouseDeposit = Enum.ResourceType.resourceLookup.get(ResourceType.GOLD.templateID).deposit_limit - this.getCity().getWarehouse().resources.get(ItemBase.getGoldItemBase()); Warehouse.depositProfitTax(ItemBase.getGoldItemBase(), warehouseDeposit, this,this.getCity().getWarehouse()); return amount - warehouseDeposit; } diff --git a/src/engine/objects/Warehouse.java b/src/engine/objects/Warehouse.java index ed52c6a5..c30ce7af 100644 --- a/src/engine/objects/Warehouse.java +++ b/src/engine/objects/Warehouse.java @@ -73,36 +73,6 @@ public class Warehouse extends AbstractWorldObject { warehouseByBuildingUUID.put(this.buildingUID, this); } - public static ConcurrentHashMap getMaxResources() { - if (maxResources.size() != 23) { - maxResources.put(7, 100000000); - maxResources.put(1580000, 10000); - maxResources.put(1580001, 2000); - maxResources.put(1580002, 2000); - maxResources.put(1580003, 1000); - maxResources.put(1580004, 10000); - maxResources.put(1580005, 3000); - maxResources.put(1580006, 3000); - maxResources.put(1580007, 1000); - maxResources.put(1580008, 3000); - maxResources.put(1580009, 2000); - maxResources.put(1580010, 2000); - maxResources.put(1580011, 1000); - maxResources.put(1580012, 2000); - maxResources.put(1580013, 3000); - maxResources.put(1580014, 1000); - maxResources.put(1580015, 1000); - maxResources.put(1580016, 1000); - maxResources.put(1580017, 500); - maxResources.put(1580018, 500); - maxResources.put(1580019, 500); - maxResources.put(1580020, 500); - maxResources.put(1580021, 500); - } - - return maxResources; - } - public static void warehouseDeposit(MerchantMsg msg, PlayerCharacter player, NPC npc) { Building warehouseBuilding; @@ -282,7 +252,6 @@ public class Warehouse extends AbstractWorldObject { return false; } - if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID())) return false; @@ -296,7 +265,7 @@ public class Warehouse extends AbstractWorldObject { int newAmount = oldAmount + amount; - if (newAmount > getMaxResources().get(ib.getUUID())) { + if (newAmount > Enum.ResourceType.resourceLookup.get(resource.templsteID).deposit_limit) { //ChatManager.chatSystemInfo(pc, "The Warehouse is at it's maximum for this type of resource."); return false; } @@ -353,7 +322,7 @@ public class Warehouse extends AbstractWorldObject { int oldAmount = warehouse.resources.get(resource); int newAmount = oldAmount + amount; - if (newAmount > getMaxResources().get(resource.getUUID())) + if (newAmount > Enum.ResourceType.resourceLookup.get(resource.getUUID()).deposit_limit) return false; if (!DepositApproved(resource, amount, warehouse)) @@ -385,7 +354,7 @@ public class Warehouse extends AbstractWorldObject { int oldAmount = warehouse.resources.get(ib); int newAmount = oldAmount + amount; - if (newAmount > getMaxResources().get(ib.getUUID())) + if (newAmount > Enum.ResourceType.resourceLookup.get(ib.getUUID()).deposit_limit) return false; int itemID = ib.getUUID(); @@ -499,7 +468,7 @@ public class Warehouse extends AbstractWorldObject { int oldAmount = warehouse.resources.get(ib); int newAmount = oldAmount + amount; - if (newAmount > getMaxResources().get(ib.getUUID())) + if (newAmount > Enum.ResourceType.resourceLookup.get(ib.getUUID()).deposit_limit) return; if (!DepositApproved(ib,amount,warehouse)) @@ -880,7 +849,7 @@ public class Warehouse extends AbstractWorldObject { public static boolean isAboveCap(Warehouse warehouse, ItemBase ib, int deposit) { int newAmount = warehouse.resources.get(ib) + deposit; - return newAmount > getMaxResources().get(ib.getUUID()); + return newAmount > Enum.ResourceType.resourceLookup.get(ib.getUUID()).deposit_limit; }