Browse Source

Proper parsing of power grants

combat-2
MagicBot 8 months ago
parent
commit
946714d3ae
  1. 19
      src/engine/objects/ItemTemplate.java

19
src/engine/objects/ItemTemplate.java

@ -350,14 +350,17 @@ public class ItemTemplate {
item_user_power_action.put(power, arguments); item_user_power_action.put(power, arguments);
} }
JSONArray powerGrants = (JSONArray) jsonObject.get("item_power_grant"); JSONObject powerGrants = (JSONObject) jsonObject.get("item_power_grant");
if (powerGrants.isEmpty() == false) if (powerGrants.isEmpty() == false) {
for (Object o : powerGrants) {
JSONObject powerGrantEntry = (JSONObject) o; JSONObject powerGrantEntries = (JSONObject) powerGrants.get("power_granted_powers");
String power_type = (String) powerGrantEntry.get("power_type");
int power_value = ((Long) powerGrantEntry.get("power_value")).intValue(); for (Object grantedPower : powerGrantEntries.keySet()) {
item_power_grant.put(power_type, power_value); int powerLevel = ((Long) powerGrantEntries.get(grantedPower)).intValue();
item_power_grant.put((String) grantedPower, powerLevel);
}
} }
JSONArray item_power_actions = (JSONArray) jsonObject.get("item_power_action"); JSONArray item_power_actions = (JSONArray) jsonObject.get("item_power_action");

Loading…
Cancel
Save