From c5bb051e644b00f8ffd6ee64a830a1275f61ad57 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 27 Feb 2024 16:35:36 -0500 Subject: [PATCH] Parsing resource costs --- src/engine/objects/ItemTemplate.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index bee69e5f..b06dfe20 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -79,6 +79,7 @@ public class ItemTemplate { public HashMap item_user_power_action = new HashMap<>(); public static HashMap item_power_grant = new HashMap<>(); public HashMap item_power_action = new HashMap<>(); + public HashMap item_resource_cost = new HashMap<>(); public ItemTemplate(JSONObject jsonObject) { @@ -347,6 +348,16 @@ public class ItemTemplate { item_power_action.put(power, power_arguments); } + JSONArray resource_costs = (JSONArray) jsonObject.get("item_resource_costs"); + + if (resource_costs.isEmpty() == false) + for (Object o : resource_costs) { + JSONObject resource_entry = (JSONObject) o; + Enum.ResourceType resource_type = Enum.ResourceType.valueOf((String) resource_entry.get("resource_type")); + int resource_value = ((Long) resource_entry.get("resource_value")).intValue(); + item_resource_cost.put(resource_type, resource_value); + } + } catch (Exception e) { Logger.error(e); }