RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
Prestige.java
1package com.osroyale.content.prestige;
2
3import com.osroyale.game.world.World;
4import com.osroyale.game.world.entity.mob.player.Player;
5import com.osroyale.game.world.entity.skill.Skill;
6import com.osroyale.game.world.items.Item;
7import com.osroyale.net.packet.out.SendItemOnInterface;
8import com.osroyale.net.packet.out.SendMessage;
9import com.osroyale.net.packet.out.SendScrollbar;
10import com.osroyale.net.packet.out.SendString;
11import com.osroyale.util.MessageColor;
12
13import java.util.Arrays;
14import java.util.HashSet;
15import java.util.Set;
16
17import static com.osroyale.game.world.items.containers.bank.VaultCurrency.COINS;
18
60
61public class Prestige {
62
64 private final Player player;
65 private static final String COLOR = "<col=354CE6>";
66
67
69 public int totalPrestige;
70
72 private int prestigePoint;
73
75 public int[] prestige = new int[Skill.SKILL_COUNT];
76
78 public Set<PrestigePerk> activePerks = new HashSet<>();
79
81 public Prestige(Player player) {
82 this.player = player;
83 }
84
86 public void open() {
87 player.send(new SendString(player.getName(), 52007));
88 player.send(new SendString("Total Prestiges: <col=76E34B>" + totalPrestige + "</col>", 52008));
89 player.send(new SendString("Prestige Points: <col=76E34B>" + prestigePoint + "</col>", 52009));
90 Arrays.stream(PrestigeData.values).forEach(p -> player.send(new SendString(p.name + " " + "(<col=" + getColorInterface(prestige[p.skill]) + ">" + prestige[p.skill] + "</col>)", p.string)));
91 player.interfaceManager.open(52000);
92 }
93
95 public void prestige(PrestigeData data) {
96 prestige[data.skill]++;
97 totalPrestige += 1;
98 prestigePoint += 1;
99 player.skills.setExperience(data.skill, Skill.getExperienceForLevel(data.skill == 3 ? 10 : 1));
100 player.skills.setMaxLevel(data.skill, data.skill == 3 ? 10 : 1);
101 player.skills.setLevel(data.skill, data.skill == 3 ? 10 : 1);
102 player.skills.refresh(data.skill);
103 player.skills.setCombatLevel();
104 player.bankVault.add(COINS, 1_000_000);
105 player.send(new SendMessage("You have successfully prestiged your <col=255>" + Skill.getName(data.skill) + "</col> skill!"));
106 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!");
107 open();
108 }
109
111 public void perkInformation() {
112 final int totalPerks = PrestigePerk.values.length;
113 for (int i = 0, string = 37114; i < totalPerks; i++) {
114 PrestigePerk perk = PrestigePerk.forId(i);
115 player.send(new SendString("<col=" + (hasPerk(perk) ? "347043" : "3c50b2") + ">" + perk.name, string++));
116 player.send(new SendString(perk.description, string++));
117 player.send(new SendString("", string++));
118 }
119
120 player.send(new SendString("<col=000000>This is a list of all the available perks.", 37111));
121 player.send(new SendString("<col=000000>Perks with green names indicate that it is active.", 37112));
122 player.send(new SendString("", 37113));
123 player.send(new SendString("", 37107));
124 player.send(new SendString("Prestige Perks Information", 37103));
125 player.send(new SendScrollbar(37110, totalPerks * 65));
126 player.send(new SendItemOnInterface(37199));
127 player.interfaceManager.open(37100);
128 }
129
131 public boolean activatePerk(Item item) {
132 PrestigePerk perk = PrestigePerk.forItem(item.getId());
133 if (perk == null) {
134 return false;
135 }
136 if (activePerks == null) {
137 activePerks = new HashSet<>();
138 }
139 if (activePerks.contains(perk)) {
140 player.send(new SendMessage("The Perk: " + perk.name + " perk is already active on your account!", MessageColor.DARK_BLUE));
141 return true;
142 }
143 player.inventory.remove(item);
144 activePerks.add(perk);
145 player.send(new SendMessage("You have successfully activated the " + perk.name + " perk.", MessageColor.DARK_BLUE));
146 return true;
147 }
148
149 public boolean hasPerk(PrestigePerk perk) {
150 return activePerks.contains(perk);
151 }
152
154 public int getPrestigeColor(int skill) {
155 return getColor(prestige[skill]);
156 }
157
159 public int getColor(int tier) {
160 switch (tier) {
161 case 1:
162 return 0xf49242;
163 case 2:
164 return 0x42f468;
165 case 3:
166 return 0x42d1f4;
167 case 4:
168 return 0xa76ffc;
169 case 5:
170 return 0xf44949;
171 default:
172 return 0xFFFF00;
173 }
174 }
175
177 private String getColorInterface(int tier) {
178 return Integer.toHexString(getColor(tier));
179 }
180
181 public int getPrestigePoint() {
182 return prestigePoint;
183 }
184
185 public void setPrestigePoint(int prestigePoint) {
186 this.prestigePoint = prestigePoint;
187 }
188}
void prestige(PrestigeData data)
Definition Prestige.java:95
static void sendMessage(String... messages)
Definition World.java:433
static String getName(int skill)
Definition Skill.java:502
static final int getExperienceForLevel(int level)
Definition Skill.java:491