Browse Source

Fleshing out constructor

combat-2
MagicBot 9 months ago
parent
commit
8ff112b802
  1. 2
      src/engine/Enum.java
  2. 26
      src/engine/objects/ItemTemplate.java

2
src/engine/Enum.java

@ -2327,7 +2327,7 @@ public class Enum { @@ -2327,7 +2327,7 @@ public class Enum {
WAREHOUSE
}
public enum ItemSlotType implements EnumBitSetHelper<ItemSlotType> {
public enum ItemEquipSlotType {
RHELD,
LHELD,
HELM,

26
src/engine/objects/ItemTemplate.java

@ -8,11 +8,12 @@ @@ -8,11 +8,12 @@
package engine.objects;
import engine.Enum;
import engine.math.Vector3fImmutable;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.HashMap;
@ -30,7 +31,11 @@ public class ItemTemplate { @@ -30,7 +31,11 @@ public class ItemTemplate {
public float combat_health_full;
public HashMap<String, Float> combat_attack_resist = new HashMap<>();
public ArrayList combatPowers;
public Enum.ItemType item_type;
public int item_eq_slots_value;
public boolean item_eq_slots_type;
public EnumSet<Enum.ItemEquipSlotType> item_eq_slots_or;
public EnumSet<Enum.ItemEquipSlotType> item_eq_slots_and;
public ItemTemplate(JSONObject jsonObject) {
@ -63,13 +68,20 @@ public class ItemTemplate { @@ -63,13 +68,20 @@ public class ItemTemplate {
combat_attack_resist.put((String) key, resist);
}
// Reading arraylist of ints
// Parsing an enum
JSONArray combat_json = (JSONArray) jsonObject.get("combat_powers");
item_type = Enum.ItemType.valueOf((String) jsonObject.get("item_type"));
if (combat_json.isEmpty() == false)
for (Object o : combat_json)
combatPowers.add(o);
item_eq_slots_value = ((Long) jsonObject.get("item_eq_slots_value")).intValue();
item_eq_slots_type = (boolean) jsonObject.get("item_eq_slots_value");
// Parsing an enumset
JSONArray eq_slots_or = (JSONArray) jsonObject.get("item_eq_slots_or");
if (eq_slots_or.isEmpty() == false)
for (Object o : eq_slots_or)
item_eq_slots_or.add(Enum.ItemEquipSlotType.valueOf((String) o));
}
}

Loading…
Cancel
Save