38 NO_RANGED(31034, 631,
new RuleCondition() {
41 if (rules.contains(
DuelRule.NO_MELEE) && rules.contains(
DuelRule.NO_MAGIC)) {
42 player.send(
new SendMessage(
"You must have at least one combat type checked."));
50 NO_MELEE(31035, 632,
new RuleCondition() {
53 if (rules.contains(
DuelRule.NO_MAGIC) && rules.contains(
DuelRule.NO_RANGED)) {
54 player.send(
new SendMessage(
"You must have at least one combat type checked."));
58 if (rules.contains(
DuelRule.NO_WEAPON) && rules.contains(
DuelRule.NO_MAGIC)) {
59 player.message(
"You can't have No Melee, No Magic, Nothing in your Right Hand, how would you fight?");
63 if (rules.contains(
DuelRule.NO_FORFEIT)) {
64 player.send(
new SendMessage(
"You can't have No Forfeit and No Melee, you could run out of ammo."));
68 if (rules.contains(
DuelRule.ONLY_FUN_WEAPONS)) {
69 player.send(
new SendMessage(
"You cannot select no melee when only fun weapons selected."));
73 if (rules.contains(
DuelRule.ONLY_WHIP_DDS)) {
74 player.send(
new SendMessage(
"You cannot use whip and dragon dagger if melee is off."));
81 NO_MAGIC(31036, 633,
new RuleCondition() {
84 if (rules.contains(
DuelRule.NO_MELEE) && rules.contains(
DuelRule.NO_RANGED)) {
85 player.send(
new SendMessage(
"You must have at least one combat type checked."));
89 if (rules.contains(
DuelRule.NO_WEAPON) && rules.contains(
DuelRule.NO_MELEE)) {
90 player.message(
"You can't have No Melee, No Magic, Nothing in your Right Hand, how would you fight?");
96 NO_SPECIAL_ATTACK(31037, 634, (player, rules) ->
true),
97 ONLY_FUN_WEAPONS(31038, 635,
new RuleCondition() {
100 if (rules.contains(
DuelRule.NO_WEAPON)) {
101 player.send(
new SendMessage(
"You cannot select only fun weapons when no weapons selected."));
107 NO_FORFEIT(31039, 636,
new RuleCondition() {
110 if (rules.contains(
DuelRule.NO_MELEE)) {
111 player.send(
new SendMessage(
"You can't have No Forfeit and No Melee, you could run out of ammo."));
115 if (rules.contains(
DuelRule.OBSTACLES)) {
116 player.send(
new SendMessage(
"You cannot have no-movement and obstacles on at the same time."));
122 NO_PRAYER(31040, 637, (player, rules) ->
true),
123 NO_DRINKS(31041, 638, (player, rules) ->
true),
124 NO_FOOD(31042, 639, (player, rules) ->
true),
125 NO_MOVEMENT(31043, 640,
new RuleCondition() {
128 if (rules.contains(
DuelRule.OBSTACLES)) {
129 player.send(
new SendMessage(
"You cannot have no-movement and obstacles on at the same time."));
135 OBSTACLES(31044, 641,
new RuleCondition() {
138 if (rules.contains(
DuelRule.NO_MOVEMENT)) {
139 player.send(
new SendMessage(
"You cannot have no-movement and obstacles on at the same time."));
142 if (rules.contains(
DuelRule.OBSTACLES)) {
143 player.message(
"Obstacles are permanently disabled.");
146 player.message(
"Obstacles are permanently disabled.");
150 ONLY_WHIP_DDS(31056, 642,
new RuleCondition() {
153 if (rules.contains(
DuelRule.NO_WEAPON)) {
154 player.send(
new SendMessage(
"You cannot select only whip and dds when no weapons selected."));
157 if (rules.contains(
DuelRule.LOCK_ITEMS)) {
158 player.send(
new SendMessage(
"You cannot select only whip and dds when lock items is selected."));
164 LOCK_ITEMS(31059, 643,
new RuleCondition() {
167 if (rules.contains(
DuelRule.ONLY_WHIP_DDS)) {
168 player.send(
new SendMessage(
"You cannot select lock items when only whip and dds is selected."));
174 NO_HEAD(13813, 16384,
Equipment.HELM_SLOT, (player, rules) ->
true),
175 NO_CAPE(13814, 32768,
Equipment.CAPE_SLOT, (player, rules) ->
true),
176 NO_NECKLACE(13815, 65536,
Equipment.AMULET_SLOT, (player, rules) ->
true),
177 NO_AMMO(13816, 134217728,
Equipment.ARROWS_SLOT, (player, rules) ->
true),
178 NO_WEAPON(13817, 131072,
Equipment.WEAPON_SLOT,
new RuleCondition() {
181 if (rules.contains(
DuelRule.NO_MELEE) && rules.contains(
DuelRule.NO_MAGIC)) {
182 player.message(
"You can't have No Melee, No Magic, Nothing in your Right Hand, how would you fight?");
186 if (rules.contains(
DuelRule.ONLY_FUN_WEAPONS)) {
187 player.send(
new SendMessage(
"You cannot select no weapons when only fun weapons selected."));
191 if (rules.contains(
DuelRule.ONLY_WHIP_DDS)) {
192 player.send(
new SendMessage(
"You cannot select no weapons when only whip and dds only is selected."));
198 NO_BODY(13818, 262144,
Equipment.CHEST_SLOT,(player, rules) ->
true),
199 NO_SHIELD(13819, 524288,
Equipment.SHIELD_SLOT, (player, rules) ->
true),
200 NO_LEGS(13820, 2097152,
Equipment.LEGS_SLOT, (player, rules) ->
true),
201 NO_GLOVES(13823, 8388608,
Equipment.HANDS_SLOT, (player, rules) ->
true),
202 NO_BOOTS(13822, 16777216,
Equipment.FEET_SLOT, (player, rules) ->
true),
203 NO_RINGS(13821, 67108864,
Equipment.RING_SLOT, (player, rules) ->
true);
208 private final int button;
213 private final int value;
218 private final int slot;
223 private final RuleCondition condition;
232 DuelRule(
int button,
int value, RuleCondition condition) {
233 this(button, value, -1, condition);
244 DuelRule(
int button,
int value,
int slot, RuleCondition condition) {
245 this.button = button;
248 this.condition = condition;
251 public static final ImmutableSet<DuelRule> EQUIPMENT_RULES = ImmutableSet.of(NO_HEAD, NO_CAPE, NO_NECKLACE, NO_AMMO, NO_WEAPON, NO_BODY, NO_SHIELD, NO_LEGS, NO_GLOVES, NO_BOOTS, NO_RINGS);
253 public static Optional<DuelRule> forButton(
int button) {
255 if (rules.getButtonId() == button) {
256 return Optional.of(rules);
259 return Optional.empty();
262 public boolean canSet(
Player player) {
263 if (!Activity.search(player, DuelArenaActivity.class).isPresent()) {
267 DuelArenaActivity activity = Activity.search(player, DuelArenaActivity.class).get();
269 final DuelRules rules = activity.rules;
271 if (!condition.canSelect(player, rules)) {
275 Player other = activity.opponent;
277 if (inventorySlotsRequired(player, rules,
this) > player.inventory.
getFreeSlots()) {
281 if (inventorySlotsRequired(other, rules,
this) > other.inventory.getFreeSlots()) {
288 public static void validateEquipmentRules(
Player player) {
293 if (activity.rules.contains(rule) && !rule.canSet(player)) {
294 activity.rules.unflag(rule);
298 player.send(
new SendToggle(286, activity.rules.getValue()));
299 activity.opponent.send(
new SendToggle(286, activity.rules.getValue()));
305 if (!EQUIPMENT_RULES.contains(rule)) {
306 player.send(
new SendConfig(rule.getValue(), activity.rules.contains(rule) ? 1 : 0));
307 other.send(
new SendConfig(rule.getValue(), activity.rules.contains(rule) ? 1 : 0));
311 player.send(
new SendToggle(286, activity.rules.getValue()));
312 other.send(
new SendToggle(286, activity.rules.getValue()));
315 public boolean set(
Player player,
boolean showMessage) {
324 boolean meets = condition.canSelect(player, rules);
326 Player other = player.equals(activity.opponent) ? activity.player : activity.opponent;
329 if (inventorySlotsRequired(player, rules,
this) > player.inventory.getFreeSlots()) {
331 player.send(
new SendMessage(
"You do not have enough inventory space."));
336 if (inventorySlotsRequired(other, rules,
this) > other.inventory.getFreeSlots()) {
338 player.send(
new SendMessage(
"The other player does not have enough space."));
343 rules.alternate(
this);
345 if ((this.getButtonId() >= 31034 && this.getButtonId() <= 31056) || this.getButtonId() == 31059) {
346 player.send(
new SendConfig(this.getValue(), rules.contains(
this) ? 1 : 0));
347 other.send(
new SendConfig(this.getValue(), rules.contains(
this) ? 1 : 0));
349 player.send(
new SendToggle(286, rules.getValue()));
350 other.send(
new SendToggle(286, rules.getValue()));
362 EnumSet<DuelRule> tempRules = EnumSet.copyOf(rules.getFlags());
365 if (player.equipment.hasHead()) {
366 if (tempRules.contains(
DuelRule.NO_HEAD)) {
371 if (player.equipment.hasAmulet()) {
372 if (tempRules.contains(
DuelRule.NO_NECKLACE)) {
377 if (player.equipment.hasWeapon()) {
378 Item item = player.equipment.get(
Equipment.WEAPON_SLOT);
380 String name = item.getName().toLowerCase();
382 if (tempRules.contains(
DuelRule.NO_WEAPON)) {
386 if (tempRules.contains(
DuelRule.ONLY_WHIP_DDS)) {
387 if (!(name.contains(
"whip") || name.contains(
"abyssal tentacle") || name.contains(
"dragon dagger"))) {
394 if (player.equipment.hasCape()) {
395 if (tempRules.contains(
DuelRule.NO_CAPE)) {
400 if (player.equipment.hasAmmo()) {
401 if (tempRules.contains(
DuelRule.NO_AMMO)) {
406 if (player.equipment.hasChest()) {
407 if (tempRules.contains(
DuelRule.NO_BODY)) {
412 if (tempRules.contains(
DuelRule.NO_SHIELD)) {
414 if (player.equipment.hasShield()) {
418 Item weapon = player.equipment.get(
Equipment.WEAPON_SLOT);
420 if (weapon !=
null) {
424 if (def !=
null && def.isTwoHanded()) {
431 if (player.equipment.hasLegs()) {
432 if (tempRules.contains(
DuelRule.NO_LEGS)) {
437 if (player.equipment.hasHands()) {
438 if (tempRules.contains(
DuelRule.NO_GLOVES)) {
443 if (player.equipment.hasFeet()) {
444 if (tempRules.contains(
DuelRule.NO_BOOTS)) {
449 if (player.equipment.hasRing()) {
450 if (tempRules.contains(
DuelRule.NO_RINGS)) {
487 public interface RuleCondition {