Browse Source

Parsing resource costs

combat-2
MagicBot 9 months ago
parent
commit
c5bb051e64
  1. 11
      src/engine/objects/ItemTemplate.java

11
src/engine/objects/ItemTemplate.java

@ -79,6 +79,7 @@ public class ItemTemplate { @@ -79,6 +79,7 @@ public class ItemTemplate {
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 HashMap<Enum.ResourceType, Integer> item_resource_cost = new HashMap<>();
public ItemTemplate(JSONObject jsonObject) {
@ -347,6 +348,16 @@ public class ItemTemplate { @@ -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);
}

Loading…
Cancel
Save