|
|
@ -12,6 +12,7 @@ import engine.Enum; |
|
|
|
import engine.math.Vector3fImmutable; |
|
|
|
import engine.math.Vector3fImmutable; |
|
|
|
import org.json.simple.JSONArray; |
|
|
|
import org.json.simple.JSONArray; |
|
|
|
import org.json.simple.JSONObject; |
|
|
|
import org.json.simple.JSONObject; |
|
|
|
|
|
|
|
import org.pmw.tinylog.Logger; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.EnumSet; |
|
|
|
import java.util.EnumSet; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
@ -54,114 +55,118 @@ public class ItemTemplate { |
|
|
|
|
|
|
|
|
|
|
|
public ItemTemplate(JSONObject jsonObject) { |
|
|
|
public ItemTemplate(JSONObject jsonObject) { |
|
|
|
|
|
|
|
|
|
|
|
// Reading a String
|
|
|
|
try { |
|
|
|
|
|
|
|
// Reading a String
|
|
|
|
|
|
|
|
|
|
|
|
obj_name = (String) jsonObject.get("obj_name"); |
|
|
|
obj_name = (String) jsonObject.get("obj_name"); |
|
|
|
|
|
|
|
|
|
|
|
// Reading floats from an array
|
|
|
|
// Reading floats from an array
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray scaleData = (JSONArray) jsonObject.get("obj_scale"); |
|
|
|
JSONArray scaleData = (JSONArray) jsonObject.get("obj_scale"); |
|
|
|
obj_scale = new Vector3fImmutable(((Double) scaleData.get(0)).floatValue(), ((Double) scaleData.get(1)).floatValue(), |
|
|
|
obj_scale = new Vector3fImmutable(((Double) scaleData.get(0)).floatValue(), ((Double) scaleData.get(1)).floatValue(), |
|
|
|
((Double) scaleData.get(2)).floatValue()); |
|
|
|
((Double) scaleData.get(2)).floatValue()); |
|
|
|
|
|
|
|
|
|
|
|
// Reading an integer value
|
|
|
|
// Reading an integer value
|
|
|
|
|
|
|
|
|
|
|
|
obj_render_object = ((Long) jsonObject.get("obj_render_object")).intValue(); |
|
|
|
obj_render_object = ((Long) jsonObject.get("obj_render_object")).intValue(); |
|
|
|
obj_icon = ((Long) jsonObject.get("obj_icon")).intValue(); |
|
|
|
obj_icon = ((Long) jsonObject.get("obj_icon")).intValue(); |
|
|
|
|
|
|
|
|
|
|
|
// Reading float values
|
|
|
|
// Reading float values
|
|
|
|
|
|
|
|
|
|
|
|
combat_health_current = ((Double) jsonObject.get("combat_health_current")).floatValue(); |
|
|
|
combat_health_current = ((Double) jsonObject.get("combat_health_current")).floatValue(); |
|
|
|
combat_health_full = ((Double) jsonObject.get("combat_health_full")).floatValue(); |
|
|
|
combat_health_full = ((Double) jsonObject.get("combat_health_full")).floatValue(); |
|
|
|
|
|
|
|
|
|
|
|
// Reading a hashmap of floats
|
|
|
|
// Reading a hashmap of floats
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject resist_json = (JSONObject) jsonObject.get("combat_attack_resist"); |
|
|
|
JSONObject resist_json = (JSONObject) jsonObject.get("combat_attack_resist"); |
|
|
|
|
|
|
|
|
|
|
|
for (Object key : resist_json.keySet()) { |
|
|
|
for (Object key : resist_json.keySet()) { |
|
|
|
float resist = ((Double) resist_json.get(key)).floatValue(); |
|
|
|
float resist = ((Double) resist_json.get(key)).floatValue(); |
|
|
|
combat_attack_resist.put((String) key, resist); |
|
|
|
combat_attack_resist.put((String) key, resist); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Parsing an enum
|
|
|
|
// Parsing an enum
|
|
|
|
|
|
|
|
|
|
|
|
item_type = Enum.ItemType.valueOf((String) jsonObject.get("item_type")); |
|
|
|
item_type = Enum.ItemType.valueOf((String) jsonObject.get("item_type")); |
|
|
|
item_eq_slots_value = ((Long) jsonObject.get("item_eq_slots_value")).intValue(); |
|
|
|
item_eq_slots_value = ((Long) jsonObject.get("item_eq_slots_value")).intValue(); |
|
|
|
item_eq_slots_type = (boolean) jsonObject.get("item_eq_slots_type"); |
|
|
|
item_eq_slots_type = (boolean) jsonObject.get("item_eq_slots_type"); |
|
|
|
|
|
|
|
|
|
|
|
// Parsing an enumset
|
|
|
|
// Parsing an enumset
|
|
|
|
|
|
|
|
|
|
|
|
JSONArray eq_slots_or = (JSONArray) jsonObject.get("item_eq_slots_or"); |
|
|
|
JSONArray eq_slots_or = (JSONArray) jsonObject.get("item_eq_slots_or"); |
|
|
|
|
|
|
|
|
|
|
|
if (eq_slots_or.isEmpty() == false) |
|
|
|
if (eq_slots_or.isEmpty() == false) |
|
|
|
for (Object o : eq_slots_or) |
|
|
|
for (Object o : eq_slots_or) |
|
|
|
item_eq_slots_or.add(Enum.ItemEquipSlotType.valueOf((String) o)); |
|
|
|
item_eq_slots_or.add(Enum.ItemEquipSlotType.valueOf((String) o)); |
|
|
|
|
|
|
|
|
|
|
|
JSONArray eq_slots_and = (JSONArray) jsonObject.get("item_eq_slots_and"); |
|
|
|
JSONArray eq_slots_and = (JSONArray) jsonObject.get("item_eq_slots_and"); |
|
|
|
|
|
|
|
|
|
|
|
if (eq_slots_and.isEmpty() == false) |
|
|
|
if (eq_slots_and.isEmpty() == false) |
|
|
|
for (Object o : eq_slots_or) |
|
|
|
for (Object o : eq_slots_or) |
|
|
|
item_eq_slots_and.add(Enum.ItemEquipSlotType.valueOf((String) o)); |
|
|
|
item_eq_slots_and.add(Enum.ItemEquipSlotType.valueOf((String) o)); |
|
|
|
|
|
|
|
|
|
|
|
item_value = ((Long) jsonObject.get("item_value")).intValue(); |
|
|
|
item_value = ((Long) jsonObject.get("item_value")).intValue(); |
|
|
|
item_wt = ((Long) jsonObject.get("item_wt")).intValue(); |
|
|
|
item_wt = ((Long) jsonObject.get("item_wt")).intValue(); |
|
|
|
item_passive_defense_mod = ((Double) jsonObject.get("item_passive_defense_mod")).floatValue(); |
|
|
|
item_passive_defense_mod = ((Double) jsonObject.get("item_passive_defense_mod")).floatValue(); |
|
|
|
item_base_name = (String) jsonObject.get("item_base_name"); |
|
|
|
item_base_name = (String) jsonObject.get("item_base_name"); |
|
|
|
item_dsc = (String) jsonObject.get("item_dsc"); |
|
|
|
item_dsc = (String) jsonObject.get("item_dsc"); |
|
|
|
item_render_object_female = ((Long) jsonObject.get("item_render_object_female")).intValue(); |
|
|
|
item_render_object_female = ((Long) jsonObject.get("item_render_object_female")).intValue(); |
|
|
|
item_health_full = ((Double) jsonObject.get("item_health_full")).floatValue(); |
|
|
|
item_health_full = ((Double) jsonObject.get("item_health_full")).floatValue(); |
|
|
|
|
|
|
|
|
|
|
|
Object skills_used = jsonObject.get("item_skill_used"); |
|
|
|
Object skills_used = jsonObject.get("item_skill_used"); |
|
|
|
|
|
|
|
|
|
|
|
if (skills_used instanceof String) { |
|
|
|
if (skills_used instanceof String) { |
|
|
|
String skilString = (String) skills_used; |
|
|
|
String skilString = (String) skills_used; |
|
|
|
skilString = skilString.replaceAll("\\s", ""); |
|
|
|
skilString = skilString.replaceAll("\\s", ""); |
|
|
|
skilString = skilString.replaceAll(",", ""); |
|
|
|
skilString = skilString.replaceAll(",", ""); |
|
|
|
item_skill_used.add(Enum.CharacterSkills.valueOf(skilString)); |
|
|
|
item_skill_used.add(Enum.CharacterSkills.valueOf(skilString)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Object mastery_used = jsonObject.get("item_skill_mastery_used"); |
|
|
|
Object mastery_used = jsonObject.get("item_skill_mastery_used"); |
|
|
|
|
|
|
|
|
|
|
|
if (mastery_used instanceof String) { |
|
|
|
if (mastery_used instanceof String) { |
|
|
|
String masteryString = (String) mastery_used; |
|
|
|
String masteryString = (String) mastery_used; |
|
|
|
masteryString = masteryString.replaceAll("\\s", ""); |
|
|
|
masteryString = masteryString.replaceAll("\\s", ""); |
|
|
|
masteryString = masteryString.replaceAll(",", ""); |
|
|
|
masteryString = masteryString.replaceAll(",", ""); |
|
|
|
item_skill_mastery_used.add(Enum.CharacterSkills.valueOf(masteryString)); |
|
|
|
item_skill_mastery_used.add(Enum.CharacterSkills.valueOf(masteryString)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
item_parry_anim_id = ((Long) jsonObject.get("item_parry_anim_id")).intValue(); |
|
|
|
item_parry_anim_id = ((Long) jsonObject.get("item_parry_anim_id")).intValue(); |
|
|
|
|
|
|
|
|
|
|
|
// Item Type == ARMOR?
|
|
|
|
// Item Type == ARMOR?
|
|
|
|
|
|
|
|
|
|
|
|
if (jsonObject.containsValue("item_bulk_factor")) |
|
|
|
if (jsonObject.containsValue("item_bulk_factor")) |
|
|
|
item_bulk_factor = ((Double) jsonObject.get("item_bulk_factor")).floatValue(); |
|
|
|
item_bulk_factor = ((Double) jsonObject.get("item_bulk_factor")).floatValue(); |
|
|
|
|
|
|
|
|
|
|
|
if (jsonObject.containsValue("item_defense_rating")) |
|
|
|
if (jsonObject.containsValue("item_defense_rating")) |
|
|
|
item_defense_rating = ((Double) jsonObject.get("item_defense_rating")).floatValue(); |
|
|
|
item_defense_rating = ((Double) jsonObject.get("item_defense_rating")).floatValue(); |
|
|
|
|
|
|
|
|
|
|
|
JSONArray itemflags = (JSONArray) jsonObject.get("item_flags"); |
|
|
|
JSONArray itemflags = (JSONArray) jsonObject.get("item_flags"); |
|
|
|
|
|
|
|
|
|
|
|
if (itemflags.isEmpty() == false) |
|
|
|
if (itemflags.isEmpty() == false) |
|
|
|
for (Object o : itemflags) |
|
|
|
for (Object o : itemflags) |
|
|
|
item_flags.add(Enum.ItemFlags.valueOf((String) o)); |
|
|
|
item_flags.add(Enum.ItemFlags.valueOf((String) o)); |
|
|
|
|
|
|
|
|
|
|
|
JSONArray itemUseflags = (JSONArray) jsonObject.get("item_use_flags"); |
|
|
|
JSONArray itemUseflags = (JSONArray) jsonObject.get("item_use_flags"); |
|
|
|
|
|
|
|
|
|
|
|
if (itemUseflags.isEmpty() == false) |
|
|
|
if (itemUseflags.isEmpty() == false) |
|
|
|
for (Object o : itemUseflags) |
|
|
|
for (Object o : itemUseflags) |
|
|
|
item_use_flags.add(Enum.ItemUseFlags.valueOf((String) o)); |
|
|
|
item_use_flags.add(Enum.ItemUseFlags.valueOf((String) o)); |
|
|
|
|
|
|
|
|
|
|
|
item_initial_charges = ((Long) jsonObject.get("item_initial_charges")).intValue(); |
|
|
|
item_initial_charges = ((Long) jsonObject.get("item_initial_charges")).intValue(); |
|
|
|
|
|
|
|
|
|
|
|
JSONArray skill_required = (JSONArray) jsonObject.get("item_skill_req"); |
|
|
|
JSONArray skill_required = (JSONArray) jsonObject.get("item_skill_req"); |
|
|
|
|
|
|
|
|
|
|
|
for (Object o : skill_required) { |
|
|
|
for (Object o : skill_required) { |
|
|
|
JSONObject skill_req = (JSONObject) o; |
|
|
|
JSONObject skill_req = (JSONObject) o; |
|
|
|
String skill_type = (String) skill_req.get("skill_type"); |
|
|
|
String skill_type = (String) skill_req.get("skill_type"); |
|
|
|
skill_type = skill_type.replaceAll("\\s", ""); |
|
|
|
skill_type = skill_type.replaceAll("\\s", ""); |
|
|
|
skill_type = skill_type.replaceAll(",", ""); |
|
|
|
skill_type = skill_type.replaceAll(",", ""); |
|
|
|
int skill_level = ((Long) skill_req.get("skill_level")).intValue(); |
|
|
|
int skill_level = ((Long) skill_req.get("skill_level")).intValue(); |
|
|
|
item_skill_required.put(Enum.CharacterSkills.valueOf(skill_type), skill_level); |
|
|
|
item_skill_required.put(Enum.CharacterSkills.valueOf(skill_type), skill_level); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
Logger.error(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|