Browse Source

deposit limits use type lookup

combat-2
MagicBot 8 months ago
parent
commit
2e37bd2472
  1. 45
      src/engine/devcmd/cmds/MakeItemCmd.java
  2. 2
      src/engine/net/client/msg/ViewResourcesMessage.java
  3. 6
      src/engine/objects/Building.java
  4. 41
      src/engine/objects/Warehouse.java

45
src/engine/devcmd/cmds/MakeItemCmd.java

@ -9,7 +9,6 @@
package engine.devcmd.cmds; package engine.devcmd.cmds;
import engine.Enum.ItemContainerType;
import engine.Enum.ItemType; import engine.Enum.ItemType;
import engine.Enum.OwnerType; import engine.Enum.OwnerType;
import engine.devcmd.AbstractDevCmd; import engine.devcmd.AbstractDevCmd;
@ -30,50 +29,6 @@ public class MakeItemCmd extends AbstractDevCmd {
protected void _doCmd(PlayerCharacter pc, String[] words, protected void _doCmd(PlayerCharacter pc, String[] words,
AbstractGameObject target) { 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) { if (words.length < 3 || words.length > 5) {
this.sendUsage(pc); this.sendUsage(pc);
return; return;

2
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()); Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(ib.getUUID());
writer.putInt(resourceType.hash); writer.putInt(resourceType.hash);
writer.putInt(0); //available? 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); GuildTag._serializeForDisplay(guild.getGuildTag(), writer);

6
src/engine/objects/Building.java

@ -1429,17 +1429,17 @@ public class Building extends AbstractWorldObject {
if (this.getCity().getWarehouse() == null) if (this.getCity().getWarehouse() == null)
return amount; 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; return amount;
int profitAmount = (int) (amount * (taxAmount * .01f)); int profitAmount = (int) (amount * (taxAmount * .01f));
if (this.getCity().getWarehouse().resources.get(ItemBase.getGoldItemBase()) + profitAmount <= Warehouse.getMaxResources().get(ItemBase.getGoldItemBase().getUUID())) { 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()); Warehouse.depositProfitTax(ItemBase.getGoldItemBase(), profitAmount, this, this.getCity().getWarehouse());
return amount - profitAmount; return amount - profitAmount;
} }
//overDrafting //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()); Warehouse.depositProfitTax(ItemBase.getGoldItemBase(), warehouseDeposit, this,this.getCity().getWarehouse());
return amount - warehouseDeposit; return amount - warehouseDeposit;
} }

41
src/engine/objects/Warehouse.java

@ -73,36 +73,6 @@ public class Warehouse extends AbstractWorldObject {
warehouseByBuildingUUID.put(this.buildingUID, this); warehouseByBuildingUUID.put(this.buildingUID, this);
} }
public static ConcurrentHashMap<Integer, Integer> 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) { public static void warehouseDeposit(MerchantMsg msg, PlayerCharacter player, NPC npc) {
Building warehouseBuilding; Building warehouseBuilding;
@ -282,7 +252,6 @@ public class Warehouse extends AbstractWorldObject {
return false; return false;
} }
if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID())) if (!itemMan.doesCharOwnThisItem(resource.getObjectUUID()))
return false; return false;
@ -296,7 +265,7 @@ public class Warehouse extends AbstractWorldObject {
int newAmount = oldAmount + amount; 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."); //ChatManager.chatSystemInfo(pc, "The Warehouse is at it's maximum for this type of resource.");
return false; return false;
} }
@ -353,7 +322,7 @@ public class Warehouse extends AbstractWorldObject {
int oldAmount = warehouse.resources.get(resource); int oldAmount = warehouse.resources.get(resource);
int newAmount = oldAmount + amount; int newAmount = oldAmount + amount;
if (newAmount > getMaxResources().get(resource.getUUID())) if (newAmount > Enum.ResourceType.resourceLookup.get(resource.getUUID()).deposit_limit)
return false; return false;
if (!DepositApproved(resource, amount, warehouse)) if (!DepositApproved(resource, amount, warehouse))
@ -385,7 +354,7 @@ public class Warehouse extends AbstractWorldObject {
int oldAmount = warehouse.resources.get(ib); int oldAmount = warehouse.resources.get(ib);
int newAmount = oldAmount + amount; int newAmount = oldAmount + amount;
if (newAmount > getMaxResources().get(ib.getUUID())) if (newAmount > Enum.ResourceType.resourceLookup.get(ib.getUUID()).deposit_limit)
return false; return false;
int itemID = ib.getUUID(); int itemID = ib.getUUID();
@ -499,7 +468,7 @@ public class Warehouse extends AbstractWorldObject {
int oldAmount = warehouse.resources.get(ib); int oldAmount = warehouse.resources.get(ib);
int newAmount = oldAmount + amount; int newAmount = oldAmount + amount;
if (newAmount > getMaxResources().get(ib.getUUID())) if (newAmount > Enum.ResourceType.resourceLookup.get(ib.getUUID()).deposit_limit)
return; return;
if (!DepositApproved(ib,amount,warehouse)) if (!DepositApproved(ib,amount,warehouse))
@ -880,7 +849,7 @@ public class Warehouse extends AbstractWorldObject {
public static boolean isAboveCap(Warehouse warehouse, ItemBase ib, int deposit) { public static boolean isAboveCap(Warehouse warehouse, ItemBase ib, int deposit) {
int newAmount = warehouse.resources.get(ib) + deposit; int newAmount = warehouse.resources.get(ib) + deposit;
return newAmount > getMaxResources().get(ib.getUUID()); return newAmount > Enum.ResourceType.resourceLookup.get(ib.getUUID()).deposit_limit;
} }

Loading…
Cancel
Save