From 946714d3ae1e1b1b0fad67db05de80bb1f8cd7ac Mon Sep 17 00:00:00 2001 From: MagicBot Date: Mon, 1 Apr 2024 15:53:36 -0400 Subject: [PATCH] Proper parsing of power grants --- src/engine/objects/ItemTemplate.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index 7e550a5e..cd13104b 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -350,15 +350,18 @@ public class ItemTemplate { item_user_power_action.put(power, arguments); } - JSONArray powerGrants = (JSONArray) jsonObject.get("item_power_grant"); - - if (powerGrants.isEmpty() == false) - for (Object o : powerGrants) { - JSONObject powerGrantEntry = (JSONObject) o; - String power_type = (String) powerGrantEntry.get("power_type"); - int power_value = ((Long) powerGrantEntry.get("power_value")).intValue(); - item_power_grant.put(power_type, power_value); + JSONObject powerGrants = (JSONObject) jsonObject.get("item_power_grant"); + + if (powerGrants.isEmpty() == false) { + + JSONObject powerGrantEntries = (JSONObject) powerGrants.get("power_granted_powers"); + + for (Object grantedPower : powerGrantEntries.keySet()) { + int powerLevel = ((Long) powerGrantEntries.get(grantedPower)).intValue(); + item_power_grant.put((String) grantedPower, powerLevel); + } + } JSONArray item_power_actions = (JSONArray) jsonObject.get("item_power_action");