RuneHive-Game
Loading...
Searching...
No Matches
ClanShowcaseBox.java
Go to the documentation of this file.
1package com.runehive.content.itemaction.impl;
2
3import com.runehive.content.clanchannel.ClanUtility;
4import com.runehive.content.clanchannel.channel.ClanChannel;
5import com.runehive.content.clanchannel.content.ClanLevel;
6import com.runehive.content.itemaction.ItemAction;
7import com.runehive.game.world.entity.mob.player.Player;
8import com.runehive.game.world.items.Item;
9import com.runehive.net.packet.out.SendMessage;
10import com.runehive.util.Utility;
11
12import java.util.ArrayList;
13import java.util.List;
14
15public class ClanShowcaseBox extends ItemAction {
16
17 @Override
18 public String name() {
19 return "Clan Showcase Box";
20 }
21
22 @Override
23 public boolean inventory(Player player, Item item, int opcode) {
24 if (opcode != 1) {
25 return false;
26 }
27 ClanChannel channel = player.clanChannel;
28 if (channel == null) {
29 player.send(new SendMessage("You need to be in a clan to do this!"));
30 return true;
31 }
32 if (channel.getShowcase().showcaseItems.size() >= 28) {
33 player.send(new SendMessage("You have reached the maximum capacity of showcase items you can hold. Please delete an item to proceed."));
34 return true;
35 }
36 ClanLevel level = channel.getDetails().level;
37 List<Item> items = new ArrayList<>();
38
39 for (int reward : ClanUtility.getRewardItems(level)) {
40 Item rewardItem = new Item(reward, 1);
41 for (Item showcase : channel.getShowcaseItems()) {
42 if (rewardItem.getId() != showcase.getId())
43 items.add(rewardItem);
44 }
45 }
46
47 if (items.isEmpty()) {
48 return true;
49 }
50
51 Item showcaseReward = Utility.randomElement(items);
52 player.inventory.remove(item);
53 channel.getShowcase().showcaseItems.add(showcaseReward.getId());
54 channel.message("We just received " + showcaseReward.getName() + " from the showcase box!");
55 return true;
56 }
57}
This class holds all the util methods for the clan channel system.
static int[] getRewardItems(ClanLevel level)
Gets the rewards based on the clan level.
void message(Object... messages)
Handles messaging all the members in the clan channel.
Handles executing an item action.
boolean inventory(Player player, Item item, int opcode)
The execution method of the action.
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
boolean remove(Item item)
Attempts to withdraw item from this container.
The OutgoingPacket that sends a message to a Players chatbox in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
Definition Utility.java:248
Handles the clan levels (based off the total experience earned).
Definition ClanLevel.java:8