From b26134ec7218720ab1479d5a35b71efbf0c0c0d7 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Tue, 27 Feb 2024 12:21:18 -0500 Subject: [PATCH] Support for multiple damage type entries. --- src/engine/objects/ItemTemplate.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index e9c5c0ec..6597da19 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -10,6 +10,7 @@ package engine.objects; import engine.Enum; import engine.math.Vector3fImmutable; +import javafx.util.Pair; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.pmw.tinylog.Logger; @@ -54,9 +55,8 @@ public class ItemTemplate { public int item_weapon_projectile_id; public float item_weapon_projectile_speed; public int item_weapon_combat_idle_anim; - public Enum.SourceType item_weapon_damage_type; - public int item_weapon_damage_min; - public int item_weapon_damage_max; + + public HashMap> item_weapon_damage = new HashMap<>(); public EnumSet item_flags = EnumSet.noneOf(Enum.ItemFlags.class); public EnumSet item_use_flags = EnumSet.noneOf(Enum.ItemUseFlags.class); public int item_initial_charges; @@ -169,13 +169,13 @@ public class ItemTemplate { JSONArray weapon_damage = (JSONArray) item_weapon.get("weapon_damage"); - // Need a pojo for this or a PAIR<> - for (Object o : weapon_damage) { JSONObject damage_entry = (JSONObject) o; - item_weapon_damage_type = Enum.SourceType.valueOf(((String) damage_entry.get("damage_type")).toUpperCase()); - item_weapon_damage_min = ((Long) damage_entry.get("damage_min")).intValue(); - item_weapon_damage_max = ((Long) damage_entry.get("damage_max")).intValue(); + Enum.SourceType sourceType = Enum.SourceType.valueOf(((String) damage_entry.get("damage_type")).toUpperCase()); + int min = ((Long) damage_entry.get("damage_min")).intValue(); + int max = ((Long) damage_entry.get("damage_max")).intValue(); + Pair minMax = new Pair<>(min, max); // getKey = min. getValue = max. + item_weapon_damage.put(sourceType, minMax); } }