RuneHive-Game
Loading...
Searching...
No Matches
BonesToBananas.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.Spellbook;
6import com.runehive.net.packet.out.SendMessage;
7import com.runehive.game.Animation;
8import com.runehive.game.Graphic;
9import com.runehive.game.world.entity.mob.player.Player;
10import com.runehive.content.skill.impl.magic.Magic;
11import com.runehive.content.skill.impl.magic.spell.Spell;
12import com.runehive.game.world.entity.skill.Skill;
13import com.runehive.game.world.items.Item;
14
15public class BonesToBananas implements Spell {
16
17 @Override
18 public String getName() {
19 return "Bones to bananas";
20 }
21
22 @Override
23 public Item[] getRunes() {
24 return new Item[] { new Item(557, 2), new Item(555, 2), new Item(561, 1) };
25 }
26
27 @Override
28 public int getLevel() {
29 return 15;
30 }
31
32 @Override
33 public void execute(Player player, Item item) {
34 if (player.spellbook != Spellbook.MODERN)
35 return;
36
37 int bone = 0;
38
39 for (final int bones : Magic.BONES) {
40 if (player.inventory.contains(bones)) {
41 bone = bones;
42 break;
43 }
44 }
45
46 if (bone == 0) {
47 player.send(new SendMessage("You have no bones to do this!"));
48 return;
49 }
50
51 final int amount = player.inventory.computeAmountForId(bone);
52
53 player.inventory.remove(bone, amount);
54 player.inventory.add(new Item(1963, amount), -1, true);
56 player.animate(new Animation(722));
57 player.graphic(new Graphic(141, true));
59 player.send(new SendMessage("You have converted " + amount + " bones to bananas."));
61 }
62}
The class that contains setting-related constants for the server.
Definition Config.java:24
static final double MAGIC_MODIFICATION
The experience modification for magic.
Definition Config.java:268
void execute(Player player, Item item)
Executes the magic spell.
int getLevel()
Gets the level required to cast 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
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 computeAmountForId(int id)
Computes the total quantity of the Items in this container with id.
boolean remove(Item item)
Attempts to withdraw item from this container.
boolean add(Item item)
Attempts to deposit item into this container.
boolean contains(int id)
Determines if this container contains id.
boolean removeAll(Collection<? extends Item > items)
Attempts to withdraw items in bulk from this container.
The OutgoingPacket that sends a message to a Players chatbox in the client.
The in-game spellbooks for players.
Definition Spellbook.java:8
The itemcontainer for casting a spell.
Definition Spell.java:11