From 5304919e2a6fc4d286002ebbff5b260a1310ef4a Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 27 Feb 2024 15:16:18 -0500 Subject: [PATCH] More parsing work --- src/engine/objects/ItemTemplate.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index f29257ef..6dba8aee 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -77,9 +77,8 @@ public class ItemTemplate { public int item_level_req; public Enum.SexType item_sex_req; public HashMap item_user_power_action = new HashMap<>(); - public static HashMap item_power_grant = new HashMap<>(); - + public HashMap item_power_action = new HashMap<>(); public ItemTemplate(JSONObject jsonObject) { @@ -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 { 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);