Browse Source

Refactor itembase.name to template.

combat-2
MagicBot 9 months ago
parent
commit
8d91f200e7
  1. 11
      src/engine/objects/ItemBase.java
  2. 2
      src/engine/objects/ItemFactory.java
  3. 8
      src/engine/objects/Warehouse.java

11
src/engine/objects/ItemBase.java

@ -37,8 +37,8 @@ public class ItemBase { @@ -37,8 +37,8 @@ public class ItemBase {
private static final HashMap<String, Integer> _IDsByNames = new HashMap<>();
private static final ArrayList<ItemBase> _resourceList = new ArrayList<>();
private final int uuid;
private String name;
//requirements/restrictions
// private String name;
//requirements/restrictions
public EnumSet<Enum.MonsterType> restrictedRaces;
public EnumSet<Enum.MonsterType> requiredRaces;
public EnumSet<Enum.ClassType> restrictedClasses;
@ -179,7 +179,9 @@ public class ItemBase { @@ -179,7 +179,9 @@ public class ItemBase {
if (itemBase.type.equals(ItemType.RESOURCE))
_resourceList.add(itemBase);
_IDsByNames.put(itemBase.name.toLowerCase().replace(" ", "_"), itemBase.uuid);
ItemTemplate template = ItemTemplate.itemTemplates.get(itemBase.uuid);
_IDsByNames.put(template.item_base_name.toLowerCase().replace(" ", "_"), itemBase.uuid);
}
public static HashMap<Integer, Integer> getItemHashIDMap() {
@ -254,9 +256,6 @@ public class ItemBase { @@ -254,9 +256,6 @@ public class ItemBase {
/*
* Getters
*/
public String getName() {
return this.name;
}
public float getDurability() {
return this.durability;

2
src/engine/objects/ItemFactory.java

@ -491,7 +491,7 @@ public class ItemFactory { @@ -491,7 +491,7 @@ public class ItemFactory {
int creationAmount = suffixResourceCosts.get(ibResources);
if (Warehouse.isResourceLocked(cityWarehouse, ibResources) == true) {
ChatManager.chatSystemError(pc, ibResources.getName() + " is locked!" + template.item_base_name);
ChatManager.chatSystemError(pc, "Resource is locked!" + template.item_base_name);
return null;
}

8
src/engine/objects/Warehouse.java

@ -354,24 +354,24 @@ public class Warehouse extends AbstractWorldObject { @@ -354,24 +354,24 @@ public class Warehouse extends AbstractWorldObject {
public static synchronized boolean depositFromMine(Mine mine, ItemBase resource, int amount, Warehouse warehouse) {
int oldAmount = warehouse.resources.get(resource);
int newAmount = oldAmount + amount;
if (newAmount > getMaxResources().get(resource.getUUID()))
return false;
if (!DepositApproved(resource,amount,warehouse))
if (!DepositApproved(resource, amount, warehouse))
return false;
warehouse.resources.put(resource, newAmount);
Resource resourceType;
ItemTemplate template = ItemTemplate.itemTemplates.get(resource.getUUID());
if (resource.getUUID() == 7)
resourceType = Resource.GOLD;
else
resourceType = Resource.valueOf(resource.getName().toUpperCase());
resourceType = Resource.valueOf(template.item_base_name.toUpperCase());
if (mine != null)
AddTransactionToWarehouse(warehouse, Enum.GameObjectType.Building, mine.getBuildingID(), Enum.TransactionType.MINE, resourceType, amount);

Loading…
Cancel
Save