forked from MagicBane/Server
Parsing resource costs
This commit is contained in:
@@ -79,6 +79,7 @@ public class ItemTemplate {
|
|||||||
public HashMap<String, int[]> item_user_power_action = new HashMap<>();
|
public HashMap<String, int[]> item_user_power_action = new HashMap<>();
|
||||||
public static HashMap<String, Integer> item_power_grant = new HashMap<>();
|
public static HashMap<String, Integer> item_power_grant = new HashMap<>();
|
||||||
public HashMap<String, int[]> item_power_action = 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) {
|
public ItemTemplate(JSONObject jsonObject) {
|
||||||
|
|
||||||
@@ -347,6 +348,16 @@ public class ItemTemplate {
|
|||||||
item_power_action.put(power, power_arguments);
|
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) {
|
} catch (Exception e) {
|
||||||
Logger.error(e);
|
Logger.error(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user