Browse Source

Parsing classes

combat-2
MagicBot 9 months ago
parent
commit
61f28a588b
  1. 17
      src/engine/objects/ItemTemplate.java

17
src/engine/objects/ItemTemplate.java

@ -54,6 +54,8 @@ public class ItemTemplate {
public EnumSet<Enum.MonsterType> item_race_req = EnumSet.noneOf(Enum.MonsterType.class); public EnumSet<Enum.MonsterType> item_race_req = EnumSet.noneOf(Enum.MonsterType.class);
public EnumSet<Enum.MonsterType> item_race_res = EnumSet.noneOf(Enum.MonsterType.class); public EnumSet<Enum.MonsterType> item_race_res = EnumSet.noneOf(Enum.MonsterType.class);
public EnumSet<Enum.ClassType> item_class_req = EnumSet.noneOf(Enum.ClassType.class);
public EnumSet<Enum.ClassType> item_class_res = EnumSet.noneOf(Enum.ClassType.class);
public ItemTemplate(JSONObject jsonObject) { public ItemTemplate(JSONObject jsonObject) {
@ -186,6 +188,21 @@ public class ItemTemplate {
item_race_req.add(Enum.MonsterType.valueOf(race)); item_race_req.add(Enum.MonsterType.valueOf(race));
} }
JSONObject class_required = (JSONObject) jsonObject.get("item_class_req");
restrict = ((Boolean) class_required.get("restrict"));
JSONArray classes = (JSONArray) class_required.get("classes");
for (Object o : races) {
String classEntry = (String) o;
classEntry = classEntry.replaceAll("\\s", "");
classEntry = classEntry.replaceAll(",", "");
if (restrict)
item_class_res.add(Enum.ClassType.valueOf(classEntry));
else
item_class_req.add(Enum.ClassType.valueOf(classEntry));
}
} catch (Exception e) { } catch (Exception e) {
Logger.error(e); Logger.error(e);
} }

Loading…
Cancel
Save