RuneHive-Game
Loading...
Searching...
No Matches
RunecraftPouch.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.runecrafting;
2
3import com.runehive.game.world.entity.mob.player.Player;
4import com.runehive.game.world.entity.skill.Skill;
5import com.runehive.game.world.items.Item;
6
7/**
8 * The runecraft pouch.
9 *
10 * @author Daniel
11 */
12public class RunecraftPouch {
13 /** The player instance. */
14 private final Player player;
15
16 /** Constructs a new <code>RunecraftPouch</code>. */
18 this.player = player;
19 }
20
21 /** Deposits essence into the player's runecraft pouch. */
22 public void deposit(RunecraftPouchData pouch) {
23 if (player.skills.getMaxLevel(Skill.RUNECRAFTING) < pouch.level) {
24 player.message("You need a runecrafting level of " + pouch.level + " to use this pouch!");
25 return;
26 }
27
28 int inventory = player.inventory.computeAmountForId(7936);
29
30 if (inventory == 0) {
31 player.message("You have no rune essences in your inventory to fill this pouch!");
32 return;
33 }
34
35 int essence = pouch.deposit(player, pouch.capacity);
36
37 System.out.println(essence);
38
39
40 if (essence != 0) {
41 player.inventory.remove(7936, essence);
42 player.message("You have filled your pouch with " + essence + " rune essences!");
43 }
44 }
45
46 /** Withdraws essence from the player's rune essence pouch. */
47 public void withdraw(RunecraftPouchData pouch) {
48 int essence = pouch.withdraw(player);
49
50 if (essence != 0) {
51 player.inventory.add(7936, essence);
52 player.message("You have emptied your pouch.");
53 }
54 }
55
56 /** Handles player dying with a rune pouch. */
57 public boolean death(Item item) {
59
60 if (pouch == null)
61 return false;
62
63 pouch.empty(player);
64 return true;
65 }
66}
boolean death(Item item)
Handles player dying with a rune pouch.
void deposit(RunecraftPouchData pouch)
Deposits essence into the player's runecraft pouch.
RunecraftPouch(Player player)
Constructs a new RunecraftPouch.
void withdraw(RunecraftPouchData pouch)
Withdraws essence from the player's rune essence pouch.
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 RUNECRAFTING
The runecrafting skill id.
Definition Skill.java:81
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
final int level
The level required to use the runecrafting pouch.
abstract int deposit(Player player, int amount)
What happens to the runecrafting pouch when a player fills it.
static RunecraftPouchData forItem(int item)
Gets the runecrafting pouch data based on the item identification.
abstract void empty(Player player)
Empties the runecrafting pouch.
abstract int withdraw(Player player)
What happens to the runecrafting pouch when a player empties it.
final int capacity
The capacity that the runecrafting pouch can hold.