RuneHive-Game
Loading...
Searching...
No Matches
RunecraftPouchData.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;
4
5/**
6 * Holds the runecrafting pouch data.
7 *
8 * @author Daniel
9 */
10public enum RunecraftPouchData {
11 SMALL_POUCH(5509, 1, 3, -1) {
12 @Override
13 public int deposit(Player player, int amount) {
14 if (player.smallPouch >= capacity) {
15 player.message("Your small pouch is already filled to it's capacity!");
16 return 0;
17 }
18
19 int essence = player.inventory.computeAmountForId(7936);
20
21 if (amount > essence)
22 amount = essence;
23
24 if (player.smallPouch + amount > capacity)
25 amount = capacity - player.smallPouch;
26
27 return player.smallPouch += amount;
28 }
29
30 @Override
31 public int withdraw(Player player) {
32 if (player.smallPouch == 0) {
33 player.message("You have no rune essences store in your small pouch!");
34 return 0;
35 }
36 if (player.inventory.getFreeSlots() < player.smallPouch){
37 player.message("Please free up some inventory spaces before doing this!");
38 return 0;
39 }
40 int amount = player.smallPouch;
41 empty(player);
42 return amount;
43 }
44
45 @Override
46 public void empty(Player player) {
47 player.smallPouch = 0;
48 }
49 },
50 MEDIUM_POUCH(5510, 25, 6, 9) {
51 public int deposit(Player player, int amount) {
52 if (player.mediumPouch >= capacity) {
53 player.message("Your medium pouch is already filled to it's capacity!");
54 return 0;
55 }
56
57 int essence = player.inventory.computeAmountForId(7936);
58
59 if (amount > essence)
60 amount = essence;
61
62 if (player.mediumPouch + amount > capacity)
63 amount = capacity - player.mediumPouch;
64
65 return player.mediumPouch += amount;
66 }
67
68 @Override
69 public int withdraw(Player player) {
70 if (player.mediumPouch == 0) {
71 player.message("You have no rune essences store in your medium pouch!");
72 return 0;
73 }
74 if (player.inventory.getFreeSlots() < player.mediumPouch){
75 player.message("Please free up some inventory spaces before doing this!");
76 return 0;
77 }
78 int amount = player.mediumPouch;
79 empty(player);
80 return amount;
81 }
82
83 @Override
84 public void empty(Player player) {
85 player.mediumPouch = 0;
86 }
87 },
88 LARGE_POUCH(5512, 50, 9, 18) {
89 public int deposit(Player player, int amount) {
90 if (player.largePouch >= capacity) {
91 player.message("Your large pouch is already filled to it's capacity!");
92 return 0;
93 }
94
95 int essence = player.inventory.computeAmountForId(7936);
96
97 if (amount > essence)
98 amount = essence;
99
100 if (player.largePouch + amount > capacity)
101 amount = capacity - player.largePouch;
102
103 return player.largePouch += amount;
104 }
105
106 @Override
107 public int withdraw(Player player) {
108 if (player.largePouch == 0) {
109 player.message("You have no rune essences store in your large pouch!");
110 return 0;
111 }
112 if (player.inventory.getFreeSlots() < player.largePouch){
113 player.message("Please free up some inventory spaces before doing this!");
114 return 0;
115 }
116 int amount = player.largePouch;
117 empty(player);
118 return amount;
119 }
120
121 @Override
122 public void empty(Player player) {
123 player.largePouch = 0;
124 }
125 },
126 GIANT_POUCH(5514, 75, 12, 50) {
127 public int deposit(Player player, int amount) {
128 if (player.giantPouch >= capacity) {
129 player.message("Your giant pouch is already filled to it's capacity!");
130 return 0;
131 }
132
133 int essence = player.inventory.computeAmountForId(7936);
134
135 if (amount > essence)
136 amount = essence;
137
138 if (player.giantPouch + amount > capacity)
139 amount = capacity - player.giantPouch;
140
141 return player.giantPouch += amount;
142 }
143
144 @Override
145 public int withdraw(Player player) {
146 if (player.giantPouch == 0) {
147 player.message("You have no rune essences store in your giant pouch!");
148 return 0;
149 }
150 if (player.inventory.getFreeSlots() < player.giantPouch){
151 player.message("Please free up some inventory spaces before doing this!");
152 return 0;
153 }
154 int amount = player.giantPouch;
155 empty(player);
156 return amount;
157 }
158
159 @Override
160 public void empty(Player player) {
161 player.giantPouch = 0;
162 }
163 };
164
165 /** The item identification of the runecrafting pouch. */
166 public final int item;
167
168 /** The level required to use the runecrafting pouch. */
169 public final int level;
170
171 /** The capacity that the runecrafting pouch can hold. */
172 public final int capacity;
173
174 /** The amount of uses before the runecrafting pouch will decay. */
175 public final int decay;
176
177 /** What happens to the runecrafting pouch when a player fills it. */
178 public abstract int deposit(Player player, int amount);
179
180 /** What happens to the runecrafting pouch when a player empties it. */
181 public abstract int withdraw(Player player);
182
183 /** Empties the runecrafting pouch. */
184 public abstract void empty(Player player);
185
186 /** Constructs a new <code>RunecraftPouchData</code>. */
188 this.item = item;
189 this.level = level;
190 this.capacity = capacity;
191 this.decay = decay;
192 }
193
194 /** Gets the runecrafting pouch data based on the item identification. */
195 public static RunecraftPouchData forItem(int item) {
196 for (RunecraftPouchData pouch : values()) {
197 if (pouch.item == item)
198 return pouch;
199 }
200 return null;
201 }
202}
This class represents a character controlled by a player.
Definition Player.java:125
final int computeAmountForId(int id)
Computes the total quantity of the Items in this container with id.
final int level
The level required to use the runecrafting pouch.
final int decay
The amount of uses before the runecrafting pouch will decay.
RunecraftPouchData(int item, int level, int capacity, int decay)
Constructs a new RunecraftPouchData.
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.
final int item
The item identification of the runecrafting pouch.