RuneHive-Game
Loading...
Searching...
No Matches
DuelRules.java
Go to the documentation of this file.
1package com.runehive.content.activity.impl.duelarena;
2
3import java.util.EnumSet;
4
5
6public final class DuelRules {
7
8 private final EnumSet<DuelRule> flags = EnumSet.noneOf(DuelRule.class);
9
10 private int value;
11
12 private void incrementValue(int value) {
13 this.value += value;
14 }
15
16 private void decrementValue(int value) {
17 this.value -= value;
18 if (this.value < 0) {
19 this.value = 0;
20 }
21 }
22
23 public void flag(DuelRule rule) {
24 if (flags.contains(rule)) {
25 return;
26 }
27 flags.add(rule);
28 if (DuelRule.EQUIPMENT_RULES.contains(rule)) {
30 }
31 }
32
33 public void unflag(DuelRule rule) {
34 if (!flags.contains(rule)) {
35 return;
36 }
37 flags.remove(rule);
38 if (DuelRule.EQUIPMENT_RULES.contains(rule)) {
40 }
41 }
42
43 public void alternate(DuelRule flag) {
44 if (flags.contains(flag)) {
45 flags.remove(flag);
46 if (DuelRule.EQUIPMENT_RULES.contains(flag)) {
47 decrementValue(flag.getValue());
48 }
49 } else {
50 flags.add(flag);
51 if (DuelRule.EQUIPMENT_RULES.contains(flag)) {
52 incrementValue(flag.getValue());
53 }
54 }
55 }
56
57 public int getValue() {
58 return value;
59 }
60
61 public boolean contains(DuelRule rule) {
62 return flags.contains(rule);
63 }
64
65 public void reset() {
66 flags.clear();
67 value = 0;
68 }
69
70 public EnumSet<DuelRule> getFlags() {
71 return flags.clone();
72 }
73
74}
static final ImmutableSet< DuelRule > EQUIPMENT_RULES