|
|
@ -34,7 +34,7 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
public int UID; |
|
|
|
public int UID; |
|
|
|
public int buildingUID; |
|
|
|
public int buildingUID; |
|
|
|
public ArrayList<Transaction> transactions = new ArrayList<>(); |
|
|
|
public ArrayList<Transaction> transactions = new ArrayList<>(); |
|
|
|
public ConcurrentHashMap<ItemBase, Integer> resources = new ConcurrentHashMap<>(); |
|
|
|
public ConcurrentHashMap<Enum.ResourceType, Integer> resources = new ConcurrentHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -43,29 +43,29 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
public Warehouse(ResultSet rs) throws SQLException { |
|
|
|
public Warehouse(ResultSet rs) throws SQLException { |
|
|
|
super(rs); |
|
|
|
super(rs); |
|
|
|
this.UID = rs.getInt("UID"); |
|
|
|
this.UID = rs.getInt("UID"); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580000), rs.getInt("warehouse_stone")); |
|
|
|
this.resources.put(Enum.ResourceType.STONE, rs.getInt("warehouse_stone")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580001), rs.getInt("warehouse_truesteel")); |
|
|
|
this.resources.put(Enum.ResourceType.TRUESTEEL, rs.getInt("warehouse_truesteel")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580002), rs.getInt("warehouse_iron")); |
|
|
|
this.resources.put(Enum.ResourceType.IRON, rs.getInt("warehouse_iron")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580003), rs.getInt("warehouse_adamant")); |
|
|
|
this.resources.put(Enum.ResourceType.ADAMANT, rs.getInt("warehouse_adamant")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580004), rs.getInt("warehouse_lumber")); |
|
|
|
this.resources.put(Enum.ResourceType.LUMBER, rs.getInt("warehouse_lumber")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580005), rs.getInt("warehouse_oak")); |
|
|
|
this.resources.put(Enum.ResourceType.OAK, rs.getInt("warehouse_oak")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580006), rs.getInt("warehouse_bronzewood")); |
|
|
|
this.resources.put(Enum.ResourceType.BRONZEWOOD, rs.getInt("warehouse_bronzewood")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580007), rs.getInt("warehouse_mandrake")); |
|
|
|
this.resources.put(Enum.ResourceType.MANDRAKE, rs.getInt("warehouse_mandrake")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580008), rs.getInt("warehouse_coal")); |
|
|
|
this.resources.put(Enum.ResourceType.COAL, rs.getInt("warehouse_coal")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580009), rs.getInt("warehouse_agate")); |
|
|
|
this.resources.put(Enum.ResourceType.AGATE, rs.getInt("warehouse_agate")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580010), rs.getInt("warehouse_diamond")); |
|
|
|
this.resources.put(Enum.ResourceType.DIAMOND, rs.getInt("warehouse_diamond")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580011), rs.getInt("warehouse_onyx")); |
|
|
|
this.resources.put(Enum.ResourceType.ONYX, rs.getInt("warehouse_onyx")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580012), rs.getInt("warehouse_azoth")); |
|
|
|
this.resources.put(Enum.ResourceType.AZOTH, rs.getInt("warehouse_azoth")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580013), rs.getInt("warehouse_orichalk")); |
|
|
|
this.resources.put(Enum.ResourceType.ORICHALK, rs.getInt("warehouse_orichalk")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580014), rs.getInt("warehouse_antimony")); |
|
|
|
this.resources.put(Enum.ResourceType.ANTIMONY, rs.getInt("warehouse_antimony")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580015), rs.getInt("warehouse_sulfur")); |
|
|
|
this.resources.put(Enum.ResourceType.SULFUR, rs.getInt("warehouse_sulfur")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580016), rs.getInt("warehouse_quicksilver")); |
|
|
|
this.resources.put(Enum.ResourceType.QUICKSILVER, rs.getInt("warehouse_quicksilver")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580017), rs.getInt("warehouse_galvor")); |
|
|
|
this.resources.put(Enum.ResourceType.GALVOR, rs.getInt("warehouse_galvor")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580018), rs.getInt("warehouse_wormwood")); |
|
|
|
this.resources.put(Enum.ResourceType.WORMWOOD, rs.getInt("warehouse_wormwood")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580019), rs.getInt("warehouse_obsidian")); |
|
|
|
this.resources.put(Enum.ResourceType.OBSIDIAN, rs.getInt("warehouse_obsidian")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580020), rs.getInt("warehouse_bloodstone")); |
|
|
|
this.resources.put(Enum.ResourceType.BLOODSTONE, rs.getInt("warehouse_bloodstone")); |
|
|
|
this.resources.put(ItemBase.getItemBase(1580021), rs.getInt("warehouse_mithril")); |
|
|
|
this.resources.put(Enum.ResourceType.MITHRIL, rs.getInt("warehouse_mithril")); |
|
|
|
this.resources.put(ItemBase.getItemBase(7), rs.getInt("warehouse_gold")); |
|
|
|
this.resources.put(Enum.ResourceType.GOLD, rs.getInt("warehouse_gold")); |
|
|
|
this.lockedResourceTypes = EnumBitSet.asEnumBitSet(rs.getLong("warehouse_locks"), Enum.ResourceType.class); |
|
|
|
this.lockedResourceTypes = EnumBitSet.asEnumBitSet(rs.getLong("warehouse_locks"), Enum.ResourceType.class); |
|
|
|
this.buildingUID = rs.getInt("parent"); |
|
|
|
this.buildingUID = rs.getInt("parent"); |
|
|
|
warehouseByBuildingUUID.put(this.buildingUID, this); |
|
|
|
warehouseByBuildingUUID.put(this.buildingUID, this); |
|
|
@ -133,24 +133,15 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
if (warehouse == null) |
|
|
|
if (warehouse == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
int hashID = msg.getHashID(); |
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.hashLookup.get(msg.getHashID()); |
|
|
|
int itemBaseID = ItemBase.getItemHashIDMap().get(hashID); |
|
|
|
|
|
|
|
ItemBase ib = ItemBase.getItemBase(itemBaseID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ib == null) { |
|
|
|
if (isResourceLocked(warehouse, resourceType)) { |
|
|
|
Logger.debug("Failed to find Resource ItemBaseID with Hash ID = " + hashID); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ItemTemplate template = ItemTemplate.itemTemplates.get(itemBaseID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isResourceLocked(warehouse, ib)) { |
|
|
|
|
|
|
|
ChatManager.chatSystemInfo(player, "You cannot withdrawl a locked resource."); |
|
|
|
ChatManager.chatSystemInfo(player, "You cannot withdrawl a locked resource."); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!withdraw(warehouse, player, ib, withdrawAmount, true, true)) { |
|
|
|
if (!withdraw(warehouse, player, resourceType, withdrawAmount, true, true)) { |
|
|
|
ChatManager.chatGuildError(player, "Failed to withdrawl " + template.item_base_name + '.'); |
|
|
|
ChatManager.chatGuildError(player, "Failed to withdrawl " + resourceType.name() + '.'); |
|
|
|
Logger.debug(player.getName() + " Failed to withdrawl =" + template.item_base_name + " from Warehouse With ID = " + warehouseBuilding.getObjectUUID()); |
|
|
|
Logger.debug(player.getName() + " Failed to withdrawl =" + resourceType.name() + " from Warehouse With ID = " + warehouseBuilding.getObjectUUID()); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -183,7 +174,7 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.hashLookup.get(hashID); |
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.hashLookup.get(hashID); |
|
|
|
|
|
|
|
|
|
|
|
if (isResourceLocked(wh, ItemBase.getItemBase(resourceType.templateID))) { |
|
|
|
if (isResourceLocked(wh, resourceType)) { |
|
|
|
boolean worked; |
|
|
|
boolean worked; |
|
|
|
EnumBitSet<Enum.ResourceType> bitSet = EnumBitSet.asEnumBitSet(wh.lockedResourceTypes.toLong(), Enum.ResourceType.class); |
|
|
|
EnumBitSet<Enum.ResourceType> bitSet = EnumBitSet.asEnumBitSet(wh.lockedResourceTypes.toLong(), Enum.ResourceType.class); |
|
|
|
|
|
|
|
|
|
|
@ -223,6 +214,7 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
public static synchronized boolean deposit(PlayerCharacter pc, Item resource, int amount, boolean removeFromInventory, boolean transaction, Warehouse warehouse) { |
|
|
|
public static synchronized boolean deposit(PlayerCharacter pc, Item resource, int amount, boolean removeFromInventory, boolean transaction, Warehouse warehouse) { |
|
|
|
|
|
|
|
|
|
|
|
ClientConnection origin = pc.getClientConnection(); |
|
|
|
ClientConnection origin = pc.getClientConnection(); |
|
|
|
|
|
|
|
|
|
|
|
if (origin == null) |
|
|
|
if (origin == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
@ -231,12 +223,9 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ItemBase ib = resource.getItemBase(); |
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(resource.templsteID); |
|
|
|
|
|
|
|
|
|
|
|
if (ib == null) |
|
|
|
if (warehouse.resources.get(resourceType) == null) |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (warehouse.resources.get(ib) == null) |
|
|
|
|
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
CharacterItemManager itemMan = pc.getCharItemManager(); |
|
|
|
CharacterItemManager itemMan = pc.getCharItemManager(); |
|
|
@ -244,7 +233,6 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
if (itemMan == null) |
|
|
|
if (itemMan == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (itemMan.getGoldTrading() > 0) { |
|
|
|
if (itemMan.getGoldTrading() > 0) { |
|
|
|
ErrorPopupMsg.sendErrorPopup(pc, 195); |
|
|
|
ErrorPopupMsg.sendErrorPopup(pc, 195); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -259,7 +247,7 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
if (resource.getNumOfItems() < amount) |
|
|
|
if (resource.getNumOfItems() < amount) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
int oldAmount = warehouse.resources.get(ib); |
|
|
|
int oldAmount = warehouse.resources.get(resourceType); |
|
|
|
|
|
|
|
|
|
|
|
int newAmount = oldAmount + amount; |
|
|
|
int newAmount = oldAmount + amount; |
|
|
|
|
|
|
|
|
|
|
@ -270,7 +258,7 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (removeFromInventory) { |
|
|
|
if (removeFromInventory) { |
|
|
|
if (ib.getUUID() == 7) { |
|
|
|
if (resourceType.equals(Enum.ResourceType.GOLD)) { |
|
|
|
|
|
|
|
|
|
|
|
if (itemMan.getGoldInventory().getNumOfItems() - amount < 0) |
|
|
|
if (itemMan.getGoldInventory().getNumOfItems() - amount < 0) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -297,12 +285,10 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
} |
|
|
|
} |
|
|
|
itemMan.updateInventory(); |
|
|
|
itemMan.updateInventory(); |
|
|
|
|
|
|
|
|
|
|
|
if (!DepositApproved(ib,amount,warehouse)) |
|
|
|
if (!DepositApproved(resourceType, amount, warehouse)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
warehouse.resources.put(ib, newAmount); |
|
|
|
warehouse.resources.put(resourceType, newAmount); |
|
|
|
|
|
|
|
|
|
|
|
Enum.ResourceType resourceType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resource.template.item_type.equals(Enum.ItemType.GOLD)) |
|
|
|
if (resource.template.item_type.equals(Enum.ItemType.GOLD)) |
|
|
|
resourceType = Enum.ResourceType.GOLD; |
|
|
|
resourceType = Enum.ResourceType.GOLD; |
|
|
@ -315,26 +301,18 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static synchronized boolean depositFromMine(Mine mine, ItemBase resource, int amount, Warehouse warehouse) { |
|
|
|
public static synchronized boolean depositFromMine(Mine mine, Enum.ResourceType resourceType, int amount, Warehouse warehouse) { |
|
|
|
|
|
|
|
|
|
|
|
int oldAmount = warehouse.resources.get(resource); |
|
|
|
int oldAmount = warehouse.resources.get(resourceType); |
|
|
|
int newAmount = oldAmount + amount; |
|
|
|
int newAmount = oldAmount + amount; |
|
|
|
|
|
|
|
|
|
|
|
if (newAmount > Enum.ResourceType.resourceLookup.get(resource.getUUID()).deposit_limit) |
|
|
|
if (newAmount > resourceType.deposit_limit) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (!DepositApproved(resource, amount, warehouse)) |
|
|
|
if (!DepositApproved(resourceType, amount, warehouse)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
warehouse.resources.put(resource, newAmount); |
|
|
|
warehouse.resources.put(resourceType, newAmount); |
|
|
|
Enum.ResourceType resourceType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ItemTemplate template = ItemTemplate.itemTemplates.get(resource.getUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resource.getUUID() == 7) |
|
|
|
|
|
|
|
resourceType = Enum.ResourceType.GOLD; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
resourceType = Enum.ResourceType.valueOf(template.item_base_name.toUpperCase()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mine != null) |
|
|
|
if (mine != null) |
|
|
|
AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, mine.getBuildingID(), Enum.TransactionType.MINE, resourceType, amount); |
|
|
|
AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, mine.getBuildingID(), Enum.TransactionType.MINE, resourceType, amount); |
|
|
@ -342,262 +320,229 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean DepositApproved(ItemBase ib, int amount, Warehouse warehouse){ |
|
|
|
public static boolean DepositApproved(Enum.ResourceType resourceType, int amount, Warehouse warehouse) { |
|
|
|
if (ib == null) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (warehouse.resources.get(ib) == null) |
|
|
|
|
|
|
|
|
|
|
|
if (warehouse.resources.get(resourceType) == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
int oldAmount = warehouse.resources.get(ib); |
|
|
|
int oldAmount = warehouse.resources.get(resourceType); |
|
|
|
int newAmount = oldAmount + amount; |
|
|
|
int newAmount = oldAmount + amount; |
|
|
|
|
|
|
|
|
|
|
|
if (newAmount > Enum.ResourceType.resourceLookup.get(ib.getUUID()).deposit_limit) |
|
|
|
if (newAmount > resourceType.deposit_limit) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
int itemID = ib.getUUID(); |
|
|
|
|
|
|
|
boolean worked = false; |
|
|
|
boolean worked = false; |
|
|
|
|
|
|
|
|
|
|
|
switch (itemID) { |
|
|
|
switch (resourceType) { |
|
|
|
case 7: |
|
|
|
case GOLD: |
|
|
|
worked = DbManager.WarehouseQueries.updateGold(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateGold(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580000: |
|
|
|
case STONE: |
|
|
|
worked = DbManager.WarehouseQueries.updateStone(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateStone(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580001: |
|
|
|
case TRUESTEEL: |
|
|
|
worked = DbManager.WarehouseQueries.updateTruesteel(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateTruesteel(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580002: |
|
|
|
case IRON: |
|
|
|
worked = DbManager.WarehouseQueries.updateIron(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateIron(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580003: |
|
|
|
case ADAMANT: |
|
|
|
worked = DbManager.WarehouseQueries.updateAdamant(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateAdamant(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580004: |
|
|
|
case LUMBER: |
|
|
|
worked = DbManager.WarehouseQueries.updateLumber(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateLumber(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580005: |
|
|
|
case OAK: |
|
|
|
worked = DbManager.WarehouseQueries.updateOak(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateOak(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580006: |
|
|
|
case BRONZEWOOD: |
|
|
|
worked = DbManager.WarehouseQueries.updateBronzewood(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateBronzewood(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580007: |
|
|
|
case MANDRAKE: |
|
|
|
worked = DbManager.WarehouseQueries.updateMandrake(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateMandrake(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580008: |
|
|
|
case COAL: |
|
|
|
worked = DbManager.WarehouseQueries.updateCoal(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateCoal(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580009: |
|
|
|
case AGATE: |
|
|
|
worked = DbManager.WarehouseQueries.updateAgate(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateAgate(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580010: |
|
|
|
case DIAMOND: |
|
|
|
worked = DbManager.WarehouseQueries.updateDiamond(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateDiamond(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580011: |
|
|
|
case ONYX: |
|
|
|
worked = DbManager.WarehouseQueries.updateOnyx(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateOnyx(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580012: |
|
|
|
case AZOTH: |
|
|
|
worked = DbManager.WarehouseQueries.updateAzoth(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateAzoth(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580013: |
|
|
|
case ORICHALK: |
|
|
|
worked = DbManager.WarehouseQueries.updateOrichalk(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateOrichalk(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580014: |
|
|
|
case ANTIMONY: |
|
|
|
worked = DbManager.WarehouseQueries.updateAntimony(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateAntimony(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580015: |
|
|
|
case SULFUR: |
|
|
|
worked = DbManager.WarehouseQueries.updateSulfur(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateSulfur(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580016: |
|
|
|
case QUICKSILVER: |
|
|
|
worked = DbManager.WarehouseQueries.updateQuicksilver(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateQuicksilver(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580017: |
|
|
|
case GALVOR: |
|
|
|
worked = DbManager.WarehouseQueries.updateGalvor(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateGalvor(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580018: |
|
|
|
case WORMWOOD: |
|
|
|
worked = DbManager.WarehouseQueries.updateWormwood(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateWormwood(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580019: |
|
|
|
case OBSIDIAN: |
|
|
|
worked = DbManager.WarehouseQueries.updateObsidian(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateObsidian(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580020: |
|
|
|
case BLOODSTONE: |
|
|
|
worked = DbManager.WarehouseQueries.updateBloodstone(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateBloodstone(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1580021: |
|
|
|
case MITHRIL: |
|
|
|
worked = DbManager.WarehouseQueries.updateMithril(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateMithril(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
return worked; |
|
|
|
return worked; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static synchronized void depositRealmTaxes(PlayerCharacter taxer, ItemBase ib, int amount, Warehouse warehouse) { |
|
|
|
public static synchronized void depositRealmTaxes(PlayerCharacter taxer, Enum.ResourceType resourceType, int amount, Warehouse warehouse) { |
|
|
|
|
|
|
|
|
|
|
|
if (!DepositApproved(ib, amount, warehouse)) |
|
|
|
if (!DepositApproved(resourceType, amount, warehouse)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
int oldAmount = warehouse.resources.get(ib); |
|
|
|
int oldAmount = warehouse.resources.get(resourceType); |
|
|
|
int newAmount = oldAmount + amount; |
|
|
|
int newAmount = oldAmount + amount; |
|
|
|
warehouse.resources.put(ib, newAmount); |
|
|
|
warehouse.resources.put(resourceType, newAmount); |
|
|
|
Enum.ResourceType resourceType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ItemTemplate template = ItemTemplate.itemTemplates.get(ib.getUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ib.getUUID() == 7) |
|
|
|
|
|
|
|
resourceType = Enum.ResourceType.GOLD; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
resourceType = Enum.ResourceType.valueOf(template.item_base_name.toUpperCase()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), Enum.TransactionType.TAXRESOURCEDEPOSIT, resourceType, amount); |
|
|
|
AddTransactionToWarehouse(warehouse, taxer.getObjectType(), taxer.getObjectUUID(), Enum.TransactionType.TAXRESOURCEDEPOSIT, resourceType, amount); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static synchronized void depositProfitTax(ItemBase ib, int amount, Building building, Warehouse warehouse) { |
|
|
|
public static synchronized void depositProfitTax(Enum.ResourceType resourceType, int amount, Building building, Warehouse warehouse) { |
|
|
|
|
|
|
|
|
|
|
|
if (ib == null) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ItemTemplate template = ItemTemplate.itemTemplates.get(ib.getUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (warehouse.resources.get(ib) == null) |
|
|
|
if (warehouse.resources.get(resourceType) == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
int oldAmount = warehouse.resources.get(ib); |
|
|
|
int oldAmount = warehouse.resources.get(resourceType); |
|
|
|
int newAmount = oldAmount + amount; |
|
|
|
int newAmount = oldAmount + amount; |
|
|
|
|
|
|
|
|
|
|
|
if (newAmount > Enum.ResourceType.resourceLookup.get(ib.getUUID()).deposit_limit) |
|
|
|
if (newAmount > resourceType.deposit_limit) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
if (!DepositApproved(ib,amount,warehouse)) |
|
|
|
if (!DepositApproved(resourceType, amount, warehouse)) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
warehouse.resources.put(ib, newAmount); |
|
|
|
warehouse.resources.put(resourceType, newAmount); |
|
|
|
Enum.ResourceType resourceType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ib.getUUID() == 7) |
|
|
|
|
|
|
|
resourceType = Enum.ResourceType.GOLD; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
resourceType = Enum.ResourceType.valueOf(template.item_base_name.toUpperCase()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (building != null) |
|
|
|
if (building != null) |
|
|
|
AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount); |
|
|
|
AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, building.getObjectUUID(), Enum.TransactionType.DEPOSIT, resourceType, amount); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean WithdrawApproved(ItemBase ib, int amount, Warehouse warehouse){ |
|
|
|
public static boolean WithdrawApproved(Enum.ResourceType resourceType, int amount, Warehouse warehouse) { |
|
|
|
|
|
|
|
|
|
|
|
if (ib == null) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (warehouse.resources.get(ib) == null) |
|
|
|
if (warehouse.resources.get(resourceType) == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (amount <= 0) |
|
|
|
if (amount <= 0) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
int oldAmount = warehouse.resources.get(ib); |
|
|
|
int oldAmount = warehouse.resources.get(resourceType); |
|
|
|
|
|
|
|
|
|
|
|
if (oldAmount < amount) |
|
|
|
if (oldAmount < amount) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(ib.getUUID()); |
|
|
|
|
|
|
|
int hashID = resourceType.hash; |
|
|
|
|
|
|
|
int newAmount = oldAmount - amount; |
|
|
|
int newAmount = oldAmount - amount; |
|
|
|
boolean worked = false; |
|
|
|
boolean worked = false; |
|
|
|
|
|
|
|
|
|
|
|
switch (hashID) { |
|
|
|
switch (resourceType) { |
|
|
|
case 2308551: |
|
|
|
case GOLD: |
|
|
|
worked = DbManager.WarehouseQueries.updateGold(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateGold(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 74856115: |
|
|
|
case STONE: |
|
|
|
worked = DbManager.WarehouseQueries.updateStone(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateStone(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case -317484979: |
|
|
|
case TRUESTEEL: |
|
|
|
worked = DbManager.WarehouseQueries.updateTruesteel(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateTruesteel(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 2504297: |
|
|
|
case IRON: |
|
|
|
worked = DbManager.WarehouseQueries.updateIron(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateIron(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case -1741189964: |
|
|
|
case ADAMANT: |
|
|
|
worked = DbManager.WarehouseQueries.updateAdamant(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateAdamant(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case -1603256692: |
|
|
|
case LUMBER: |
|
|
|
worked = DbManager.WarehouseQueries.updateLumber(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateLumber(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 74767: |
|
|
|
case OAK: |
|
|
|
worked = DbManager.WarehouseQueries.updateOak(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateOak(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1334770447: |
|
|
|
case BRONZEWOOD: |
|
|
|
worked = DbManager.WarehouseQueries.updateBronzewood(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateBronzewood(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1191391799: |
|
|
|
case MANDRAKE: |
|
|
|
worked = DbManager.WarehouseQueries.updateMandrake(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateMandrake(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 2559427: |
|
|
|
case COAL: |
|
|
|
worked = DbManager.WarehouseQueries.updateCoal(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateCoal(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 75173057: |
|
|
|
case AGATE: |
|
|
|
worked = DbManager.WarehouseQueries.updateAgate(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateAgate(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case -1730704107: |
|
|
|
case DIAMOND: |
|
|
|
worked = DbManager.WarehouseQueries.updateDiamond(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateDiamond(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 2977263: |
|
|
|
case ONYX: |
|
|
|
worked = DbManager.WarehouseQueries.updateOnyx(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateOnyx(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 78329697: |
|
|
|
case AZOTH: |
|
|
|
worked = DbManager.WarehouseQueries.updateAzoth(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateAzoth(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case -2036290524: |
|
|
|
case ORICHALK: |
|
|
|
worked = DbManager.WarehouseQueries.updateOrichalk(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateOrichalk(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 452320058: |
|
|
|
case ANTIMONY: |
|
|
|
worked = DbManager.WarehouseQueries.updateAntimony(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateAntimony(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case -1586349421: |
|
|
|
case SULFUR: |
|
|
|
worked = DbManager.WarehouseQueries.updateSulfur(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateSulfur(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case -472884509: |
|
|
|
case QUICKSILVER: |
|
|
|
worked = DbManager.WarehouseQueries.updateQuicksilver(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateQuicksilver(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case -1596311545: |
|
|
|
case GALVOR: |
|
|
|
worked = DbManager.WarehouseQueries.updateGalvor(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateGalvor(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 1532478436: |
|
|
|
case WORMWOOD: |
|
|
|
worked = DbManager.WarehouseQueries.updateWormwood(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateWormwood(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case -697973233: |
|
|
|
case OBSIDIAN: |
|
|
|
worked = DbManager.WarehouseQueries.updateObsidian(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateObsidian(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case -1569826353: |
|
|
|
case BLOODSTONE: |
|
|
|
worked = DbManager.WarehouseQueries.updateBloodstone(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateBloodstone(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case -1761257186: |
|
|
|
case MITHRIL: |
|
|
|
worked = DbManager.WarehouseQueries.updateMithril(warehouse, newAmount); |
|
|
|
worked = DbManager.WarehouseQueries.updateMithril(warehouse, newAmount); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
return worked; |
|
|
|
return worked; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static synchronized boolean withdraw(Warehouse warehouse, NPC npc, ItemBase ib, int amount, boolean transaction) { |
|
|
|
public static synchronized boolean withdraw(Warehouse warehouse, NPC npc, Enum.ResourceType resourceType, int amount, boolean transaction) { |
|
|
|
|
|
|
|
|
|
|
|
int oldAmount = warehouse.resources.get(ib); |
|
|
|
int oldAmount = warehouse.resources.get(resourceType); |
|
|
|
|
|
|
|
|
|
|
|
int newAmount = oldAmount - amount; |
|
|
|
int newAmount = oldAmount - amount; |
|
|
|
|
|
|
|
|
|
|
|
if (!WithdrawApproved(ib, amount, warehouse)) |
|
|
|
if (!WithdrawApproved(resourceType, amount, warehouse)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
ItemTemplate template = ItemTemplate.itemTemplates.get(ib.getUUID()); |
|
|
|
warehouse.resources.put(resourceType, newAmount); |
|
|
|
|
|
|
|
|
|
|
|
warehouse.resources.put(ib, newAmount); |
|
|
|
|
|
|
|
Enum.ResourceType resourceType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ib.getUUID() == 7) |
|
|
|
|
|
|
|
resourceType = Enum.ResourceType.GOLD; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
resourceType = Enum.ResourceType.valueOf(template.item_base_name.toUpperCase()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (transaction) |
|
|
|
if (transaction) |
|
|
|
AddTransactionToWarehouse(warehouse, npc.getObjectType(), npc.getObjectUUID(), Enum.TransactionType.WITHDRAWL, resourceType, amount); |
|
|
|
AddTransactionToWarehouse(warehouse, npc.getObjectType(), npc.getObjectUUID(), Enum.TransactionType.WITHDRAWL, resourceType, amount); |
|
|
@ -607,27 +552,22 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
public static synchronized void transferResources(Warehouse warehouse, PlayerCharacter taxer, TaxResourcesMsg msg, ArrayList<Integer> realmResources, float taxPercent) { |
|
|
|
public static synchronized void transferResources(Warehouse warehouse, PlayerCharacter taxer, TaxResourcesMsg msg, ArrayList<Integer> realmResources, float taxPercent) { |
|
|
|
|
|
|
|
|
|
|
|
for (int ibID : realmResources) { |
|
|
|
for (int templateID : realmResources) { |
|
|
|
|
|
|
|
|
|
|
|
ItemBase ib = ItemBase.getItemBase(ibID); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ib == null) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ItemTemplate template = ItemTemplate.itemTemplates.get(ib.getUUID()); |
|
|
|
ItemTemplate template = ItemTemplate.itemTemplates.get(templateID); |
|
|
|
|
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(templateID); |
|
|
|
|
|
|
|
|
|
|
|
if (warehouse.resources.get(ib) == null) |
|
|
|
if (warehouse.resources.get(resourceType) == null) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
int amount = (int) (warehouse.resources.get(ib) * taxPercent); |
|
|
|
int amount = (int) (warehouse.resources.get(resourceType) * taxPercent); |
|
|
|
|
|
|
|
|
|
|
|
if (amount <= 0) { |
|
|
|
if (amount <= 0) { |
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(ib.getUUID()); |
|
|
|
|
|
|
|
msg.getResources().put(resourceType.hash, 0); |
|
|
|
msg.getResources().put(resourceType.hash, 0); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int oldAmount = warehouse.resources.get(ib); |
|
|
|
int oldAmount = warehouse.resources.get(resourceType); |
|
|
|
|
|
|
|
|
|
|
|
if (oldAmount < amount) |
|
|
|
if (oldAmount < amount) |
|
|
|
amount = oldAmount; |
|
|
|
amount = oldAmount; |
|
|
@ -637,17 +577,15 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
if (newAmount < amount) |
|
|
|
if (newAmount < amount) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
Enum.ResourceType resourceType = Enum.ResourceType.resourceLookup.get(ib.getUUID()); |
|
|
|
if (!WithdrawApproved(resourceType, amount, warehouse)) { |
|
|
|
|
|
|
|
|
|
|
|
if (!WithdrawApproved(ib, amount, warehouse)) { |
|
|
|
|
|
|
|
msg.getResources().put(resourceType.hash, 0); |
|
|
|
msg.getResources().put(resourceType.hash, 0); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
msg.getResources().put(resourceType.hash, amount); |
|
|
|
msg.getResources().put(resourceType.hash, amount); |
|
|
|
|
|
|
|
|
|
|
|
warehouse.resources.put(ib, newAmount); |
|
|
|
warehouse.resources.put(resourceType, newAmount); |
|
|
|
depositRealmTaxes(taxer, ib, amount, warehouse); |
|
|
|
depositRealmTaxes(taxer, resourceType, amount, warehouse); |
|
|
|
Enum.ResourceType resource; |
|
|
|
Enum.ResourceType resource; |
|
|
|
|
|
|
|
|
|
|
|
if (resourceType.equals(Enum.ResourceType.GOLD)) |
|
|
|
if (resourceType.equals(Enum.ResourceType.GOLD)) |
|
|
@ -660,17 +598,14 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static synchronized boolean withdraw(Warehouse warehouse, PlayerCharacter pc, ItemBase ib, int amount, boolean addToInventory, boolean transaction) { |
|
|
|
public static synchronized boolean withdraw(Warehouse warehouse, PlayerCharacter pc, Enum.ResourceType resourceType, int amount, boolean addToInventory, boolean transaction) { |
|
|
|
|
|
|
|
|
|
|
|
if (pc == null) |
|
|
|
if (pc == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (ib == null) |
|
|
|
ItemTemplate template = ItemTemplate.itemTemplates.get(resourceType.templateID); |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ItemTemplate template = ItemTemplate.itemTemplates.get(ib.getUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (warehouse.resources.get(ib) == null) |
|
|
|
if (warehouse.resources.get(resourceType) == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (amount <= 0) |
|
|
|
if (amount <= 0) |
|
|
@ -687,15 +622,14 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (addToInventory && ib.getUUID() == ItemBase.GOLD_BASE_ID) { |
|
|
|
if (addToInventory && resourceType.equals(Enum.ResourceType.GOLD)) { |
|
|
|
if (pc.getCharItemManager().getGoldInventory().getNumOfItems() + amount > MBServerStatics.PLAYER_GOLD_LIMIT) { |
|
|
|
if (pc.getCharItemManager().getGoldInventory().getNumOfItems() + amount > MBServerStatics.PLAYER_GOLD_LIMIT) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (pc.getCharItemManager().getGoldInventory().getNumOfItems() + amount < 0) |
|
|
|
if (pc.getCharItemManager().getGoldInventory().getNumOfItems() + amount < 0) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
int oldAmount = warehouse.resources.get(ib); |
|
|
|
int oldAmount = warehouse.resources.get(resourceType); |
|
|
|
|
|
|
|
|
|
|
|
if (oldAmount < amount) |
|
|
|
if (oldAmount < amount) |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -703,13 +637,13 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
int newAmount = oldAmount - amount; |
|
|
|
int newAmount = oldAmount - amount; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!WithdrawApproved(ib,amount,warehouse)) |
|
|
|
if (!WithdrawApproved(resourceType, amount, warehouse)) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
warehouse.resources.put(ib, newAmount); |
|
|
|
warehouse.resources.put(resourceType, newAmount); |
|
|
|
|
|
|
|
|
|
|
|
if (addToInventory) { |
|
|
|
if (addToInventory) { |
|
|
|
if (ib.getUUID() == 7) { |
|
|
|
if (resourceType.equals(Enum.ResourceType.GOLD)) { |
|
|
|
|
|
|
|
|
|
|
|
itemMan.addGoldToInventory(amount, false); |
|
|
|
itemMan.addGoldToInventory(amount, false); |
|
|
|
UpdateGoldMsg ugm = new UpdateGoldMsg(pc); |
|
|
|
UpdateGoldMsg ugm = new UpdateGoldMsg(pc); |
|
|
@ -721,7 +655,7 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
boolean itemWorked = false; |
|
|
|
boolean itemWorked = false; |
|
|
|
|
|
|
|
|
|
|
|
Item item = new Item(ib.getUUID()); |
|
|
|
Item item = new Item(resourceType.templateID); |
|
|
|
item.ownerID = pc.getObjectUUID(); |
|
|
|
item.ownerID = pc.getObjectUUID(); |
|
|
|
item.ownerType = Enum.OwnerType.PlayerCharacter; |
|
|
|
item.ownerType = Enum.OwnerType.PlayerCharacter; |
|
|
|
item.containerType = Enum.ItemContainerType.INVENTORY; |
|
|
|
item.containerType = Enum.ItemContainerType.INVENTORY; |
|
|
@ -739,12 +673,6 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Enum.ResourceType resourceType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ib.getUUID() == 7) |
|
|
|
|
|
|
|
resourceType = Enum.ResourceType.GOLD; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
resourceType = Enum.ResourceType.valueOf(template.item_base_name.toUpperCase()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (transaction) |
|
|
|
if (transaction) |
|
|
|
AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.WITHDRAWL, resourceType, amount); |
|
|
|
AddTransactionToWarehouse(warehouse, pc.getObjectType(), pc.getObjectUUID(), Enum.TransactionType.WITHDRAWL, resourceType, amount); |
|
|
@ -752,17 +680,17 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static synchronized boolean loot(Warehouse warehouse, PlayerCharacter pc, ItemBase ib, int amount, boolean addToInventory) { |
|
|
|
public static synchronized boolean loot(Warehouse warehouse, PlayerCharacter pc, Enum.ResourceType resourceType, int amount, boolean addToInventory) { |
|
|
|
|
|
|
|
|
|
|
|
if (pc == null) |
|
|
|
if (pc == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
ItemTemplate template = ItemTemplate.itemTemplates.get(ib.getUUID()); |
|
|
|
ItemTemplate template = ItemTemplate.itemTemplates.get(resourceType); |
|
|
|
|
|
|
|
|
|
|
|
if (template == null) |
|
|
|
if (template == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (warehouse.resources.get(ib) == null) |
|
|
|
if (warehouse.resources.get(resourceType) == null) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
if (amount <= 0) |
|
|
|
if (amount <= 0) |
|
|
@ -778,17 +706,17 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int oldAmount = warehouse.resources.get(ib); |
|
|
|
int oldAmount = warehouse.resources.get(resourceType); |
|
|
|
|
|
|
|
|
|
|
|
if (oldAmount < amount) |
|
|
|
if (oldAmount < amount) |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
|
|
int newAmount = oldAmount - amount; |
|
|
|
int newAmount = oldAmount - amount; |
|
|
|
|
|
|
|
|
|
|
|
warehouse.resources.put(ib, newAmount); |
|
|
|
warehouse.resources.put(resourceType, newAmount); |
|
|
|
|
|
|
|
|
|
|
|
if (addToInventory) { |
|
|
|
if (addToInventory) { |
|
|
|
if (ib.getUUID() == 7) { |
|
|
|
if (resourceType.equals(Enum.ResourceType.GOLD)) { |
|
|
|
|
|
|
|
|
|
|
|
itemMan.addGoldToInventory(amount, false); |
|
|
|
itemMan.addGoldToInventory(amount, false); |
|
|
|
UpdateGoldMsg ugm = new UpdateGoldMsg(pc); |
|
|
|
UpdateGoldMsg ugm = new UpdateGoldMsg(pc); |
|
|
@ -799,7 +727,7 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
itemMan.updateInventory(); |
|
|
|
itemMan.updateInventory(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
boolean itemWorked = false; |
|
|
|
boolean itemWorked = false; |
|
|
|
Item item = new Item(ib.getUUID()); |
|
|
|
Item item = new Item(resourceType.templateID); |
|
|
|
item.ownerID = pc.getObjectUUID(); |
|
|
|
item.ownerID = pc.getObjectUUID(); |
|
|
|
item.ownerType = Enum.OwnerType.PlayerCharacter; |
|
|
|
item.ownerType = Enum.OwnerType.PlayerCharacter; |
|
|
|
item.containerType = Enum.ItemContainerType.INVENTORY; |
|
|
|
item.containerType = Enum.ItemContainerType.INVENTORY; |
|
|
@ -851,12 +779,7 @@ public class Warehouse extends AbstractWorldObject { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static boolean isResourceLocked(Warehouse warehouse, ItemBase itemBase) { |
|
|
|
public static boolean isResourceLocked(Warehouse warehouse, Enum.ResourceType resourceType) { |
|
|
|
|
|
|
|
|
|
|
|
Enum.ResourceType resourceType; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resourceType = Enum.ResourceType.resourceLookup.get(itemBase.getUUID()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return resourceType.elementOf(warehouse.lockedResourceTypes); |
|
|
|
return resourceType.elementOf(warehouse.lockedResourceTypes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|