RuneHive-Game
Loading...
Searching...
No Matches
CrystalChest.java
Go to the documentation of this file.
1package com.runehive.content;
2
3import com.runehive.game.world.entity.mob.player.Player;
4import com.runehive.game.world.items.Item;
5import com.runehive.util.chance.Chance;
6import com.runehive.util.chance.WeightedChance;
7
8import java.util.Arrays;
9
10/**
11 * Handles opening the crystal chest.
12 *
13 * @author Daniel
14 */
15public class CrystalChest {
16
17 /** The two item key halves. */
18 public static final Item[] KEY_HALVES = {new Item(985), new Item(987)};
19
20 /** The item key to enter the crystal chest. */
21 public static final Item KEY = new Item(989);
22
23 /** Handles creating a key. */
24 public static void createKey(Player player) {
25 if (player.inventory.containsAll(KEY_HALVES)) {
26 player.inventory.remove(KEY_HALVES[0]);
27 player.inventory.remove(KEY_HALVES[1]);
28 player.inventory.add(KEY);
29 player.dialogueFactory.sendItem("Crystal Key", "You have combined the two parts to form a key.", KEY.getId()).execute();
30 }
31 }
32
33 /** Handles getting an item reward from the chest. */
34 public static Item getReward() {
35 return ITEMS.next();
36 }
37
38 /** Holds all the crystal chest rewards. */
39 private static final Chance<Item> ITEMS = new Chance<>(Arrays.asList(
40 new WeightedChance<>(8, new Item(1163, 1)), // RUNE_FULL_HELM
41 new WeightedChance<>(6, new Item(1147, 1)), // RUNE_MED_HELM
42 new WeightedChance<>(6, new Item(1127, 1)), // RUNE_PLATEBODY
43 new WeightedChance<>(6, new Item(1093, 1)), // RUNE_PLATESKIRT
44 new WeightedChance<>(6, new Item(1201, 1)), // RUNE_KITESHIELD
45 new WeightedChance<>(6, new Item(1185, 1)), // RUNE_SQ_SHIELD
46 new WeightedChance<>(6, new Item(1333, 1)), // RUNE_SCIMITAR
47 new WeightedChance<>(6, new Item(1079, 1)), // RUNE_PLATELEGS
48 new WeightedChance<>(5, new Item(10828, 1)), // HELM_OF_NEITZ
49 new WeightedChance<>(5, new Item(1632, 1)), // UNCUT_DAGONSTONE
50 new WeightedChance<>(5, new Item(4099, 1)), // MYSTIC_HAT
51 new WeightedChance<>(5, new Item(4089, 1)), // MYSTIC_HAT
52 new WeightedChance<>(5, new Item(4109, 1)), // MYSTIC_HAT
53 new WeightedChance<>(5, new Item(4101, 1)), // MYSTIC_TOP
54 new WeightedChance<>(5, new Item(4091, 1)), // MYSTIC_TOP
55 new WeightedChance<>(5, new Item(4111, 1)), // MYSTIC_TOP
56 new WeightedChance<>(5, new Item(4103, 1)), // MYSTIC_BOTTOM
57 new WeightedChance<>(5, new Item(4093, 1)), // MYSTIC_BOTTOM
58 new WeightedChance<>(5, new Item(4113, 1)), // MYSTIC_BOTTOM
59 new WeightedChance<>(4, new Item(995, 35000)), // COINS
60 new WeightedChance<>(3.5, new Item(13307, 350)), // BLOOD_MONEY
61 new WeightedChance<>(3.5, new Item(4153, 1)), // GRANITE_MAUL
62 new WeightedChance<>(3.5, new Item(10589, 1)), // GRANITE_HELM
63 new WeightedChance<>(3.5, new Item(10564, 1)), // GRANITE_BODY
64 new WeightedChance<>(3.5, new Item(6809, 1)), // GRANITE_LEGS
65 new WeightedChance<>(3.5, new Item(21643, 1)), // GRANITE_BOOTS
66 new WeightedChance<>(3.5, new Item(21646, 1)), // GRANITE_LONGSWORD
67 new WeightedChance<>(3, new Item(1149, 1)), // DRAGON_MED_HELM
68 new WeightedChance<>(3, new Item(1187, 1)), // DRAGON_SQ_SHIELD
69 new WeightedChance<>(3, new Item(1215, 1)), // DRAGON_DAGGER
70 new WeightedChance<>(3, new Item(4587, 1)), // DRAGON_SCIMITAR
71 new WeightedChance<>(3, new Item(4087, 1)), // DRAGON_PLATELEGS
72 new WeightedChance<>(3, new Item(1434, 1)), // DRAGON_MACE
73 new WeightedChance<>(3, new Item(4585, 1)), // DRAGON_PLATESKIRT
74 new WeightedChance<>(3, new Item(3204, 1)), // DRAGON_HALBERD
75 new WeightedChance<>(3, new Item(1249, 1)), // DRAGON_SPEAR
76 new WeightedChance<>(3, new Item(1305, 1)), // DRAGON_LONGSWORD
77 new WeightedChance<>(3, new Item(1377, 1)), // DRAGON_BATTLEAXE
78 new WeightedChance<>(2, new Item(7158, 1)), // DRAGON_2H_SWORD
79 new WeightedChance<>(1.5, new Item(6199, 1)), // BRONZE_MYSTERY_BOX
80 new WeightedChance<>(1, new Item(11840, 1)), // DRAGON_BOOTS
81 new WeightedChance<>(5, new Item(13307, 1500)), // BLOOD_MONEY
82 new WeightedChance<>(0.5, new Item(6571, 1)) // UNCUT_ONYX
83 ));
84}
Handles opening the crystal chest.
static void createKey(Player player)
Handles creating a key.
static final Item[] KEY_HALVES
The two item key halves.
static final Item KEY
The item key to enter the crystal chest.
static final Chance< Item > ITEMS
Holds all the crystal chest rewards.
static Item getReward()
Handles getting an item reward from the chest.
final DialogueFactory execute()
Retrieves the next dialogue in the chain and executes it.
final DialogueFactory sendItem(String title, String text, Item item)
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 remove(Item item)
Attempts to withdraw item from this container.
boolean add(Item item)
Attempts to deposit item into this container.
final boolean containsAll(int... identifiers)
Determines if this container contains all identifiers.
Handles a random chance.
Definition Chance.java:14