1package com.runehive.content.mysterybox;
3import com.runehive.game.task.TickableTask;
4import com.runehive.game.world.World;
5import com.runehive.game.world.entity.mob.player.Player;
6import com.runehive.net.packet.out.SendColor;
7import com.runehive.net.packet.out.SendString;
8import com.runehive.util.Utility;
15 private List<MysteryItem>
items;
24 this.items =
new ArrayList<>();
25 this.allItems =
new ArrayList<>();
27 this.mysteryBox =
player.mysteryBox;
41 if (!
items.contains(item)) {
67 double randomValue = Math.random();
68 double cumulativeProbability = 0.0;
71 Collections.sort(
items, Comparator.comparingDouble(this::getItemProbability).reversed());
75 cumulativeProbability += itemProbability;
76 if (randomValue <= cumulativeProbability) {
91 player.message(
"Congratulations! You have won @red@" +
Utility.
getAOrAn(
reward.getName()) +
" " +
reward.getName() +
"!\nThis item falls in the rarity of " +
reward.rarity.name().toLowerCase() +
".");
92 System.out.println(
"Rarity: " +
reward.rarity.name().toLowerCase());
96 return player.mysteryBox.box !=
null;
100 player.dialogueFactory.clear();
104 mysteryBox.count =
player.inventory.computeAmountForId(
mysteryBox.box.item());
106 for (
int index = 0; index < 11; index++) {
MysteryItem getNextItem()
boolean canSchedule()
A function executed on registration.
void onCancel(boolean logout)
A function executed on cancellation.
List< MysteryItem > items
void onSchedule()
A function executed on registration.
List< MysteryItem > allItems
final MysteryBoxManager mysteryBox
double getItemProbability(MysteryItem item)
MysteryBoxEvent(Player player)
final MysteryRarity rarity
synchronized final void cancel()
Cancels all subsequent executions.
TickableTask(boolean instant, int delay)
Represents the game world.
static void sendMessage(String... messages)
Sends a global message.
This class represents a character controlled by a player.
The OutgoingPacket that sends a color to a string in the client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
static int random(int bound)
static String getAOrAn(String nextWord)
A or an.
Created by Daniel on 2018-02-03.