Browse Source

Parsing races

combat-2
MagicBot 9 months ago
parent
commit
155bbfbf4e
  1. 20
      src/engine/objects/ItemTemplate.java

20
src/engine/objects/ItemTemplate.java

@ -17,7 +17,6 @@ import org.pmw.tinylog.Logger; @@ -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 { @@ -52,6 +51,9 @@ public class ItemTemplate {
public EnumSet<Enum.ItemUseFlags> item_use_flags = EnumSet.noneOf(Enum.ItemUseFlags.class);
public int item_initial_charges;
public HashMap<Enum.CharacterSkills, Integer> item_skill_required = new HashMap<>();
public EnumSet<Enum.RaceType> item_race_req = EnumSet.noneOf(Enum.RaceType.class);
public EnumSet<Enum.RaceType> item_race_res = EnumSet.noneOf(Enum.RaceType.class);
public ItemTemplate(JSONObject jsonObject) {
@ -168,6 +170,22 @@ public class ItemTemplate { @@ -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);
}

Loading…
Cancel
Save