28public enum MagicRune {
29 AIR_RUNE(556,
new int[]{4695, 4696, 4697},
new int[]{1381, 1397, 1405, 11998, 12000, 20730, 20733, 20736, 20739}),
30 FIRE_RUNE(554,
new int[]{4694, 4697, 4699},
new int[]{1387, 1393, 1401, 11998, 12000, 11787, 3053, 3054, 12795}),
31 WATER_RUNE(555,
new int[]{4694, 4695, 4698},
new int[]{1383, 1395, 1403, 20730, 20733, 6562, 6563, 11787, 11789, 12795, 21006}),
32 EARTH_RUNE(557,
new int[]{4698, 4696, 4699},
new int[]{3053, 3054, 1385, 1399, 1407, 6562, 6563, 20736, 20739}),
33 MIND_RUNE(558,
null,
null),
34 BODY_RUNE(559,
null,
null),
35 DEATH_RUNE(560,
null,
null),
36 NATURE_RUNE(561,
null,
null),
37 CHAOS_RUNE(562,
null,
null),
38 LAW_RUNE(563,
null,
null),
39 COSMIC_RUNE(564,
null,
null),
40 BLOOD_RUNE(565,
null,
null),
41 SOUL_RUNE(566,
null,
null),
42 ASTRAL_RUNE(9075,
null,
null),
43 WRATH_RUNE(21880,
null,
null);
45 private final int mainId;
46 private final int[] combos;
47 private final int[] staffs;
49 MagicRune(
int mainId,
int[] combos,
int[] staffs) {
55 public int getMainId() {
59 public int[] getCombos() {
63 public int[] getStaffs() {
67 public static MagicRune forMainId(
int id) {
68 for (MagicRune rune : values()) {
69 if (rune.mainId ==
id)
75 public boolean isStaff(
int id) {
76 if (staffs ==
null)
return false;
77 for (
int staff : staffs) {
85 public boolean containsCombo(
ItemContainer container,
int amount) {
86 if (combos ==
null)
return false;
87 for (
int combo : combos) {
88 if (container.
contains(combo, amount)) {
95 public static boolean hasRunes(
Player player, Item[] required) {
96 Item wepon = player.equipment.getWeapon();
97 for (Item item : required) {
98 MagicRune rune = forMainId(item.getId());
103 if (player.runePouch.contains(item))
106 if (wepon !=
null && rune.isStaff(wepon.getId()))
109 if (player.inventory.
contains(rune.mainId, item.getAmount()))
112 if (rune.containsCombo(player.inventory, item.getAmount()))
121 public static void remove(
Player player, Item[] required) {
122 Item wepon = player.equipment.getWeapon();
123 boolean refresh =
false;
125 for (Item item : required) {
126 MagicRune rune = forMainId(item.getId());
131 if (wepon !=
null && rune.isStaff(wepon.getId()))
134 if (player.runePouch.contains(item)) {
135 player.runePouch.remove(item);
139 if (player.inventory.
contains(rune.mainId, item.getAmount())) {
140 refresh |= player.inventory.
remove(rune.mainId, item.getAmount());
144 if (rune.combos !=
null && rune.containsCombo(player.inventory, item.getAmount())) {
145 for (
int combo : rune.combos) {
146 if (player.inventory.
contains(combo, item.getAmount())) {
147 refresh |= player.inventory.
remove(combo, item.getAmount());
155 if (refresh) player.inventory.
refresh();
159 List<Item> required =
new LinkedList<>();
161 required.add(
new Item(rune.getMainId(), rune.getAmount()));
163 return hasRunes(player, required.toArray(
new Item[required.size()]));
167 List<Item> required =
new LinkedList<>();
169 required.add(
new Item(rune.getMainId(), rune.getAmount()));
171 remove(player, required.toArray(
new Item[required.size()]));