RuneHive-Game
Loading...
Searching...
No Matches
HighAlchemy.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.magic.spell.impl;
2
3import com.runehive.Config;
4import com.runehive.content.achievement.AchievementHandler;
5import com.runehive.content.achievement.AchievementKey;
6import com.runehive.content.activity.randomevent.RandomEventHandler;
7import com.runehive.content.skill.impl.magic.Magic;
8import com.runehive.content.skill.impl.magic.Spellbook;
9import com.runehive.content.skill.impl.magic.spell.Spell;
10import com.runehive.game.Animation;
11import com.runehive.game.Graphic;
12import com.runehive.game.world.entity.mob.player.Player;
13import com.runehive.game.world.entity.skill.Skill;
14import com.runehive.game.world.items.Item;
15import com.runehive.net.packet.out.SendForceTab;
16import com.runehive.net.packet.out.SendMessage;
17
18import java.util.Arrays;
19
20/**
21 * The high alchemy spell.
22 *
23 * @author Daniel
24 */
25public class HighAlchemy implements Spell {
26
27 @Override
28 public String getName() {
29 return "High alchemy";
30 }
31
32 @Override
33 public int getLevel() {
34 return 55;
35 }
36
37 @Override
38 public Item[] getRunes() {
39 return new Item[] { new Item(554, 5), new Item(561, 1) };
40 }
41
42 @Override
43 public void execute(Player player, Item item) {
44 if (player.spellbook != Spellbook.MODERN)
45 return;
46
47 if (!player.spellCasting.castingDelay.elapsed(500)) {
48 return;
49 }
50
51 if (Arrays.stream(Magic.UNALCHEABLES).anyMatch($it -> item.getId() == $it.getId())) {
52 player.send(new SendMessage("You can not alch this item!"));
53 return;
54 }
55
56 int value = item.getHighAlch();
57
58 player.animate(new Animation(713));
59 player.graphic(new Graphic(113, true));
60 player.inventory.remove(item.getId(), 1);
62 player.inventory.add(Config.CURRENCY, value == 0 ? 1 : value);
63 player.inventory.refresh();
64 player.send(new SendForceTab(6));
70 }
71}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final int CURRENCY
The currency identification of the server.
Definition Config.java:175
static final double MAGIC_MODIFICATION
The experience modification for magic.
Definition Config.java:268
static void activate(Player player, AchievementKey achievement)
Activates the achievement for the individual player.
int getLevel()
Gets the level required to cast spell.
void execute(Player player, Item item)
Executes the magic spell.
Item[] getRunes()
Gets the runes required to cast the spell.
Class that models a single animation used by an entity.
Represents a single graphic that can be used by entities.
Definition Graphic.java:10
void clearNonWalkableActions()
Purges actions in the queue with a WalkablePolicy of NON_WALKABLE.
Optional< Graphic > graphic
Definition Mob.java:91
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 MAGIC
The magic skill id.
Definition Skill.java:39
void addExperience(int id, double experience)
Adds experience to a given skill.
The container class that represents an item that can be interacted with.
Definition Item.java:21
final int getId()
Gets the identification of this item.
Definition Item.java:324
boolean remove(Item item)
Attempts to withdraw item from this container.
boolean add(Item item)
Attempts to deposit item into this container.
boolean removeAll(Collection<? extends Item > items)
Attempts to withdraw items in bulk from this container.
void refresh()
Refreshes the players inventory.
The OutgoingPacket that sends a message to a Players chatbox in the client.
boolean elapsed(long time, TimeUnit unit)
The in-game spellbooks for players.
Definition Spellbook.java:8
The itemcontainer for casting a spell.
Definition Spell.java:11