RuneHive-Game
Loading...
Searching...
No Matches
BirdsNest.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.woodcutting;
2
3import com.runehive.content.prestige.PrestigePerk;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.items.Item;
6import com.runehive.game.world.items.ground.GroundItem;
7import com.runehive.net.packet.out.SendMessage;
8import com.runehive.util.MessageColor;
9import com.runehive.util.RandomUtils;
10import com.runehive.util.Utility;
11
12/**
13 * Handles dropping & searching birds nest which are obtained from woodcutting.
14 *
15 * @author Daniel
16 */
17public class BirdsNest {
18
19 /** Identification of all bird nest items. */
20 private static final int[] BIRD_NEST = {5070, 5071, 5072, 5073, 5074};
21
22 /** Identification of all seeds obtainable from birds nest. */
23 private static final int[] SEED_REWARD = {5312, 5313, 5314, 5315, 5316, 5283, 5284, 5285, 5286, 5287, 5288, 5289, 5290, 5317};
24
25 /** Identification of all rings obtainable from birds nest. */
26 private static final int[] RING_REWARD = {1635, 1637, 1639, 1641, 1643};
27
28 /** Handles dropping the birds nest. */
29 public static void drop(Player player) {
30 int chance = player.prestige.hasPerk(PrestigePerk.LITTLE_BIRDY) ? 10 : 5;
31 if (Utility.random(1, 200) < chance) {
32 Item item = new Item(Utility.randomElement(BIRD_NEST), 1);
33 GroundItem.create(player, item);
34 player.send(new SendMessage("A bird's nest falls out of the tree.", MessageColor.RED));
35 }
36 }
37
38 /** Handles searching a birds nest. */
39 public static void search(Player player, int item) {
40 if (player.inventory.remaining() == 0) {
41 player.send(new SendMessage("You do not have enough inventory space to do this."));
42 return;
43 }
44 int reward = 0;
45 if (item == 5074)
47 else if (item == 5073)
49 else if (item == 5070)
50 reward = 5076;
51 else if (item == 5071)
52 reward = 5077;
53 else if (item == 5072)
54 reward = 5078;
55 Item rewardItem = new Item(reward, 1);
56 String name = rewardItem.getName();
57 player.send(new SendMessage("You search the nest... and find " + Utility.getAOrAn(name) + " " + name + "."));
58 player.inventory.replace(item, 5075, true);
59 player.inventory.add(rewardItem);
60 }
61}
boolean hasPerk(PrestigePerk perk)
Handles dropping & searching birds nest which are obtained from woodcutting.
static void drop(Player player)
Handles dropping the birds nest.
static final int[] BIRD_NEST
Identification of all bird nest items.
static final int[] SEED_REWARD
Identification of all seeds obtainable from birds nest.
static final int[] RING_REWARD
Identification of all rings obtainable from birds nest.
static void search(Player player, int item)
Handles searching a birds nest.
This class represents a character controlled by a player.
Definition Player.java:125
The container class that represents an item that can be interacted with.
Definition Item.java:21
boolean add(Item item)
Attempts to deposit item into this container.
final boolean replace(int oldId, int newId, int index, boolean refresh)
Replaces the first occurrence of the Item having the identifier oldId with newId.
Represents a single Ground item on the world map.
static GroundItem create(Player player, Item item)
Creates a new GroundItem object for a player and an item.
The OutgoingPacket that sends a message to a Players chatbox in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static int random(int bound)
Definition Utility.java:239
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
Definition Utility.java:248
static String getAOrAn(String nextWord)
A or an.
Definition Utility.java:116
Handles the perk rewards from prestiging.
Holds an enum of colors for ease.