Browse Source

More parsing work

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

20
src/engine/objects/ItemTemplate.java

@ -77,9 +77,8 @@ public class ItemTemplate { @@ -77,9 +77,8 @@ public class ItemTemplate {
public int item_level_req;
public Enum.SexType item_sex_req;
public HashMap<String, int[]> item_user_power_action = new HashMap<>();
public static HashMap<String, Integer> item_power_grant = new HashMap<>();
public HashMap<String, int[]> item_power_action = new HashMap<>();
public ItemTemplate(JSONObject jsonObject) {
@ -314,10 +313,10 @@ public class ItemTemplate { @@ -314,10 +313,10 @@ public class ItemTemplate {
item_level_req = ((Long) jsonObject.get("item_level_req")).intValue();
item_sex_req = Enum.SexType.valueOf((String) jsonObject.get("item_sex_req"));
JSONArray powerActions = (JSONArray) jsonObject.get("item_user_power_action");
JSONArray userPowerActions = (JSONArray) jsonObject.get("item_user_power_action");
if (powerActions.isEmpty() == false)
for (Object o : powerActions) {
if (userPowerActions.isEmpty() == false)
for (Object o : userPowerActions) {
JSONObject powerActionEntry = (JSONObject) o;
String power = (String) powerActionEntry.get("power");
JSONArray args = (JSONArray) powerActionEntry.get("arguments");
@ -335,6 +334,17 @@ public class ItemTemplate { @@ -335,6 +334,17 @@ public class ItemTemplate {
item_power_grant.put(power_type, power_value);
}
JSONArray item_power_actions = (JSONArray) jsonObject.get("item_user_power_action");
if (item_power_actions.isEmpty() == false)
for (Object o : item_power_actions) {
JSONObject powerActionEntry = (JSONObject) o;
String power = (String) powerActionEntry.get("power_type");
JSONObject power_actions = (JSONObject) powerActionEntry.get("power_actions");
JSONArray args = (JSONArray) power_actions.get("power_arguments");
int[] power_arguments = {((Long) args.get(0)).intValue(), ((Long) args.get(1)).intValue()};
item_power_action.put(power, power_arguments);
}
} catch (Exception e) {
Logger.error(e);

Loading…
Cancel
Save