RuneHive-Game
Loading...
Searching...
No Matches
Prayer.java
Go to the documentation of this file.
1package com.runehive.game.world.entity.mob.prayer;
2
3import com.google.common.collect.ImmutableList;
4import com.google.common.collect.ImmutableSet;
5import com.runehive.game.world.entity.combat.attack.listener.CombatListener;
6import com.runehive.game.world.entity.combat.attack.listener.other.prayer.AuguryListener;
7import com.runehive.game.world.entity.combat.attack.listener.other.prayer.ChivalryListener;
8import com.runehive.game.world.entity.combat.attack.listener.other.prayer.PietyListener;
9import com.runehive.game.world.entity.combat.attack.listener.other.prayer.RigourListener;
10import com.runehive.game.world.entity.combat.attack.listener.other.prayer.attack.ClarityOfThoughtListener;
11import com.runehive.game.world.entity.combat.attack.listener.other.prayer.attack.ImprovedReflexesListener;
12import com.runehive.game.world.entity.combat.attack.listener.other.prayer.attack.IncredibleReflexesListener;
13import com.runehive.game.world.entity.combat.attack.listener.other.prayer.defence.RockSkinListener;
14import com.runehive.game.world.entity.combat.attack.listener.other.prayer.defence.SteelSkinListener;
15import com.runehive.game.world.entity.combat.attack.listener.other.prayer.defence.ThickSkinListener;
16import com.runehive.game.world.entity.combat.attack.listener.other.prayer.magic.MysticLoreListener;
17import com.runehive.game.world.entity.combat.attack.listener.other.prayer.magic.MysticMightListener;
18import com.runehive.game.world.entity.combat.attack.listener.other.prayer.magic.MysticWillListener;
19import com.runehive.game.world.entity.combat.attack.listener.other.prayer.ranged.EagleEyeListener;
20import com.runehive.game.world.entity.combat.attack.listener.other.prayer.ranged.HawkEyeListener;
21import com.runehive.game.world.entity.combat.attack.listener.other.prayer.ranged.SharpListener;
22import com.runehive.game.world.entity.combat.attack.listener.other.prayer.strength.BurstOfStrengthListener;
23import com.runehive.game.world.entity.combat.attack.listener.other.prayer.strength.SuperhumanStrengthListener;
24import com.runehive.game.world.entity.combat.attack.listener.other.prayer.strength.UltimateStrengthListener;
25import com.runehive.game.world.entity.mob.Mob;
26import com.runehive.game.world.entity.mob.player.Player;
27import com.runehive.game.world.entity.mob.player.PlayerRight;
28import com.runehive.game.world.entity.skill.Skill;
29import com.runehive.net.packet.out.SendConfig;
30import com.runehive.net.packet.out.SendMessage;
31
32import java.util.*;
33
34/**
35 * Handles the prayer book.
36 *
37 * @author Michael
38 * @author Daniel
39 */
40public enum Prayer {
41 THICK_SKIN("Thick Skin", 1, 3, 83, 630, 5609, new ThickSkinListener(), Type.DEFENSIVE),
42 BURST_OF_STRENGTH("Burst of Strength", 4, 3, 84, 631, 5610, new BurstOfStrengthListener(), Type.AGGRESSIVE),
43 CLARITY_OF_THOUGHT("Clarity of Thought", 7, 3, 85, 632, 5611, new ClarityOfThoughtListener(), Type.OFFENSIVE),
44 SHARP_EYE("Sharp Eye", 8, 3, 700, 633, 19812, new SharpListener(), Type.OFFENSIVE, Type.AGGRESSIVE),
45 MYSTIC_WILL("Mystic Will", 9, 3, 701, 634, 19814, new MysticWillListener(), Type.OFFENSIVE, Type.AGGRESSIVE),
46 ROCK_SKIN("Rock Skin", 10, 6, 86, 635, 5612, new RockSkinListener(), Type.DEFENSIVE),
47 SUPERHUMAN_STRENGTH("Superhuman Strength", 13, 6, 87, 636, 5613, new SuperhumanStrengthListener(), Type.AGGRESSIVE),
48 IMPROVED_REFLEXES("Improved Reflexes", 16, 6, 88, 637, 5614, new ImprovedReflexesListener(), Type.OFFENSIVE),
49 RAPID_RESTORE("Rapid Restore", 19, 1, 89, 638, 5615, Type.NORMAL),
50 RAPID_HEAL("Rapid Heal", 22, 2, 90, 639, 5616, Type.NORMAL),
51 PROTECT_ITEM("Protect Item", 25, 2, 91, 640, 5617, Type.NORMAL),
52 HAWK_EYE("Hawk Eye", 26, 6, 702, 641, 19816, new HawkEyeListener(), Type.OFFENSIVE, Type.AGGRESSIVE),
53 MYSTIC_LORE("Mystic Lore", 27, 6, 703, 642, 19818, new MysticLoreListener(), Type.OFFENSIVE, Type.AGGRESSIVE),
54 STEEL_SKIN("Steel Skin", 28, 12, 92, 643, 5618, new SteelSkinListener(), Type.DEFENSIVE),
55 ULTIMATE_STRENGTH("Ultimate Strength", 31, 12, 93, 644, 5619, new UltimateStrengthListener(), Type.AGGRESSIVE),
56 INCREDIBLE_REFLEXES("Incredible Reflexes", 34, 12, 94, 645, 5620, new IncredibleReflexesListener(), Type.OFFENSIVE),
57 PROTECT_FROM_MAGIC("Protect from Magic", 37, 12, 95, 646, 5621, Type.OVERHEAD),
58 PROTECT_FROM_RANGE("Protect from Range", 40, 12, 96, 647, 5622, Type.OVERHEAD),
59 PROTECT_FROM_MELEE("Protect from Melee", 43, 12, 97, 648, 5623, Type.OVERHEAD),
60 EAGLE_EYE("Eagle Eye", 44, 12, 704, 649, 19821, new EagleEyeListener(), Type.OFFENSIVE, Type.AGGRESSIVE),
61 MYSTIC_MIGHT("Mystic Might", 45, 12, 705, 650, 19823, new MysticMightListener(), Type.OFFENSIVE, Type.AGGRESSIVE),
62 RETRIBUTION("Retribution", 46, 3, 98, 651, 683, Type.OVERHEAD),
63 REDEMPTION("Redemption", 49, 6, 99, 652, 684, Type.OVERHEAD),
64 SMITE("Smite", 52, 18, 100, 653, 685, Type.OVERHEAD),
65 PRESERVE("Preserve", 55, 3, 708, 654, 28001, Type.NORMAL),
66 CHIVALRY("Chivalry", 60, 24, 706, 655, 19825, new ChivalryListener(), Type.OFFENSIVE, Type.AGGRESSIVE, Type.DEFENSIVE),
67 PIETY("Piety", 70, 24, 707, 656, 19827, new PietyListener(), Type.OFFENSIVE, Type.AGGRESSIVE, Type.DEFENSIVE),
68 RIGOUR("Rigour", 74, 24, 710, 657, 28004, new RigourListener(), Type.OFFENSIVE, Type.DEFENSIVE, Type.AGGRESSIVE),
69 AUGURY("Augury", 77, 24, 712, 658, 28007, new AuguryListener(), Type.OFFENSIVE, Type.DEFENSIVE, Type.AGGRESSIVE);
70
71 /** The name of the prayer. */
72 public final String name;
73
74 /** The required prayer level. */
75 public final int level;
76
77 /** The prayer drain rate. */
78 private final int drainRate;
79
80 /** The prayer config id. */
81 private final int config;
82
83 /** The quick-prayer config id. */
84 private final int qConfig;
85
86 /** The button id. */
87 private final int button;
88
89 /** The listener. */
91
92 /** The prayer type. */
93 private final Type[] types;
94
95 /**
96 * Constructs a new default prayer book.
97 *
98 * @param name The prayer name.
99 * @param level The required prayer level.
100 * @param drainRate The prayer's drain rate.
101 * @param config The prayer's config id.
102 * @param button The button id.
103 */
104 Prayer(String name, int level, int drainRate, int config, int qConfig, int button, Type... types) {
105 this.name = name;
106 this.level = level;
107 this.drainRate = drainRate;
108 this.config = config;
109 this.qConfig = qConfig;
110 this.button = button;
111 this.listener = null;
112 this.types = types;
113 }
114
115 /**
116 * Constructs a new default prayer book.
117 *
118 * @param name The prayer name.
119 * @param level The required prayer level.
120 * @param drainRate The prayer's drain rate.
121 * @param config The prayer's config id.
122 * @param button The button id.
123 */
125 this.name = name;
126 this.level = level;
127 this.drainRate = drainRate;
128 this.config = config;
129 this.qConfig = qConfig;
130 this.button = button;
131 this.listener = listener;
132 this.types = types;
133 }
134
135 /** Streams for the prayer button. */
136 public static Optional<Prayer> forButton(int button) {
137 return Arrays.stream(values()).filter(p -> p.getButton() == button).findAny();
138 }
139
140 public String getName() {
141 return name;
142 }
143
144 public int getLevel() {
145 return level;
146 }
147
148 public int getDrainRate() {
149 return drainRate;
150 }
151
152 public int getConfig() {
153 return config;
154 }
155
156 public int getQConfig() {
157 return qConfig;
158 }
159
160 public int getButton() {
161 return button;
162 }
163
164 public Prayer.Type[] getTypes() {
165 return types;
166 }
167
168 private static final Collection<Prayer> OFFENSIVE = ImmutableList.of(
169 CLARITY_OF_THOUGHT, IMPROVED_REFLEXES, INCREDIBLE_REFLEXES,
170 SHARP_EYE, HAWK_EYE, EAGLE_EYE,
171 MYSTIC_WILL, MYSTIC_LORE, MYSTIC_MIGHT,
172 CHIVALRY, PIETY, RIGOUR, AUGURY
173 );
174
175 private static final Collection<Prayer> AGGRESSIVE = ImmutableList.of(
180 );
181
182 private static final Collection<Prayer> DEFENSIVE = ImmutableList.of(
185 );
186
187 public static final Collection<Prayer> OVERHEAD = ImmutableList.of(
190 );
191
192 /**
193 * Checks if a prayer is of a certain type.
194 *
195 * @param type The type to check
196 * @return {@code True} if the prayer is of thie given type.
197 */
198 boolean is(Type type) {
199 return Arrays.stream(getTypes()).anyMatch(other -> type == other);
200 }
201
202 /**
203 * Gets the prayers to disable after activating this prayer.
204 *
205 * @return A set of prayers to disable.
206 */
207 Set<Prayer> toDeactivate() {
208 Type[] types = getTypes();
209 if (types.length == 0) return EMPTY;
210 Set<Prayer> deactivate = new HashSet<>();
211 for (Type type : types) {
212 deactivate.addAll(forType(type));
213 }
214 return deactivate;
215
216 }
217 public static double getBonus(Player player) {
218 double bonus = 0;
219 if(player.equipment.getId(0) == 25438)
220 bonus += 0.4;
221 if(player.equipment.getId(4) == 25434)
222 bonus += 0.8;
223 if(player.equipment.getId(7) == 25436)
224 bonus += 0.6;
225 if(player.equipment.getId(10) == 25440)
226 bonus += 0.2;
227
228 if(player.equipment.containsAll(25438, 25434, 25436, 25440))
229 bonus = 2.5;
230
231 return bonus;
232 }
233
234
235 public boolean canToggle(Player player) {
236 if (player.skills.getLevel(Skill.PRAYER) == 0) {
237 return false;
238 }
239 if (level > player.skills.getMaxLevel(Skill.PRAYER)) {
240 return false;
241 }
242 if (this == CHIVALRY && player.skills.getMaxLevel(Skill.DEFENCE) < 60) {
243 return false;
244 }
245 if ((this == PIETY || this == RIGOUR || this == AUGURY) && player.skills.getMaxLevel(Skill.DEFENCE) < 70) {
246 return false;
247 }
248 if (this == PROTECT_ITEM && player.right.equals(PlayerRight.ULTIMATE_IRONMAN)) {
249 return false;
250 }
251 /* if ((this == PROTECT_FROM_MAGIC || this == PROTECT_FROM_MELEE || this == PROTECT_FROM_RANGE) && Area.inEventArena(player)) {
252 return false;
253 }*/
254 return PlayerRight.isAdministrator(player) || (this != RIGOUR && this != AUGURY && this != PRESERVE) || player.unlockedPrayers.contains(this);
255 }
256
257 public void reset(Player player) {
258 reset(player, null);
259 }
260
261 /**
262 * Resets the configs for this prayer. The quick prayer icon will be
263 * disabled and all active prayers will be reset.
264 *
265 * @param player The player.
266 * @param message The message to send, or null if none.
267 */
268 public void reset(Player player, String message) {
269 player.prayer.reset();
270 player.send(new SendConfig(config, 0));
271 if (message != null) {
272 player.send(new SendMessage(message));
273 }
274 }
275
276 public Optional<CombatListener<Mob>> getListener() {
277 return Optional.ofNullable(listener);
278 }
279
280 public int getHeadIcon() {
281 switch (this) {
283 return 2;
285 return 1;
287 return 0;
288 case RETRIBUTION:
289 return 3;
290 case REDEMPTION:
291 return 5;
292 case SMITE:
293 return 4;
294 default:
295 return -1;
296 }
297 }
298
299 Collection<Prayer> forType(Type type) {
300 switch (type) {
301 case OFFENSIVE:
302 return OFFENSIVE;
303 case DEFENSIVE:
304 return DEFENSIVE;
305 case AGGRESSIVE:
306 return AGGRESSIVE;
307 case OVERHEAD:
308 return OVERHEAD;
309 default:
310 return EMPTY;
311 }
312 }
313
314 static final Set<Prayer> EMPTY = ImmutableSet.of();
315
323}
This class represents a character controlled by a player.
Definition Player.java:125
Represents a trainable and usable skill.
Definition Skill.java:18
static final int PRAYER
The prayer skill id.
Definition Skill.java:36
static final int DEFENCE
The defence skill id.
Definition Skill.java:24
The OutgoingPacket responsible for changing settings on a client.
The OutgoingPacket that sends a message to a Players chatbox in the client.
static boolean isAdministrator(Player player)
Checks if the player is a privileged member.
final int config
The prayer config id.
Definition Prayer.java:81
void reset(Player player, String message)
Resets the configs for this prayer.
Definition Prayer.java:268
final int qConfig
The quick-prayer config id.
Definition Prayer.java:84
static double getBonus(Player player)
Definition Prayer.java:217
static final Collection< Prayer > OVERHEAD
Definition Prayer.java:187
static final Collection< Prayer > OFFENSIVE
Definition Prayer.java:168
boolean is(Type type)
Checks if a prayer is of a certain type.
Definition Prayer.java:198
Set< Prayer > toDeactivate()
Gets the prayers to disable after activating this prayer.
Definition Prayer.java:207
Optional< CombatListener< Mob > > getListener()
Definition Prayer.java:276
final int level
The required prayer level.
Definition Prayer.java:75
Collection< Prayer > forType(Type type)
Definition Prayer.java:299
Prayer(String name, int level, int drainRate, int config, int qConfig, int button, CombatListener< Mob > listener, Type... types)
Constructs a new default prayer book.
Definition Prayer.java:124
final String name
The name of the prayer.
Definition Prayer.java:72
Prayer(String name, int level, int drainRate, int config, int qConfig, int button, Type... types)
Constructs a new default prayer book.
Definition Prayer.java:104
static final Collection< Prayer > AGGRESSIVE
Definition Prayer.java:175
final int drainRate
The prayer drain rate.
Definition Prayer.java:78
static final Collection< Prayer > DEFENSIVE
Definition Prayer.java:182
final CombatListener< Mob > listener
The listener.
Definition Prayer.java:90
static Optional< Prayer > forButton(int button)
Streams for the prayer button.
Definition Prayer.java:136
A combat attack is used to describe what the attacking and defending mobs should do in each stage of ...