RuneHive-Game
Loading...
Searching...
No Matches
SlayerTab.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.slayer;
2
3import com.runehive.game.world.entity.mob.player.Player;
4import com.runehive.game.world.items.Item;
5import com.runehive.net.packet.out.*;
6import com.runehive.util.Utility;
7
8import java.util.Arrays;
9import java.util.List;
10
11/**
12 * Enum for the slayer tab.
13 *
14 * @author Daniel
15 */
16public enum SlayerTab {
17 /** The main itemcontainer - all the general information. */
18 MAIN(46700),
19
20 /** The duo itemcontainer - all the duo information. */
21 DUO(46800),
22
23 /** The unlock itemcontainer - holds all the unlockable perks. */
24 UNLOCK(46900),
25
26 /** The reward itemcontainer - holds all the rewards for slayer points. */
27 REWARD(46500),
28
29 /** The tasks itemcontainer - displays all the available task for player. */
30 TASK(46300),
31
32 /** The confirm itemcontainer - keeps player confirmation on purchase. */
33 CONFIRM(46400);
34
35 /** The itemcontainer identification. */
36 private final int identification;
37
38 /** Constructs a new <code>SlayerTab<code>. */
40 this.identification = identification;
41 }
42
43 /** Gets the itemcontainer identification. */
44 public int getIdentification() {
45 return identification;
46 }
47
48 /** Refreshes the tab itemcontainer. */
49 public static void refresh(Player player, SlayerTab tab) {
50 if (tab == null) {
51 return;
52 }
53
54 SlayerTask task = player.slayer.getTask();
55 switch (tab) {
56
57 case MAIN:
58 setFrame(player, 0);
59// player.send(new SendNpcDisplay(task == null ? 2044 : task.getNpc()[0], task == null ? 300 : task.getSize()));
60 player.send(new SendString(task == null ? "" : "</col>Name: <col=ffffff>" + task.getName(), 46716));
61 player.send(new SendString(task == null ? "" : "</col>Level: <col=ffffff>" + task.getCombatLevel(), 46717));
62 player.send(new SendString(task == null ? "You do not have a task assigned!" : "</col>Assigned: <col=ffffff>" + player.slayer.getAssigned(), 46718));
63 player.send(new SendString(task == null ? "" : "</col>Remaining: <col=ffffff>" + player.slayer.getAmount(), 46735));
64 player.send(new SendString(task == null ? "" : "</col>Position: <col=ffffff>" + task.getLocation(), 46736));
65 player.send(new SendString("Tasks assigned:\\n<col=ffffff>" + player.slayer.getTotalAssigned(), 46737));
66 player.send(new SendString("Tasks completed:\\n<col=ffffff>" + player.slayer.getTotalCompleted(), 46738));
67 player.send(new SendString("Tasks Cancelled:\\n<col=ffffff>" + player.slayer.getTotalCancelled(), 46739));
68 player.send(new SendString("Accumulated points:\\n<col=ffffff>" + player.slayer.getTotalPoints(), 46740));
69
70 for (int index = 0, string = 46753; index < 5; index++, string += 3) {
71 player.send(new SendTooltip("", string - 1));
72 player.send(new SendString("", string));
73 }
74
75 for (int index = 0, string = 46753; index < player.slayer.getBlocked().size(); index++, string += 3) {
76 String name = player.slayer.getBlocked().get(index).getName();
77 player.send(new SendTooltip("Unblock <col=FF981F>" + name + "</col>", string - 1));
78 player.send(new SendString(name, string));
79 }
80
81 player.send(new SendString(Utility.formatDigits(player.slayer.getPoints()) + "\\nPoints", 46714));
82 player.send(new SendString("Blocked tasks: (" + player.slayer.getBlocked().size() + "/5)", 46728));
83 break;
84
85 case DUO:
86 setFrame(player, 1);
87 player.send(new SendString("Current slayer partner: None!", 46811));
88 break;
89
90 case UNLOCK:
91 setFrame(player, 2);
92 int string = 46911;
93 for (SlayerUnlockable unlockable : SlayerUnlockable.values()) {
94 player.send(new SendTooltip("Purchase <col=FF981F>" + unlockable.getName() + "</col>", string));
95 string++;
96 player.send(new SendString(unlockable.getName(), string));
97 string++;
98 player.send(new SendString(unlockable.getDescription(), string));
99 string++;
100 player.send(new SendString(unlockable.getCost() + " points", string));
101 string++;
102 player.send(new SendConfig(560 + unlockable.ordinal(), player.slayer.getUnlocked().contains(unlockable) ? 0 : 1));
103 string++;
104 player.send(new SendItemOnInterfaceSlot(string, new Item(unlockable.getItem(), 1), 0));
105 string++;
106 }
107 player.send(new SendScrollbar(46910, 310));
108 break;
109
110 case REWARD:
111 player.send(new SendItemOnInterface(46503, Slayer.ITEMS));
112 setFrame(player, 3);
113 break;
114
115 case CONFIRM:
116 SlayerUnlockable unlockable = player.attributes.get("SLAYER_CONFIRM_KEY", SlayerUnlockable.class);
117 player.send(new SendString(unlockable.getName(), 46403));
118 player.send(new SendString(unlockable.getDescription(), 46404));
119 player.send(new SendString("Pay " + Utility.formatDigits(unlockable.getCost()) + " points?", 46405));
120
121 Item[] items = new Item[3];
122 for (int index = 0; index < 3; index++) {
123 items[index] = new Item(unlockable.getItem());
124 items[index].setAmount(0);
125 }
126
127 player.send(new SendItemOnInterface(46414, items));
128 break;
129
130 case TASK:
131 List<SlayerTask> task_list;
132 task_list = Arrays.asList(SlayerTask.values());
133 int line = 46321;
134
135 for (int index = 0; index < 35; index++) {
136 player.send(new SendString("", line + index));
137 }
138
139 for (SlayerTask tasks : task_list) {
140 line++;
141 player.send(new SendString(tasks.getName(), line));
142 line++;
143 player.send(new SendString(tasks.getCombatLevel(), line));
144 line++;
145 player.send(new SendString(tasks.getLevel(), line));
146 line++;
147 }
148
149 player.send(new SendScrollbar(46320, 400));
150 break;
151 }
152 }
153
154 /** Sets the tab frame. */
155 private static void setFrame(Player player, int index) {
156 player.send(new SendConfig(710, index));
157 player.send(new SendString("<col=" + (index == 0 ? "FF981F" : "ff9933") + ">Main", 46710));
158 player.send(new SendString("<col=" + (index == 1 ? "FF981F" : "ff9933") + ">Duo", 46711));
159 player.send(new SendString("<col=" + (index == 2 ? "FF981F" : "ff9933") + ">Unlocks", 46712));
160 player.send(new SendString("<col=" + (index == 3 ? "FF981F" : "ff9933") + ">Store", 46713));
161 }
162}
Set< SlayerUnlockable > getUnlocked()
Definition Slayer.java:359
final GenericAttributes attributes
Definition Mob.java:95
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 void setAmount(int amount)
Sets the quantity of this item.
Definition Item.java:351
The OutgoingPacket responsible for changing settings on a client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
Definition Utility.java:27
static String formatDigits(final int amount)
Formats digits for integers.
Definition Utility.java:41
public< K, E > E get(K key)
Gets a generic attribute.
MAIN
The main itemcontainer - all the general information.
UNLOCK
The unlock itemcontainer - holds all the unlockable perks.
int getIdentification()
Gets the itemcontainer identification.
REWARD
The reward itemcontainer - holds all the rewards for slayer points.
CONFIRM
The confirm itemcontainer - keeps player confirmation on purchase.
SlayerTab(int identification)
Constructs a new SlayerTab.
DUO
The duo itemcontainer - all the duo information.
static void refresh(Player player, SlayerTab tab)
Refreshes the tab itemcontainer.
final int identification
The itemcontainer identification.
static void setFrame(Player player, int index)
Sets the tab frame.
TASK
The tasks itemcontainer - displays all the available task for player.
String getCombatLevel()
Gets the combat level of the npc.
String getName()
Gets the name of the task.
String getLocation()
Gets the teleport string.
Holds all the unlockable slayer rewards and tasks.
String getDescription()
Gets the unlockable description.