Browse Source

Support for multiple damage type entries.

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

16
src/engine/objects/ItemTemplate.java

@ -10,6 +10,7 @@ package engine.objects; @@ -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 { @@ -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<Enum.SourceType, Pair<Integer, Integer>> item_weapon_damage = new HashMap<>();
public EnumSet<Enum.ItemFlags> item_flags = EnumSet.noneOf(Enum.ItemFlags.class);
public EnumSet<Enum.ItemUseFlags> item_use_flags = EnumSet.noneOf(Enum.ItemUseFlags.class);
public int item_initial_charges;
@ -169,13 +169,13 @@ public class ItemTemplate { @@ -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<Integer, Integer> minMax = new Pair<>(min, max); // getKey = min. getValue = max.
item_weapon_damage.put(sourceType, minMax);
}
}

Loading…
Cancel
Save