RuneHive-Game
Loading...
Searching...
No Matches
MysteryBoxManager.java
Go to the documentation of this file.
1package com.runehive.content.mysterybox;
2
3import com.runehive.game.world.World;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.entity.mob.player.PlayerRight;
6import com.runehive.game.world.items.Item;
7import com.runehive.game.world.position.Area;
8import com.runehive.net.packet.out.*;
9
10import java.util.Optional;
11
12public class MysteryBoxManager {
13 private final Player player;
14 int count;
16
18 this.player = player;
19 }
20
21 public boolean click(Item item) {
22 Optional<MysteryBox> mBox = MysteryBox.getMysteryBox(item.getId());
23
24 if (!mBox.isPresent()) {
25 return false;
26 }
27
29 player.dialogueFactory.sendStatement("You can not open a mystery box while in the wilderness!").execute();
30 return true;
31 }
32
33 if (player.getCombat().inCombat()) {
34 player.dialogueFactory.sendStatement("You can not open a mystery box while in combat!").execute();
35 return true;
36 }
37
38 if (player.playerAssistant.busy() && !player.interfaceManager.isInterfaceOpen(59500)) {
39 player.dialogueFactory.sendStatement("You can not open a mystery box right now!").execute();
40 return true;
41 }
42 box = mBox.get();
43 count = player.inventory.computeAmountForId(item.getId());
44
45 spin();
46 /* for (int index = 0; index < 11; index++) {
47 player.send(new SendConfig((430 + index), 1));
48 }
49 player.send(new SendItemOnInterface(59581, mBox.get().rewards()));
50 player.send(new SendScrollbar(59580, mBox.get().rewards().length * 5));
51 player.send(new SendItemOnInterface(59512));
52 player.send(new SendColor(59508, 0x37991C));
53 player.send(new SendString(mBox.get().name(), 59503));
54 player.send(new SendString("You have " + count + " available!", 59507));
55 player.interfaceManager.open(59500);*/
56 return true;
57 }
58
59 public void spin() {
60 if (box == null) {
61 player.interfaceManager.close();
62 return;
63 }
64 if (count == 0) {
65 player.dialogueFactory.sendStatement("You do not have any " + box.name() + "!", "To spin a different mystery box level click on the item first!").execute();
66 return;
67 }
69 }
70}
static Optional< MysteryBox > getMysteryBox(int item)
Handles getting the mystery box.
Represents the game world.
Definition World.java:46
static void schedule(Task task)
Submits a new event.
Definition World.java:247
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
final int getId()
Gets the identification of this item.
Definition Item.java:324
Handles checking if mobs are in a certain area.
Definition Area.java:13
static boolean inWilderness(Position position)
Definition Area.java:272