Browse Source

Refactor itembase.name to template.

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

9
src/engine/objects/ItemBase.java

@ -37,7 +37,7 @@ public class ItemBase {
private static final HashMap<String, Integer> _IDsByNames = new HashMap<>(); private static final HashMap<String, Integer> _IDsByNames = new HashMap<>();
private static final ArrayList<ItemBase> _resourceList = new ArrayList<>(); private static final ArrayList<ItemBase> _resourceList = new ArrayList<>();
private final int uuid; private final int uuid;
private String name; // private String name;
//requirements/restrictions //requirements/restrictions
public EnumSet<Enum.MonsterType> restrictedRaces; public EnumSet<Enum.MonsterType> restrictedRaces;
public EnumSet<Enum.MonsterType> requiredRaces; public EnumSet<Enum.MonsterType> requiredRaces;
@ -179,7 +179,9 @@ public class ItemBase {
if (itemBase.type.equals(ItemType.RESOURCE)) if (itemBase.type.equals(ItemType.RESOURCE))
_resourceList.add(itemBase); _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() { public static HashMap<Integer, Integer> getItemHashIDMap() {
@ -254,9 +256,6 @@ public class ItemBase {
/* /*
* Getters * Getters
*/ */
public String getName() {
return this.name;
}
public float getDurability() { public float getDurability() {
return this.durability; return this.durability;

2
src/engine/objects/ItemFactory.java

@ -491,7 +491,7 @@ public class ItemFactory {
int creationAmount = suffixResourceCosts.get(ibResources); int creationAmount = suffixResourceCosts.get(ibResources);
if (Warehouse.isResourceLocked(cityWarehouse, ibResources) == true) { 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; return null;
} }

6
src/engine/objects/Warehouse.java

@ -354,8 +354,6 @@ public class Warehouse extends AbstractWorldObject {
public static synchronized boolean depositFromMine(Mine mine, ItemBase resource, int amount, Warehouse warehouse) { public static synchronized boolean depositFromMine(Mine mine, ItemBase resource, int amount, Warehouse warehouse) {
int oldAmount = warehouse.resources.get(resource); int oldAmount = warehouse.resources.get(resource);
int newAmount = oldAmount + amount; int newAmount = oldAmount + amount;
@ -368,10 +366,12 @@ public class Warehouse extends AbstractWorldObject {
warehouse.resources.put(resource, newAmount); warehouse.resources.put(resource, newAmount);
Resource resourceType; Resource resourceType;
ItemTemplate template = ItemTemplate.itemTemplates.get(resource.getUUID());
if (resource.getUUID() == 7) if (resource.getUUID() == 7)
resourceType = Resource.GOLD; resourceType = Resource.GOLD;
else else
resourceType = Resource.valueOf(resource.getName().toUpperCase()); resourceType = Resource.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);

Loading…
Cancel
Save