RuneHive-Game
Loading...
Searching...
No Matches
LowAlchemy.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.activity.randomevent.RandomEventHandler;
5import com.runehive.content.skill.impl.magic.Magic;
6import com.runehive.content.skill.impl.magic.Spellbook;
7import com.runehive.content.skill.impl.magic.spell.Spell;
8import com.runehive.game.Animation;
9import com.runehive.game.Graphic;
10import com.runehive.game.world.entity.mob.player.Player;
11import com.runehive.game.world.entity.skill.Skill;
12import com.runehive.game.world.items.Item;
13import com.runehive.net.packet.out.SendForceTab;
14import com.runehive.net.packet.out.SendMessage;
15
16import java.util.Arrays;
17
18/**
19 * The high alchemy spell.
20 *
21 * @author Daniel
22 */
23public class LowAlchemy implements Spell {
24
25 @Override
26 public String getName() {
27 return "Low alchemy";
28 }
29
30 @Override
31 public int getLevel() {
32 return 21;
33 }
34
35 @Override
36 public Item[] getRunes() {
37 return new Item[] { new Item(554, 3), new Item(561, 1) };
38 }
39
40 @Override
41 public void execute(Player player, Item item) {
42 if (player.spellbook != Spellbook.MODERN)
43 return;
44
45 if (!player.spellCasting.castingDelay.elapsed(500)) {
46 return;
47 }
48
49 if (Arrays.stream(Magic.UNALCHEABLES).anyMatch($it -> item.getId() == $it.getId())) {
50 player.send(new SendMessage("You can not alch this item!"));
51 return;
52 }
53
54 int value = item.getLowAlch();
55
56 if (value > 150_000) {
57 player.send(new SendMessage("The value of this item is too high and can not be low-alched."));
58 return;
59 }
60
61 player.animate(new Animation(712));
62 player.graphic(new Graphic(112, true));
63 player.inventory.remove(item.getId(), 1);
65 player.inventory.refresh();
66 player.send(new SendForceTab(6));
67 player.inventory.add(Config.CURRENCY, value == 0 ? 1 : value);
72 }
73}
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
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