RuneHive-Game
Loading...
Searching...
No Matches
SlayerTask.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.slayer;
2
3import com.runehive.game.world.entity.mob.npc.definition.NpcDefinition;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.entity.skill.Skill;
6import com.runehive.game.world.position.Position;
7import com.runehive.util.Utility;
8
9import java.util.ArrayList;
10
11/**
12 * Holds all the slayer task data.
13 *
14 * @author Daniel
15 * @author Ethan
16 */
17public enum SlayerTask implements TaskInterface<Player> {
18 SAND_CRAB(new String[]{"Sand Crab"}, 1, false, TaskDifficulty.EASY, new Position(1726, 3463), "") {
19 @Override
20 public boolean canAssign(Player player) {
21 return true;
22 }
23
24 },
25 ROCK_CRAB(new String[]{"Rock Crab"}, 1, false, TaskDifficulty.EASY, new Position(2676, 3711), "Camelot") {
26 @Override
27 public boolean canAssign(Player player) {
28 return true;
29 }
30
31 },
32 CRAWLING_HAND(new String[]{"Crawling hand"}, 1, false, TaskDifficulty.EASY, new Position(3424, 3543), "Slayer Tower") {
33 @Override
34 public boolean canAssign(Player player) {
35 return true;
36 }
37
38 },
39 HILL_GIANT(new String[]{"Hill Giant"}, 1, false, TaskDifficulty.EASY, new Position(3117, 9856), "") {
40 @Override
41 public boolean canAssign(Player player) {
42 return true;
43 }
44
45 },
46 FIRE_GIANT(new String[]{"Fire giant"}, 5, false, TaskDifficulty.MEDIUM, new Position(2655, 9489), "Slayer Cave") {
47 @Override
48 public boolean canAssign(Player player) {
49 return true;
50 }
51
52 },
53 GREEN_DRAGON(new String[]{"Green dragon", "Baby green dragon"}, 5, false, TaskDifficulty.MEDIUM, new Position(3339, 3668), "WILDERNESS") {
54 @Override
55 public boolean canAssign(Player player) {
56 return true;
57 }
58
59 },
60 BANSHEE(new String[]{"Banshee"}, 15, false, TaskDifficulty.MEDIUM, new Position(3340, 3560), "Pollnivneach Smoke Dungeon") {
61 @Override
62 public boolean canAssign(Player player) {
63 return true;
64 }
65 },
66 BLOODVELDS(new String[]{"Bloodveld"}, 15, false, TaskDifficulty.MEDIUM, new Position(3419, 3562), "Slayer Tower") {
67 @Override
68 public boolean canAssign(Player player) {
69 return true;
70 }
71 },
72 INFERNAL_MAGES(new String[]{"Infernal Mage"}, 45, false, TaskDifficulty.MEDIUM, new Position(3445, 3560), "Pollnivneach Well Dungeon") {
73 @Override
74 public boolean canAssign(Player player) {
75 return true;
76 }
77
78 },
79 AVIANSIES(new String[]{"Aviansie"}, 50, false, TaskDifficulty.MEDIUM, new Position(2882, 5287, 2), "Stronghold of Security") {
80 @Override
81 public boolean canAssign(Player player) {
82 return true;
83 }
84
85 },
86 DUST_DEVILS(new String[]{"Dust devil"}, 65, true, TaskDifficulty.MEDIUM, new Position(3239, 9364), "Pollnivneach Smoke Dungeon") {
87 @Override
88 public boolean canAssign(Player player) {
89 return true;
90 }
91
92 },
93 ABERRANT_SPECTRES(new String[]{"Aberrant spectre"}, 60, true, TaskDifficulty.MEDIUM, new Position(3420, 3553, 1), "Slayer Tower") {
94 @Override
95 public boolean canAssign(Player player) {
96 return true;
97 }
98 },
99 ANKOU(new String[]{"Ankou"}, 1, false, TaskDifficulty.HARD, new Position(2359, 5236), "Stronghold of Security") {
100 @Override
101 public boolean canAssign(Player player) {
102 return true;
103 }
104 },
105 BLACK_DEMONS(new String[]{"Black demon"}, 12, false, TaskDifficulty.HARD, new Position(2876, 9790), "Taverly Dungeon") {
106 @Override
107 public boolean canAssign(Player player) {
108 return true;
109 }
110 },
111 DAGANNOTHS(new String[]{"Dagannoth", "Dagannoth mother", "Dagannoth Supreme", "Dagannoth Prime", "Dagannoth Rex"}, 1, false, TaskDifficulty.HARD, new Position(1891, 4369), "Fremennik Province Light House") {
112 @Override
113 public boolean canAssign(Player player) {
114 return true;
115 }
116
117 },
118 HELLHOUNDS(new String[]{"Hellhound", "Cerberus"}, 12, false, TaskDifficulty.HARD, new Position(2827, 9847), "Taverly Dungeon") {
119 @Override
120 public boolean canAssign(Player player) {
121 return true;
122 }
123
124 },
125 MITHRIL_DRAGON(new String[]{"Mithril dragon"}, 1, false, TaskDifficulty.HARD, new Position(1748, 5326), "Ancient Caverns") {
126 @Override
127 public boolean canAssign(Player player) {
128 return true;
129 }
130
131 },
132 STEEL_DRAGONS(new String[]{"Steel dragon"}, 35, false, TaskDifficulty.HARD, new Position(2629, 9422), "Karamja Dungeon") {
133 @Override
134 public boolean canAssign(Player player) {
135 return true;
136 }
137 },
138 IRON_DRAGONS(new String[]{"Iron dragon"}, 35, false, TaskDifficulty.HARD, new Position(2682, 9463), "Karamja Dungeon") {
139 @Override
140 public boolean canAssign(Player player) {
141 return true;
142 }
143 },
144 BLUE_DRAGONS(new String[]{"Blue dragon", "Baby blue dragon"}, 35, false, TaskDifficulty.MEDIUM, new Position(2886, 9799), "Taverly Dungeon") {
145 @Override
146 public boolean canAssign(Player player) {
147 return true;
148 }
149 },
150 GARGOYLES(new String[]{"Gargoyle"}, 75, true, TaskDifficulty.HARD, new Position(3437, 3542), "Slayer Tower") {
151 @Override
152 public boolean canAssign(Player player) {
153 return player.skills.getMaxLevel(Skill.SLAYER) >= 75;
154 }
155 },
156 CRAZY_ARCHAEOLOGIST(new String[]{"Crazy archaeologist"}, 60, false, TaskDifficulty.HARD, new Position(2966, 3698), "Wilderness") {
157 @Override
158 public boolean canAssign(Player player) {
159 return player.slayer.getUnlocked().contains(SlayerUnlockable.CRAZY_ARCHAEOLOGIST);
160 }
161 },
162 // CHAOS_ELEMENTAL("Chaos elemental", 1, 150, TaskDifficulty.HARD, new Position(1, 1), "Wilderness", 2054) {
163// @Override
164// public boolean canAssign(Player player) {
165// return player.slayer.getUnlocked().contains(SlayerUnlockable.CHAOS_ELEMENT);
166// }
167//
168// @Override
169// public boolean canAttack(Player player) {
170// return true;
171// }
172// },
173 SPIRTUAL_RANGERS(new String[]{"Spiritual Ranger"}, 63, false, TaskDifficulty.HARD, new Position(2882, 5287, 2), "Godwars Dungeon") {
174 @Override
175 public boolean canAssign(Player player) {
176 return true;
177 }
178 },
179 SPIRTUAL_WARRIORS(new String[]{"Spiritual Warrior"}, 68, false, TaskDifficulty.HARD, new Position(2882, 5287, 2), "Godwars Dungeon") {
180 @Override
181 public boolean canAssign(Player player) {
182 return true;
183 }
184 },
185 SPIRTUAL_MAGES(new String[]{"Spiritual Mage"}, 83, false, TaskDifficulty.HARD, new Position(2882, 5287, 2), "Godwars Dungeon") {
186 @Override
187 public boolean canAssign(Player player) {
188 return true;
189 }
190 },
191 SKELETAL_WYVERN(new String[]{"Skeletal wyvern"}, 72, true, TaskDifficulty.HARD, new Position(3056, 9562), "Asgarnia Ice Dungeon") {
192 @Override
193 public boolean canAssign(Player player) {
194 return player.skills.getMaxLevel(Skill.SLAYER) >= 72;
195 }
196 },
197 ABYSSAL_DEMONS(new String[]{"Abyssal Demon"}, 85, true, TaskDifficulty.HARD, new Position(3414, 3558), "Slayer Tower") {
198 @Override
199 public boolean canAssign(Player player) {
200 return player.skills.getMaxLevel(Skill.SLAYER) >= 85;
201 }
202 },
203 DARK_BEAST(new String[]{"Dark beast"}, 90, true, TaskDifficulty.HARD, new Position(2010, 4644), "Temple of Light dungeon") {
204 @Override
205 public boolean canAssign(Player player) {
206 return player.skills.getMaxLevel(Skill.SLAYER) >= 90;
207 }
208 },
209 KRAKEN(new String[]{"Kraken"}, 87, true, TaskDifficulty.BOSS, new Position(2276, 10000, 0), "Kraken cave") {
210 @Override
211 public boolean canAssign(Player player) {
212 return player.skills.getMaxLevel(Skill.SLAYER) >= getLevel();
213 }
214 },
215 KING_BLACK_DRAGON(new String[]{"King black dragon"}, 1, false, TaskDifficulty.BOSS, new Position(3000, 3849), "Wilderness") {
216 @Override
217 public boolean canAssign(Player player) {
218 return player.slayer.getUnlocked().contains(SlayerUnlockable.KING_BLACK_DRAGON);
219 }
220 },
221 ZULRAH(new String[]{"Zulrah"}, 95, false, TaskDifficulty.BOSS, new Position(2206, 3056, 0), "Zulrah's Shrine") {
222 @Override
223 public boolean canAssign(Player player) {
224 return player.slayer.getUnlocked().contains(SlayerUnlockable.ZULRAH);
225 }
226 },
227 CERBERUS(new String[]{"Cerberus"}, 91, true, TaskDifficulty.BOSS, new Position(1310, 1268, 0), "Cerberus' Lair") {
228 public boolean canAssign(Player player) {
229 return player.skills.getMaxLevel(Skill.SLAYER) >= 91;
230 }
231 };
232
233 /** The slayer level required to receive the task. */
234 private final int level;
235
236 private final boolean levelNeeded;
237
238 /** The difficulty of the task. */
240
241 /** The teleport position for the task. */
242 private final Position position;
243
244 /** The string for the position. */
245 private final String location;
246
247 /** Array of the slayer npc. */
248 private final String[] npc;
249
250 /** Constructs a new <code>SlayerTask<code>. */
252 this.level = level;
253 this.levelNeeded = levelNeeded;
254 this.difficulty = difficulty;
255 this.position = position;
256 this.location = location;
257 this.npc = npc;
258 }
259
260 /** Gets the name of the task. */
261 public String getName() {
262 return npc[0];
263 }
264
265 /** Gets the level of the task. */
266 public int getLevel() {
267 return level;
268 }
269
270 public boolean isLevelNeeded() {
271 return levelNeeded;
272 }
273
274 /** Gets the difficulty of the slayer task. */
276 return difficulty;
277 }
278
279 /** Gets the position of the task. */
281 return position;
282 }
283
284 /** Gets the teleport string. */
285 public String getLocation() {
286 return location;
287 }
288
289 /** Gets the npcs of the task. */
290 public String[] getNpc() {
291 return npc;
292 }
293
294 /** Gets the combat level of the npc. */
295 public String getCombatLevel() {
297 }
298
299 /** Checks if the npc is a slayer task assignment. */
300 public boolean valid(String name) {
301 for (String npc : npc) {
302 if (npc.equalsIgnoreCase(name))
303 return true;
304 }
305 return false;
306 }
307
308 /** Checks if a player can attack a slayer monster. */
309 public static boolean canAttack(Player player, String npc) {
310 for (SlayerTask task : values()) {
311 for (String name : task.getNpc()) {
312 if (npc.equalsIgnoreCase(name) && task.isLevelNeeded() && player.skills.getLevel(Skill.SLAYER) < task.getLevel()) {
313 return false;
314 }
315 }
316 }
317 return true;
318 }
319
320 /** Assigns a slayer task for the player. */
322 ArrayList<SlayerTask> tasks = asList(player, difficulty);
323
324 if (tasks.isEmpty()) {
325 return null;
326 }
327
328 return Utility.randomElement(tasks);
329 }
330
331 /** Returns all the available slayer tasks for the player as a list. */
332 public static ArrayList<SlayerTask> asList(Player player, TaskDifficulty difficulty) {
333 ArrayList<SlayerTask> tasks = new ArrayList<>();
334 for (SlayerTask task : values()) {
335 if (task.getLevel() > player.skills.getLevel(Skill.SLAYER))
336 continue;
337 if (!task.canAssign(player))
338 continue;
339 if (player.slayer.getBlocked().contains(task))
340 continue;
341 if (task.difficulty != difficulty)
342 continue;
343 tasks.add(task);
344 }
345 return tasks;
346 }
347
349 switch (difficulty) {
350 case EASY:
351 return 15;
352 case MEDIUM:
353 return 20;
354 case HARD:
355 return 30;
356 case BOSS:
357 return 35;
358 }
359 return 0;
360 }
361
363 switch (difficulty) {
364 case EASY:
365 return 5000;
366 case MEDIUM:
367 return 10000;
368 case HARD:
369 return 15000;
370 case BOSS:
371 return 25000;
372 }
373 return 0;
374 }
375}
376
377interface TaskInterface<T> {
378 boolean canAssign(final T player);
379}
Set< SlayerUnlockable > getUnlocked()
Definition Slayer.java:359
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 SLAYER
The slayer skill id.
Definition Skill.java:75
int getLevel(int id)
Gets the level of a skill.
int getMaxLevel(int id)
Gets the highest possible level of a skill.
Represents a single tile on the game world.
Definition Position.java:14
Handles miscellaneous methods.
Definition Utility.java:27
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
Definition Utility.java:248
final int level
The slayer level required to receive the task.
String getCombatLevel()
Gets the combat level of the npc.
final Position position
The teleport position for the task.
TaskDifficulty difficulty
The difficulty of the task.
String getName()
Gets the name of the task.
static boolean canAttack(Player player, String npc)
Checks if a player can attack a slayer monster.
String getLocation()
Gets the teleport string.
static ArrayList< SlayerTask > asList(Player player, TaskDifficulty difficulty)
Returns all the available slayer tasks for the player as a list.
static int getPoints(TaskDifficulty difficulty)
Position getPosition()
Gets the position of the task.
String[] getNpc()
Gets the npcs of the task.
final String location
The string for the position.
TaskDifficulty getDifficulty()
Gets the difficulty of the slayer task.
boolean valid(String name)
Checks if the npc is a slayer task assignment.
int getLevel()
Gets the level of the task.
SlayerTask(String[] npc, int level, boolean levelNeeded, TaskDifficulty difficulty, Position position, String location)
Constructs a new SlayerTask.
final String[] npc
Array of the slayer npc.
static SlayerTask assign(Player player, TaskDifficulty difficulty)
Assigns a slayer task for the player.
static int getCompletionExperience(TaskDifficulty difficulty)
Holds all the unlockable slayer rewards and tasks.