Browse Source

Refactor to array.

combat-2
MagicBot 9 months ago
parent
commit
8ae4a67635
  1. 10
      src/engine/objects/ItemTemplate.java

10
src/engine/objects/ItemTemplate.java

@ -10,7 +10,6 @@ package engine.objects;
import engine.Enum; import engine.Enum;
import engine.math.Vector3fImmutable; import engine.math.Vector3fImmutable;
import javafx.util.Pair;
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 org.pmw.tinylog.Logger;
@ -56,7 +55,7 @@ public class ItemTemplate {
public float item_weapon_projectile_speed; public float item_weapon_projectile_speed;
public int item_weapon_combat_idle_anim; public int item_weapon_combat_idle_anim;
public HashMap<Enum.SourceType, Pair<Integer, Integer>> item_weapon_damage = new HashMap<>(); public HashMap<Enum.SourceType, int[]> item_weapon_damage = new HashMap<>();
public EnumSet<Enum.ItemFlags> item_flags = EnumSet.noneOf(Enum.ItemFlags.class); public EnumSet<Enum.ItemFlags> item_flags = EnumSet.noneOf(Enum.ItemFlags.class);
public EnumSet<Enum.ItemUseFlags> item_use_flags = EnumSet.noneOf(Enum.ItemUseFlags.class); public EnumSet<Enum.ItemUseFlags> item_use_flags = EnumSet.noneOf(Enum.ItemUseFlags.class);
public int item_initial_charges; public int item_initial_charges;
@ -70,8 +69,7 @@ public class ItemTemplate {
public EnumSet<Enum.DisciplineType> item_disc_res = EnumSet.noneOf(Enum.DisciplineType.class); public EnumSet<Enum.DisciplineType> item_disc_res = EnumSet.noneOf(Enum.DisciplineType.class);
public int item_level_req; public int item_level_req;
public Enum.SexType item_sex_req; public Enum.SexType item_sex_req;
public HashMap<String, Pair<Integer, Integer>> item_user_power_action = new HashMap<>(); public HashMap<String, int[]> item_user_power_action = new HashMap<>();
public ItemTemplate(JSONObject jsonObject) { public ItemTemplate(JSONObject jsonObject) {
@ -178,7 +176,7 @@ public class ItemTemplate {
Enum.SourceType sourceType = Enum.SourceType.valueOf(((String) damage_entry.get("damage_type")).toUpperCase()); Enum.SourceType sourceType = Enum.SourceType.valueOf(((String) damage_entry.get("damage_type")).toUpperCase());
int min = ((Long) damage_entry.get("damage_min")).intValue(); int min = ((Long) damage_entry.get("damage_min")).intValue();
int max = ((Long) damage_entry.get("damage_max")).intValue(); int max = ((Long) damage_entry.get("damage_max")).intValue();
Pair<Integer, Integer> minMax = new Pair<>(min, max); // getKey = min. getValue = max. int[] minMax = {min, max};
item_weapon_damage.put(sourceType, minMax); item_weapon_damage.put(sourceType, minMax);
} }
} }
@ -266,7 +264,7 @@ public class ItemTemplate {
JSONObject powerActionEntry = (JSONObject) o; JSONObject powerActionEntry = (JSONObject) o;
String power = (String) powerActionEntry.get("power"); String power = (String) powerActionEntry.get("power");
JSONArray args = (JSONArray) powerActionEntry.get("arguments"); JSONArray args = (JSONArray) powerActionEntry.get("arguments");
Pair<Integer, Integer> arguments = new Pair<>(((Long) args.get(0)).intValue(), ((Long) args.get(1)).intValue()); int[] arguments = {((Long) args.get(0)).intValue(), ((Long) args.get(1)).intValue()};
item_user_power_action.put(power, arguments); item_user_power_action.put(power, arguments);
} }
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save