RuneHive-Game
Loading...
Searching...
No Matches
MysteryBox.java
Go to the documentation of this file.
1package com.runehive.content.mysterybox;
2
3import com.runehive.content.mysterybox.impl.BronzeMysteryBox;
4import com.runehive.content.mysterybox.impl.GoldMysteryBox;
5import com.runehive.content.mysterybox.impl.PetMysteryBox;
6import com.runehive.content.mysterybox.impl.SilverMysteryBox;
7
8import java.util.HashMap;
9import java.util.Map;
10import java.util.Optional;
11
12/**
13 * The mystery box class.
14 *
15 * @author Daniel
16 */
17public abstract class MysteryBox {
18
19 /** The map containing all the mystery boxes. */
20 private static Map<Integer, MysteryBox> MYSTERY_BOXES = new HashMap<>();
21
22 /** Handles loading the mystery boxes. */
23 public static void load() {
24 MysteryBox BRONZE_BOX = new BronzeMysteryBox();
25 MysteryBox SILVER_BOX = new SilverMysteryBox();
26 MysteryBox GOLD_BOX = new GoldMysteryBox();
27 MysteryBox PET_BOX = new PetMysteryBox();
28
29 MYSTERY_BOXES.put(BRONZE_BOX.item(), BRONZE_BOX);
30 MYSTERY_BOXES.put(SILVER_BOX.item(), SILVER_BOX);
31 MYSTERY_BOXES.put(GOLD_BOX.item(), GOLD_BOX);
32 MYSTERY_BOXES.put(PET_BOX.item(), PET_BOX);
33 }
34
35 /** Handles getting the mystery box. */
36 static Optional<MysteryBox> getMysteryBox(int item) {
37 return MYSTERY_BOXES.containsKey(item) ? Optional.of(MYSTERY_BOXES.get(item)) : Optional.empty();
38 }
39
40 /** The name of the mystery box. */
41 protected abstract String name();
42
43 /** The item identification of the mystery box. */
44 protected abstract int item();
45
46 /** The rewards for the mystery box. */
47 protected abstract MysteryItem[] rewards();
48}
static Map< Integer, MysteryBox > MYSTERY_BOXES
The map containing all the mystery boxes.
abstract int item()
The item identification of the mystery box.
static void load()
Handles loading the mystery boxes.
static Optional< MysteryBox > getMysteryBox(int item)
Handles getting the mystery box.
abstract MysteryItem[] rewards()
The rewards for the mystery box.
abstract String name()
The name of the mystery box.