forked from MagicBane/Server
deposit limits use type lookup
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -73,36 +73,6 @@ public class Warehouse extends AbstractWorldObject {
|
||||
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) {
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user