diff --git a/src/engine/Enum.java b/src/engine/Enum.java index 9da4fa22..08e9685e 100644 --- a/src/engine/Enum.java +++ b/src/engine/Enum.java @@ -34,6 +34,20 @@ import java.util.concurrent.ThreadLocalRandom; public class Enum { + public static > EnumSet fromLong(long bitVector, Class enumClass) { + + // Bitvector -> EnumSet without the EnumBitvector dependency + + EnumSet enumSet = EnumSet.noneOf(enumClass); + + for (E enumValue : enumClass.getEnumConstants()) { + if ((bitVector & (1L << enumValue.ordinal())) != 0) { + enumSet.add(enumValue); + } + } + return enumSet; + } + public enum PetitionType { NONE, GENERAL, diff --git a/src/engine/objects/ItemTemplate.java b/src/engine/objects/ItemTemplate.java index c581ed49..717ba8c8 100644 --- a/src/engine/objects/ItemTemplate.java +++ b/src/engine/objects/ItemTemplate.java @@ -129,6 +129,8 @@ public class ItemTemplate { public final HashMap rune_skill_adj = new HashMap<>(); public final EnumSet rune_enemy_monster_types = EnumSet.noneOf(Enum.MonsterType.class); public final EnumSet rune_not_enemy_monster_types = EnumSet.noneOf(Enum.MonsterType.class); + public final EnumSet rune_groupee_monster_types = EnumSet.noneOf(Enum.MonsterType.class); + public final EnumSet rune_helper_monster_types = EnumSet.noneOf(Enum.MonsterType.class); public ItemTemplate(JSONObject jsonObject) { @@ -511,6 +513,12 @@ public class ItemTemplate { rune_not_enemy_monster_types.add(monsterType); } + long rune_groupee_bitvector = ((Long) jsonObject.get("rune_groupee_monster_types")).intValue(); + rune_groupee_monster_types.addAll(Enum.fromLong(rune_groupee_bitvector, Enum.MonsterType.class)); + + long rune_helper_bitvector = ((Long) jsonObject.get("rune_helper_monster_types")).intValue(); + rune_helper_monster_types.addAll(Enum.fromLong(rune_helper_bitvector, Enum.MonsterType.class)); + rune_renderable = ((Boolean) jsonObject.get("rune_renderable")); rune_natural_power_attack = ((Long) jsonObject.get("rune_natural_power_attack")).intValue(); diff --git a/src/engine/util/MiscUtils.java b/src/engine/util/MiscUtils.java index 9f077c69..9902f543 100644 --- a/src/engine/util/MiscUtils.java +++ b/src/engine/util/MiscUtils.java @@ -35,4 +35,5 @@ public class MiscUtils { // empty last names are fine, return false return false; } + }