diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 91817e6a..339cfb5b 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -17,7 +17,6 @@ import org.pmw.tinylog.Logger; import java.util.EnumSet; import java.util.HashMap; - public class ItemTemplate { // Global template lookup @@ -52,6 +51,9 @@ public class ItemTemplate { public EnumSet item_use_flags = EnumSet.noneOf(Enum.ItemUseFlags.class); public int item_initial_charges; public HashMap item_skill_required = new HashMap<>(); + public EnumSet item_race_req = EnumSet.noneOf(Enum.RaceType.class); + public EnumSet item_race_res = EnumSet.noneOf(Enum.RaceType.class); + public ItemTemplate(JSONObject jsonObject) { @@ -168,6 +170,22 @@ public class ItemTemplate { int skill_level = ((Long) skill_req.get("skill_level")).intValue(); item_skill_required.put(Enum.CharacterSkills.valueOf(skill_type), skill_level); } + + JSONObject race_required = (JSONObject) jsonObject.get("item_race_req"); + boolean restrict = ((Boolean) race_required.get("restrict")); + JSONArray races = (JSONArray) race_required.get("races"); + + for (Object o : races) { + String race = (String) o; + race = race.replaceAll("\\s", ""); + race = race.replaceAll(",", ""); + + if (restrict) + item_race_res.add(Enum.RaceType.valueOf(race)); + else + item_race_req.add(Enum.RaceType.valueOf(race)); + } + } catch (Exception e) { Logger.error(e); }