RuneHive-Game
Loading...
Searching...
No Matches
Prestige.java
Go to the documentation of this file.
1package com.runehive.content.prestige;
2
3import com.runehive.game.world.World;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.entity.skill.Skill;
6import com.runehive.game.world.items.Item;
7import com.runehive.net.packet.out.SendItemOnInterface;
8import com.runehive.net.packet.out.SendMessage;
9import com.runehive.net.packet.out.SendScrollbar;
10import com.runehive.net.packet.out.SendString;
11import com.runehive.util.MessageColor;
12
13import java.util.Arrays;
14import java.util.HashSet;
15import java.util.Set;
16
17import static com.runehive.game.world.items.containers.bank.VaultCurrency.COINS;
18
19/**
20 * Handles the prestige class.
21 *
22 * @author Daniel.
23 */
24public class Prestige {
25
26 /** The player instance. */
27 private final Player player;
28 private static final String COLOR = "<col=354CE6>";
29
30
31 /** The total amount of prestiges. */
32 public int totalPrestige;
33
34 /** The prestige points. */
35 private int prestigePoint;
36
37 /** The prestiges. */
38 public int[] prestige = new int[Skill.SKILL_COUNT];
39
40 /** The set of all the active perks for the player. */
41 public Set<PrestigePerk> activePerks = new HashSet<>();
42
43 /** Constructs a new <code>Prestige</code>. */
45 this.player = player;
46 }
47
48 /** Opens the prestige panel. */
49 public void open() {
50 player.send(new SendString(player.getName(), 52007));
51 player.send(new SendString("Total Prestiges: <col=76E34B>" + totalPrestige + "</col>", 52008));
52 player.send(new SendString("Prestige Points: <col=76E34B>" + prestigePoint + "</col>", 52009));
53 Arrays.stream(PrestigeData.values).forEach(p -> player.send(new SendString(p.name + " " + "(<col=" + getColorInterface(prestige[p.skill]) + ">" + prestige[p.skill] + "</col>)", p.string)));
54 player.interfaceManager.open(52000);
55 }
56
57 /** Handles prestiging the skill. */
58 public void prestige(PrestigeData data) {
59 prestige[data.skill]++;
60 totalPrestige += 1;
61 prestigePoint += 1;
62 player.skills.setExperience(data.skill, Skill.getExperienceForLevel(data.skill == 3 ? 10 : 1));
63 player.skills.setMaxLevel(data.skill, data.skill == 3 ? 10 : 1);
64 player.skills.setLevel(data.skill, data.skill == 3 ? 10 : 1);
65 player.skills.refresh(data.skill);
66 player.skills.setCombatLevel();
67 player.bankVault.add(COINS, 1_000_000);
68 player.send(new SendMessage("You have successfully prestiged your <col=255>" + Skill.getName(data.skill) + "</col> skill!"));
69 World.sendMessage( "<icon=21> Prestige: <col=354CE6>" + player.getName() + "</col> has prestiged " + Skill.getName(data.skill) + " and has a total of " + player.prestige.totalPrestige + " prestiges!");
70 open();
71 }
72
73 /** Displays all the perk information. */
74 public void perkInformation() {
75 final int totalPerks = PrestigePerk.values.length;
76 for (int i = 0, string = 37114; i < totalPerks; i++) {
78 player.send(new SendString("<col=" + (hasPerk(perk) ? "347043" : "3c50b2") + ">" + perk.name, string++));
79 player.send(new SendString(perk.description, string++));
80 player.send(new SendString("", string++));
81 }
82
83 player.send(new SendString("<col=000000>This is a list of all the available perks.", 37111));
84 player.send(new SendString("<col=000000>Perks with green names indicate that it is active.", 37112));
85 player.send(new SendString("", 37113));
86 player.send(new SendString("", 37107));
87 player.send(new SendString("Prestige Perks Information", 37103));
88 player.send(new SendScrollbar(37110, totalPerks * 65));
89 player.send(new SendItemOnInterface(37199));
90 player.interfaceManager.open(37100);
91 }
92
93 /** Activates the perk. */
94 public boolean activatePerk(Item item) {
96 if (perk == null) {
97 return false;
98 }
99 if (activePerks == null) {
100 activePerks = new HashSet<>();
101 }
102 if (activePerks.contains(perk)) {
103 player.send(new SendMessage("The Perk: " + perk.name + " perk is already active on your account!", MessageColor.DARK_BLUE));
104 return true;
105 }
106 player.inventory.remove(item);
107 activePerks.add(perk);
108 player.send(new SendMessage("You have successfully activated the " + perk.name + " perk.", MessageColor.DARK_BLUE));
109 return true;
110 }
111
112 public boolean hasPerk(PrestigePerk perk) {
113 return activePerks.contains(perk);
114 }
115
116 /** Gets the current prestige color of the player. */
117 public int getPrestigeColor(int skill) {
118 return getColor(prestige[skill]);
119 }
120
121 /** Gets the prestige color based on the tier. */
122 public int getColor(int tier) {
123 switch (tier) {
124 case 1:
125 return 0xf49242;
126 case 2:
127 return 0x42f468;
128 case 3:
129 return 0x42d1f4;
130 case 4:
131 return 0xa76ffc;
132 case 5:
133 return 0xf44949;
134 default:
135 return 0xFFFF00;
136 }
137 }
138
139 /** Gets the prestige color based on the tier for the itemcontainer. */
140 private String getColorInterface(int tier) {
141 return Integer.toHexString(getColor(tier));
142 }
143
144 public int getPrestigePoint() {
145 return prestigePoint;
146 }
147
149 this.prestigePoint = prestigePoint;
150 }
151}
void open()
Opens the prestige panel.
Definition Prestige.java:49
void perkInformation()
Displays all the perk information.
Definition Prestige.java:74
int totalPrestige
The total amount of prestiges.
Definition Prestige.java:32
boolean hasPerk(PrestigePerk perk)
int prestigePoint
The prestige points.
Definition Prestige.java:35
final Player player
The player instance.
Definition Prestige.java:27
boolean activatePerk(Item item)
Activates the perk.
Definition Prestige.java:94
void prestige(PrestigeData data)
Handles prestiging the skill.
Definition Prestige.java:58
String getColorInterface(int tier)
Gets the prestige color based on the tier for the itemcontainer.
int getColor(int tier)
Gets the prestige color based on the tier.
Prestige(Player player)
Constructs a new Prestige.
Definition Prestige.java:44
Set< PrestigePerk > activePerks
The set of all the active perks for the player.
Definition Prestige.java:41
void setPrestigePoint(int prestigePoint)
int getPrestigeColor(int skill)
Gets the current prestige color of the player.
Represents the game world.
Definition World.java:46
static void sendMessage(String... messages)
Sends a global message.
Definition World.java:396
This class represents a character controlled by a player.
Definition Player.java:125
Represents a trainable and usable skill.
Definition Skill.java:18
static String getName(int skill)
Gets the name for a skill id.
Definition Skill.java:465
static final int SKILL_COUNT
The amount of available skills.
Definition Skill.java:90
static final int getExperienceForLevel(int level)
Gets the experience for a given level.
Definition Skill.java:454
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
The OutgoingPacket that sends a message to a Players chatbox in the client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
final int skill
The skill identification of the prestige.
Handles the perk rewards from prestiging.
final String description
The description of the perk.
static PrestigePerk forItem(int item)
final String name
The name of the perk.
Holds an enum of colors for ease.