hypixel-api-reborn 9.0.3 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/.prettierrc +13 -0
  2. package/README.md +28 -16
  3. package/package.json +60 -58
  4. package/src/API/getAPIStatus.js +8 -7
  5. package/src/API/getBoosters.js +6 -5
  6. package/src/API/getGameCounts.js +6 -5
  7. package/src/API/getGuild.js +18 -17
  8. package/src/API/getLeaderboards.js +13 -12
  9. package/src/API/getPlayer.js +22 -26
  10. package/src/API/getRecentGames.js +18 -17
  11. package/src/API/getServerInfo.js +66 -77
  12. package/src/API/getStatus.js +8 -7
  13. package/src/API/getWatchdogStats.js +6 -5
  14. package/src/API/index.js +19 -9
  15. package/src/API/skyblock/getEndedSkyblockAuctions.js +10 -9
  16. package/src/API/skyblock/getSkyblockAuctions.js +64 -64
  17. package/src/API/skyblock/getSkyblockAuctionsByPlayer.js +11 -10
  18. package/src/API/skyblock/getSkyblockBazaar.js +10 -9
  19. package/src/API/skyblock/getSkyblockMember.js +28 -24
  20. package/src/API/skyblock/getSkyblockNews.js +6 -5
  21. package/src/API/skyblock/getSkyblockProfiles.js +44 -40
  22. package/src/Client.js +406 -430
  23. package/src/Errors.js +44 -38
  24. package/src/Private/defaultCache.js +77 -0
  25. package/src/Private/rateLimit.js +79 -98
  26. package/src/Private/requests.js +65 -39
  27. package/src/Private/updater.js +45 -42
  28. package/src/Private/uuidCache.js +37 -33
  29. package/src/Private/validate.js +97 -97
  30. package/src/index.js +82 -83
  31. package/src/structures/APIIncident.js +78 -78
  32. package/src/structures/APIStatus.js +47 -47
  33. package/src/structures/Boosters/Booster.js +83 -87
  34. package/src/structures/Color.js +129 -129
  35. package/src/structures/Game.js +164 -160
  36. package/src/structures/GameCounts.js +151 -151
  37. package/src/structures/Guild/Guild.js +204 -218
  38. package/src/structures/Guild/GuildMember.js +66 -66
  39. package/src/structures/Guild/GuildRank.js +48 -48
  40. package/src/structures/ItemBytes.js +33 -36
  41. package/src/structures/Leaderboard.js +31 -31
  42. package/src/structures/MiniGames/Arcade.js +567 -569
  43. package/src/structures/MiniGames/ArenaBrawl.js +52 -56
  44. package/src/structures/MiniGames/BedWars.js +423 -329
  45. package/src/structures/MiniGames/BlitzSurvivalGames.js +172 -148
  46. package/src/structures/MiniGames/BuildBattle.js +53 -53
  47. package/src/structures/MiniGames/CopsAndCrims.js +90 -90
  48. package/src/structures/MiniGames/Duels.js +694 -460
  49. package/src/structures/MiniGames/MegaWalls.js +137 -137
  50. package/src/structures/MiniGames/MurderMystery.js +93 -93
  51. package/src/structures/MiniGames/Paintball.js +67 -67
  52. package/src/structures/MiniGames/Pit.js +19 -19
  53. package/src/structures/MiniGames/Quakecraft.js +101 -101
  54. package/src/structures/MiniGames/SkyWars.js +508 -559
  55. package/src/structures/MiniGames/SmashHeroes.js +144 -151
  56. package/src/structures/MiniGames/SpeedUHC.js +115 -57
  57. package/src/structures/MiniGames/TNTGames.js +116 -116
  58. package/src/structures/MiniGames/TurboKartRacers.js +201 -71
  59. package/src/structures/MiniGames/UHC.js +164 -143
  60. package/src/structures/MiniGames/VampireZ.js +60 -60
  61. package/src/structures/MiniGames/Walls.js +52 -52
  62. package/src/structures/MiniGames/Warlords.js +62 -62
  63. package/src/structures/MiniGames/WoolWars.js +123 -0
  64. package/src/structures/Pet.js +96 -97
  65. package/src/structures/Pets.js +64 -64
  66. package/src/structures/Player.js +433 -453
  67. package/src/structures/PlayerCosmetics.js +100 -95
  68. package/src/structures/RecentGame.js +57 -57
  69. package/src/structures/ServerInfo.js +78 -78
  70. package/src/structures/SkyBlock/Auctions/Auction.js +104 -104
  71. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +54 -54
  72. package/src/structures/SkyBlock/Auctions/BaseAuction.js +45 -45
  73. package/src/structures/SkyBlock/Auctions/Bid.js +48 -48
  74. package/src/structures/SkyBlock/Auctions/PartialAuction.js +25 -25
  75. package/src/structures/SkyBlock/Bazzar/Order.js +38 -38
  76. package/src/structures/SkyBlock/Bazzar/Product.js +53 -53
  77. package/src/structures/SkyBlock/News/SkyblockNews.js +60 -68
  78. package/src/structures/SkyBlock/SkyblockInventoryItem.js +124 -102
  79. package/src/structures/SkyBlock/SkyblockMember.js +820 -675
  80. package/src/structures/SkyBlock/SkyblockPet.js +71 -71
  81. package/src/structures/SkyBlock/SkyblockProfile.js +60 -60
  82. package/src/structures/Status.js +41 -41
  83. package/src/structures/Watchdog/Stats.js +36 -36
  84. package/src/utils/Constants.js +2789 -795
  85. package/src/utils/SkyblockUtils.js +208 -164
  86. package/src/utils/arrayTools.js +4 -4
  87. package/src/utils/divide.js +5 -5
  88. package/src/utils/guildExp.js +57 -67
  89. package/src/utils/index.js +13 -9
  90. package/src/utils/isGuildID.js +3 -3
  91. package/src/utils/isUUID.js +5 -5
  92. package/src/utils/oscillation.js +15 -23
  93. package/src/utils/removeSnakeCase.js +22 -35
  94. package/src/utils/rgbToHexColor.js +8 -0
  95. package/src/utils/romanize.js +11 -0
  96. package/src/utils/toIGN.js +20 -20
  97. package/src/utils/toUuid.js +19 -19
  98. package/src/utils/varInt.js +17 -21
  99. package/typings/index.d.ts +3532 -2625
  100. package/src/API/getFriends.js +0 -13
  101. package/src/API/getKeyInfo.js +0 -9
  102. package/src/API/getRankedSkyWars.js +0 -10
  103. package/src/structures/Friend.js +0 -38
  104. package/src/structures/KeyInfo.js +0 -42
  105. package/src/structures/MiniGames/SkyWarsRanked.js +0 -45
@@ -1,329 +1,423 @@
1
- const divide = require('../../utils/divide');
2
-
3
- const generateStatsForMode = (data, mode) => {
4
- return {
5
- winstreak: data[`${mode}_winstreak`] || 0,
6
- playedGames: data[`${mode}_games_played_bedwars`] || 0,
7
-
8
- kills: data[`${mode}_kills_bedwars`] || 0,
9
- deaths: data[`${mode}_deaths_bedwars`] || 0,
10
-
11
- wins: data[`${mode}_wins_bedwars`] || 0,
12
- losses: data[`${mode}_losses_bedwars`] || 0,
13
-
14
- finalKills: data[`${mode}_final_kills_bedwars`] || 0,
15
- finalDeaths: data[`${mode}_final_deaths_bedwars`] || 0,
16
-
17
- beds: {
18
- broken: data[`${mode}_beds_broken_bedwars`] || 0,
19
- lost: data[`${mode}_beds_lost_bedwars`] || 0,
20
- BLRatio: divide(data[`${mode}_beds_broken_bedwars`], data[`${mode}_beds_lost_bedwars`])
21
- },
22
-
23
- avg: {
24
- kills: divide(data[`${mode}_kills_bedwars`], data[`${mode}_games_played_bedwars`]),
25
- finalKills: divide(data[`${mode}_final_kills_bedwars`], data[`${mode}_games_played_bedwars`]),
26
- bedsBroken: divide(data[`${mode}_beds_broken_bedwars`], data[`${mode}_games_played_bedwars`])
27
- },
28
-
29
- KDRatio: divide(data[`${mode}_kills_bedwars`], data[`${mode}_deaths_bedwars`]),
30
- WLRatio: divide(data[`${mode}_wins_bedwars`], data[`${mode}_losses_bedwars`]),
31
- finalKDRatio: divide(data[`${mode}_final_kills_bedwars`], data[`${mode}_final_deaths_bedwars`])
32
- };
33
- };
34
-
35
- /**
36
- * BedWars class
37
- */
38
- class BedWars {
39
- /**
40
- * @param {object} data BedWars data
41
- */
42
- constructor (data) {
43
- /**
44
- * Coins
45
- * @type {number}
46
- */
47
- this.coins = data.coins || 0;
48
- /**
49
- * Level
50
- * @type {number}
51
- */
52
- this.level = data.Experience ? getLevelForExp(data.Experience) : 0;
53
- /**
54
- * Prestige
55
- * @type {BedWarsPrestige}
56
- */
57
- this.prestige = data.Experience ? getBedWarsPrestige(getLevelForExp(data.Experience)) : 'Stone';
58
- /**
59
- * Played games
60
- * @type {number}
61
- */
62
- this.playedGames = data.games_played_bedwars || 0;
63
- /**
64
- * Wins
65
- * @type {number}
66
- */
67
- this.wins = data.wins_bedwars || 0;
68
- /**
69
- * Winstreak
70
- * @type {number}
71
- */
72
- this.winstreak = data.winstreak || 0;
73
- /**
74
- * Kills
75
- * @type {number}
76
- */
77
- this.kills = data.kills_bedwars || 0;
78
- /**
79
- * Final kills
80
- * @type {number}
81
- */
82
- this.finalKills = data.final_kills_bedwars || 0;
83
- /**
84
- * Losses
85
- * @type {number}
86
- */
87
- this.losses = data.losses_bedwars || 0;
88
- /**
89
- * Deaths
90
- * @type {number}
91
- */
92
- this.deaths = data.deaths_bedwars || 0;
93
- /**
94
- * Final deaths
95
- * @type {number}
96
- */
97
- this.finalDeaths = data.final_deaths_bedwars || 0;
98
- /**
99
- * Collected items
100
- * @type {BedWarsCollectedItems}
101
- */
102
- this.collectedItemsTotal = {
103
- iron: data.iron_resources_collected_bedwars || 0,
104
- gold: data.gold_resources_collected_bedwars || 0,
105
- diamond: data.diamond_resources_collected_bedwars || 0,
106
- emerald: data.emerald_resources_collected_bedwars || 0
107
- };
108
- /**
109
- * Beds lost/broken/BL Ratio
110
- * @type {BedWarsBeds}
111
- */
112
- this.beds = {
113
- lost: data.beds_lost_bedwars || 0,
114
- broken: data.beds_broken_bedwars || 0,
115
- BLRatio: divide(data.beds_broken_bedwars, data.beds_lost_bedwars)
116
- };
117
- /**
118
- * Average Kills/Final kills/Beds broken
119
- * @type {BedWarsAvg}
120
- */
121
- this.avg = {
122
- kills: divide(this.kills, this.playedGames),
123
- finalKills: divide(this.finalKills, this.playedGames),
124
- bedsBroken: divide(this.beds.broken, this.playedGames)
125
- };
126
- /**
127
- * Kill Death ratio
128
- * @type {number}
129
- */
130
- this.KDRatio = divide(this.kills, this.deaths);
131
- /**
132
- * Final kill death ratio
133
- * @type {number}
134
- */
135
- this.finalKDRatio = divide(this.finalKills, this.finalDeaths);
136
- /**
137
- * Win Loss ratio
138
- * @type {number}
139
- */
140
- this.WLRatio = divide(this.wins, this.losses);
141
- /**
142
- * BedWars Solo stats
143
- * @type {BedWarsModeStats}
144
- */
145
- this.solo = generateStatsForMode(data, 'eight_one');
146
- /**
147
- * BedWars Doubles stats
148
- * @type {BedWarsModeStats}
149
- */
150
- this.doubles = generateStatsForMode(data, 'eight_two');
151
- /**
152
- * BedWars 3v3v3v3 stats
153
- * @type {BedWarsModeStats}
154
- */
155
- this.threes = generateStatsForMode(data, 'four_three');
156
- /**
157
- * BedWars 4v4v4v4 stats
158
- * @type {BedWarsModeStats}
159
- */
160
- this.fours = generateStatsForMode(data, 'four_four');
161
- /**
162
- * BedWars 4v4 stats
163
- * @type {BedWarsModeStats}
164
- */
165
- this['4v4'] = generateStatsForMode(data, 'two_four');
166
- /**
167
- * BedWars Dream Mode Stats
168
- * @type {BedwarsDreamStats}
169
- */
170
- this.dream = ['ultimate', 'rush', 'armed', 'lucky', 'voidless'].reduce((ac, mode) => ({
171
- [mode]: {
172
- doubles: generateStatsForMode(data, `eight_two_${mode}`),
173
- fours: generateStatsForMode(data, `four_four_${mode}`)
174
- }, ...ac
175
- }), {});
176
- /**
177
- * BedWars Castle Stats
178
- * @type {BedWarsModeStats}
179
- */
180
- this.castle = generateStatsForMode(data, 'castle');
181
- }
182
- }
183
- /**
184
- * @param {number} level
185
- * @return {string}
186
- */
187
- function getBedWarsPrestige (level) {
188
- // eslint-disable-next-line max-len
189
- return ['Stone', 'Iron', 'Gold', 'Diamond', 'Emerald', 'Sapphire', 'Ruby', 'Crystal', 'Opal', 'Amethyst', 'Rainbow', 'Iron Prime', 'Gold Prime', 'Diamond Prime', 'Emerald Prime', 'Sapphire Prime', 'Ruby Prime', 'Crystal Prime', 'Opal Prime', 'Amethyst Prime', 'Mirror', 'Light', 'Dawn', 'Dusk', 'Air', 'Wind', 'Nebula', 'Thunder', 'Earth', 'Water', 'Fire'][Math.floor(level / 100)] || 'Rainbow';
190
- }
191
- const EASY_LEVELS = 4;
192
- const EASY_LEVELS_XP = 7000;
193
- const XP_PER_PRESTIGE = 96 * 5000 + EASY_LEVELS_XP;
194
- const LEVELS_PER_PRESTIGE = 100;
195
- const HIGHEST_PRESTIGE = 10;
196
-
197
- /**
198
- * @param {number} level
199
- * @return {number}
200
- */
201
- function getExpForLevel (level) {
202
- if (level === 0) return 0;
203
- const respectedLevel = getLevelRespectingPrestige(level);
204
- if (respectedLevel > EASY_LEVELS) return 5000;
205
- switch (respectedLevel) {
206
- case 1:
207
- return 500;
208
- case 2:
209
- return 1000;
210
- case 3:
211
- return 2000;
212
- case 4:
213
- return 3500;
214
- }
215
- return 5000;
216
- }
217
- /**
218
- * @param {number} level
219
- * @return {number}
220
- */
221
- function getLevelRespectingPrestige (level) {
222
- if (level > HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE) {
223
- return level - HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE;
224
- } else {
225
- return level % LEVELS_PER_PRESTIGE;
226
- }
227
- }
228
- /**
229
- * @param {number} exp
230
- * @return {number}
231
- */
232
- function getLevelForExp (exp) {
233
- const prestiges = Math.floor(exp / XP_PER_PRESTIGE);
234
- let level = prestiges * LEVELS_PER_PRESTIGE;
235
- let expWithoutPrestiges = exp - (prestiges * XP_PER_PRESTIGE);
236
-
237
- for (let i = 1; i <= EASY_LEVELS; ++i) {
238
- const expForEasyLevel = getExpForLevel(i);
239
- if (expWithoutPrestiges < expForEasyLevel) {
240
- break;
241
- }
242
- level++;
243
- expWithoutPrestiges -= expForEasyLevel;
244
- }
245
- return level + Math.floor(expWithoutPrestiges / 5000);
246
- }
247
- /**
248
- * @typedef {string} BedWarsPrestige
249
- * * `Stone`
250
- * * `Iron`
251
- * * `Gold`
252
- * * `Diamond`
253
- * * `Emerald`
254
- * * `Sapphire`
255
- * * `Ruby`
256
- * * `Crystal`
257
- * * `Opal`
258
- * * `Amethyst`
259
- * * `Rainbow`
260
- * * `Iron Prime`
261
- * * `Gold Prime`
262
- * * `Diamond Prime`
263
- * * `Emerald Prime`
264
- * * `Sapphire Prime`
265
- * * `Ruby Prime`
266
- * * `Crystal Prime`
267
- * * `Opal Prime`
268
- * * `Amethyst Prime`
269
- * * `Mirror`
270
- * * `Light`
271
- * * `Dawn`
272
- * * `Dusk`
273
- * * `Air`
274
- * * `Wind`
275
- * * `Nebula`
276
- * * `Thunder`
277
- * * `Earth`
278
- * * `Water`
279
- * * `Fire`
280
- */
281
- /**
282
- * @typedef {object} BedWarsAvg
283
- * @property {number} kills Average kills
284
- * @property {number} finalKills Average final kills
285
- * @property {number} bedsBroken Average beds broken
286
- */
287
- /**
288
- * @typedef {object} BedWarsCollectedItems
289
- * @property {number} iron Iron
290
- * @property {number} gold Gold
291
- * @property {number} diamond Diamond
292
- * @property {number} emerald Emerald
293
- */
294
- /**
295
- * @typedef {object} BedWarsBeds
296
- * @property {number} lost Beds lost
297
- * @property {number} broken Beds broken
298
- * @property {number} BLRatio Beds broken/Beds lost ratio
299
- */
300
- /**
301
- * @typedef {Object} BedWarsModeStats
302
- * @property {number} winstreak Winstreak
303
- * @property {number} playedGames Played games
304
- * @property {number} kills Kills
305
- * @property {number} deaths Deaths
306
- * @property {number} wins Wins
307
- * @property {number} losses Losses
308
- * @property {number} finalKills Final kills
309
- * @property {number} finalDeaths Final deaths
310
- * @property {BedWarsBeds} beds Beds
311
- * @property {BedWarsAvg} avg Average Kills/Final kills/Beds broken
312
- * @property {number} KDRatio Kill Death ratio
313
- * @property {number} WLRatio Win Loss ratio
314
- * @property {number} finalKDRatio Final kills/Final deaths ratio
315
- */
316
- /**
317
- * @typedef {Object} BedwarsDreamStats
318
- * @property {BedwarsDreamModeStats} ultimate Ultimate stats
319
- * @property {BedwarsDreamModeStats} rush Rush stats
320
- * @property {BedwarsDreamModeStats} armed Armed stats
321
- * @property {BedwarsDreamModeStats} lucky Lucky Blocks stats (true api naming)
322
- * @property {BedwarsDreamModeStats} voidless Voidless stats
323
- */
324
- /**
325
- * @typedef {Object} BedwarsDreamModeStats
326
- * @property {BedWarsModeStats} doubles Doubles
327
- * @property {BedWarsModeStats} fours Fours
328
- */
329
- module.exports = BedWars;
1
+ const divide = require('../../utils/divide');
2
+
3
+ const generateStatsForMode = (data, mode) => {
4
+ return {
5
+ winstreak: data[`${mode}_winstreak`] || 0,
6
+ playedGames: data[`${mode}_games_played_bedwars`] || 0,
7
+
8
+ kills: data[`${mode}_kills_bedwars`] || 0,
9
+ deaths: data[`${mode}_deaths_bedwars`] || 0,
10
+
11
+ wins: data[`${mode}_wins_bedwars`] || 0,
12
+ losses: data[`${mode}_losses_bedwars`] || 0,
13
+
14
+ finalKills: data[`${mode}_final_kills_bedwars`] || 0,
15
+ finalDeaths: data[`${mode}_final_deaths_bedwars`] || 0,
16
+
17
+ beds: {
18
+ broken: data[`${mode}_beds_broken_bedwars`] || 0,
19
+ lost: data[`${mode}_beds_lost_bedwars`] || 0,
20
+ BLRatio: divide(data[`${mode}_beds_broken_bedwars`], data[`${mode}_beds_lost_bedwars`])
21
+ },
22
+
23
+ avg: {
24
+ kills: divide(data[`${mode}_kills_bedwars`], data[`${mode}_games_played_bedwars`]),
25
+ finalKills: divide(data[`${mode}_final_kills_bedwars`], data[`${mode}_games_played_bedwars`]),
26
+ bedsBroken: divide(data[`${mode}_beds_broken_bedwars`], data[`${mode}_games_played_bedwars`])
27
+ },
28
+
29
+ KDRatio: divide(data[`${mode}_kills_bedwars`], data[`${mode}_deaths_bedwars`]),
30
+ WLRatio: divide(data[`${mode}_wins_bedwars`], data[`${mode}_losses_bedwars`]),
31
+ finalKDRatio: divide(data[`${mode}_final_kills_bedwars`], data[`${mode}_final_deaths_bedwars`])
32
+ };
33
+ };
34
+
35
+ /**
36
+ * BedWars class
37
+ */
38
+ class BedWars {
39
+ /**
40
+ * @param {object} data BedWars data
41
+ */
42
+ constructor(data) {
43
+ /**
44
+ * Coins
45
+ * @type {number}
46
+ */
47
+ this.coins = data.coins || 0;
48
+ /**
49
+ * Level
50
+ * @type {number}
51
+ */
52
+ this.level = data.Experience ? getLevelForExp(data.Experience) : 0;
53
+ /**
54
+ * Experience
55
+ * @type {number}
56
+ */
57
+ this.experience = data.Experience || 0;
58
+ /**
59
+ * Prestige
60
+ * @type {BedWarsPrestige}
61
+ */
62
+ this.prestige = data.Experience ? getBedWarsPrestige(getLevelForExp(data.Experience)) : 'Stone';
63
+ /**
64
+ * Played games
65
+ * @type {number}
66
+ */
67
+ this.playedGames = data.games_played_bedwars || 0;
68
+ /**
69
+ * Wins
70
+ * @type {number}
71
+ */
72
+ this.wins = data.wins_bedwars || 0;
73
+ /**
74
+ * Winstreak
75
+ * @type {number}
76
+ */
77
+ this.winstreak = data.winstreak || 0;
78
+ /**
79
+ * Kills
80
+ * @type {number}
81
+ */
82
+ this.kills = data.kills_bedwars || 0;
83
+ /**
84
+ * Final kills
85
+ * @type {number}
86
+ */
87
+ this.finalKills = data.final_kills_bedwars || 0;
88
+ /**
89
+ * Losses
90
+ * @type {number}
91
+ */
92
+ this.losses = data.losses_bedwars || 0;
93
+ /**
94
+ * Deaths
95
+ * @type {number}
96
+ */
97
+ this.deaths = data.deaths_bedwars || 0;
98
+ /**
99
+ * Final deaths
100
+ * @type {number}
101
+ */
102
+ this.finalDeaths = data.final_deaths_bedwars || 0;
103
+ /**
104
+ * Collected items
105
+ * @type {BedWarsCollectedItems}
106
+ */
107
+ this.collectedItemsTotal = {
108
+ iron: data.iron_resources_collected_bedwars || 0,
109
+ gold: data.gold_resources_collected_bedwars || 0,
110
+ diamond: data.diamond_resources_collected_bedwars || 0,
111
+ emerald: data.emerald_resources_collected_bedwars || 0
112
+ };
113
+ /**
114
+ * Loot chests
115
+ * @type {BedWarsLootChests}
116
+ */
117
+ this.lootChests = {
118
+ christmas: data.bedwars_christmas_boxes || 0,
119
+ lunar: data.bedwars_lunar_boxes || 0,
120
+ normal: data.bedwars_boxes || 0,
121
+ easter: data.bedwars_easter_boxes || 0,
122
+ halloween: data.bedwars_halloween_boxes || 0,
123
+ golden: data.bedwars_golden_boxes || 0,
124
+ total: data.bedwars_christmas_boxes + data.bedwars_lunar_boxes + data.bedwars_boxes + data.bedwars_easter_boxes + data.bedwars_halloween_boxes + data.bedwars_golden_boxes || 0
125
+ };
126
+ /**
127
+ * Beds lost/broken/BL Ratio
128
+ * @type {BedWarsBeds}
129
+ */
130
+ this.beds = {
131
+ lost: data.beds_lost_bedwars || 0,
132
+ broken: data.beds_broken_bedwars || 0,
133
+ BLRatio: divide(data.beds_broken_bedwars, data.beds_lost_bedwars)
134
+ };
135
+ /**
136
+ * Average Kills/Final kills/Beds broken
137
+ * @type {BedWarsAvg}
138
+ */
139
+ this.avg = {
140
+ kills: divide(this.kills, this.playedGames),
141
+ finalKills: divide(this.finalKills, this.playedGames),
142
+ bedsBroken: divide(this.beds.broken, this.playedGames)
143
+ };
144
+ /**
145
+ * Kill Death ratio
146
+ * @type {number}
147
+ */
148
+ this.KDRatio = divide(this.kills, this.deaths);
149
+ /**
150
+ * Final kill death ratio
151
+ * @type {number}
152
+ */
153
+ this.finalKDRatio = divide(this.finalKills, this.finalDeaths);
154
+ /**
155
+ * Win Loss ratio
156
+ * @type {number}
157
+ */
158
+ this.WLRatio = divide(this.wins, this.losses);
159
+ /**
160
+ * BedWars Solo stats
161
+ * @type {BedWarsModeStats}
162
+ */
163
+ this.solo = generateStatsForMode(data, 'eight_one');
164
+ /**
165
+ * BedWars Doubles stats
166
+ * @type {BedWarsModeStats}
167
+ */
168
+ this.doubles = generateStatsForMode(data, 'eight_two');
169
+ /**
170
+ * BedWars 3v3v3v3 stats
171
+ * @type {BedWarsModeStats}
172
+ */
173
+ this.threes = generateStatsForMode(data, 'four_three');
174
+ /**
175
+ * BedWars 4v4v4v4 stats
176
+ * @type {BedWarsModeStats}
177
+ */
178
+ this.fours = generateStatsForMode(data, 'four_four');
179
+ /**
180
+ * BedWars 4v4 stats
181
+ * @type {BedWarsModeStats}
182
+ */
183
+ this['4v4'] = generateStatsForMode(data, 'two_four');
184
+ /**
185
+ * BedWars Dream Mode Stats
186
+ * @type {BedwarsDreamStats}
187
+ */
188
+ this.dream = ['ultimate', 'rush', 'armed', 'lucky', 'voidless'].reduce(
189
+ (ac, mode) => ({
190
+ [mode]: {
191
+ doubles: generateStatsForMode(data, `eight_two_${mode}`),
192
+ fours: generateStatsForMode(data, `four_four_${mode}`)
193
+ },
194
+ ...ac
195
+ }),
196
+ {}
197
+ );
198
+ /**
199
+ * BedWars Castle Stats
200
+ * @type {BedWarsModeStats}
201
+ */
202
+ this.castle = generateStatsForMode(data, 'castle');
203
+ }
204
+ }
205
+ // eslint-disable-next-line require-jsdoc
206
+ function getBedWarsPrestige(level) {
207
+ // eslint-disable-next-line max-len
208
+ if (level >= 5000) return 'Eternal';
209
+ return (
210
+ [
211
+ 'Stone',
212
+ 'Iron',
213
+ 'Gold',
214
+ 'Diamond',
215
+ 'Emerald',
216
+ 'Sapphire',
217
+ 'Ruby',
218
+ 'Crystal',
219
+ 'Opal',
220
+ 'Amethyst',
221
+ 'Rainbow',
222
+ 'Iron Prime',
223
+ 'Gold Prime',
224
+ 'Diamond Prime',
225
+ 'Emerald Prime',
226
+ 'Sapphire Prime',
227
+ 'Ruby Prime',
228
+ 'Crystal Prime',
229
+ 'Opal Prime',
230
+ 'Amethyst Prime',
231
+ 'Mirror',
232
+ 'Light',
233
+ 'Dawn',
234
+ 'Dusk',
235
+ 'Air',
236
+ 'Wind',
237
+ 'Nebula',
238
+ 'Thunder',
239
+ 'Earth',
240
+ 'Water',
241
+ 'Fire',
242
+ 'Sunrise',
243
+ 'Eclipse',
244
+ 'Gamma',
245
+ 'Majestic',
246
+ 'Andesine',
247
+ 'Marine',
248
+ 'Element',
249
+ 'Galaxy',
250
+ 'Atomic',
251
+ 'Sunset',
252
+ 'Time',
253
+ 'Winter',
254
+ 'Obsidian',
255
+ 'Spring',
256
+ 'Ice',
257
+ 'Summer',
258
+ 'Spinel',
259
+ 'Autumn',
260
+ 'Mystic',
261
+ 'Eternal'
262
+ ][Math.floor(level / 100)] || 'Eternal'
263
+ );
264
+ }
265
+ const EASY_LEVELS = 4;
266
+ const EASY_LEVELS_XP = 7000;
267
+ const XP_PER_PRESTIGE = 96 * 5000 + EASY_LEVELS_XP;
268
+ const LEVELS_PER_PRESTIGE = 100;
269
+ const HIGHEST_PRESTIGE = 10;
270
+
271
+ // eslint-disable-next-line require-jsdoc
272
+ function getExpForLevel(level) {
273
+ if (level === 0) return 0;
274
+ const respectedLevel = getLevelRespectingPrestige(level);
275
+ if (respectedLevel > EASY_LEVELS) return 5000;
276
+ switch (respectedLevel) {
277
+ case 1:
278
+ return 500;
279
+ case 2:
280
+ return 1000;
281
+ case 3:
282
+ return 2000;
283
+ case 4:
284
+ return 3500;
285
+ }
286
+ return 5000;
287
+ }
288
+ // eslint-disable-next-line require-jsdoc
289
+ function getLevelRespectingPrestige(level) {
290
+ if (level > HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE) {
291
+ return level - HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE;
292
+ } else {
293
+ return level % LEVELS_PER_PRESTIGE;
294
+ }
295
+ }
296
+ // eslint-disable-next-line require-jsdoc
297
+ function getLevelForExp(exp) {
298
+ const prestiges = Math.floor(exp / XP_PER_PRESTIGE);
299
+ let level = prestiges * LEVELS_PER_PRESTIGE;
300
+ let expWithoutPrestiges = exp - prestiges * XP_PER_PRESTIGE;
301
+
302
+ for (let i = 1; i <= EASY_LEVELS; ++i) {
303
+ const expForEasyLevel = getExpForLevel(i);
304
+ if (expWithoutPrestiges < expForEasyLevel) {
305
+ break;
306
+ }
307
+ level++;
308
+ expWithoutPrestiges -= expForEasyLevel;
309
+ }
310
+ return level + Math.floor(expWithoutPrestiges / 5000);
311
+ }
312
+ /**
313
+ * @typedef {string} BedWarsPrestige
314
+ * * `Stone`
315
+ * * `Iron`
316
+ * * `Gold`
317
+ * * `Diamond`
318
+ * * `Emerald`
319
+ * * `Sapphire`
320
+ * * `Ruby`
321
+ * * `Crystal`
322
+ * * `Opal`
323
+ * * `Amethyst`
324
+ * * `Rainbow`
325
+ * * `Iron Prime`
326
+ * * `Gold Prime`
327
+ * * `Diamond Prime`
328
+ * * `Emerald Prime`
329
+ * * `Sapphire Prime`
330
+ * * `Ruby Prime`
331
+ * * `Crystal Prime`
332
+ * * `Opal Prime`
333
+ * * `Amethyst Prime`
334
+ * * `Mirror`
335
+ * * `Light`
336
+ * * `Dawn`
337
+ * * `Dusk`
338
+ * * `Air`
339
+ * * `Wind`
340
+ * * `Nebula`
341
+ * * `Thunder`
342
+ * * `Earth`
343
+ * * `Water`
344
+ * * `Fire`
345
+ * * `Sunrise`
346
+ * * `Eclipse`
347
+ * * `Gamma`
348
+ * * `Majestic`
349
+ * * `Andesine`
350
+ * * `Marine`
351
+ * * `Element`
352
+ * * `Galaxy`
353
+ * * `Atomic`
354
+ * * `Sunset`
355
+ * * `Time`
356
+ * * `Winter`
357
+ * * `Obsidian`
358
+ * * `Spring`
359
+ * * `Ice`
360
+ * * `Summer`
361
+ * * `Spinel`
362
+ * * `Autumn`
363
+ * * `Mystic`
364
+ * * `Eternal`
365
+ */
366
+ /**
367
+ * @typedef {object} BedWarsAvg
368
+ * @property {number} kills Average kills
369
+ * @property {number} finalKills Average final kills
370
+ * @property {number} bedsBroken Average beds broken
371
+ */
372
+ /**
373
+ * @typedef {object} BedWarsCollectedItems
374
+ * @property {number} iron Iron
375
+ * @property {number} gold Gold
376
+ * @property {number} diamond Diamond
377
+ * @property {number} emerald Emerald
378
+ */
379
+ /**
380
+ * @typedef {object} BedWarsLootChests
381
+ * @property {number} christmas Christmas chests
382
+ * @property {number} halloween Halloween chests
383
+ * @property {number} easter Easter chests
384
+ * @property {number} christmas Christmas chests
385
+ * @property {number} golden Golden chests
386
+ * @property {number} normal Normal chests
387
+ */
388
+ /**
389
+ * @typedef {object} BedWarsBeds
390
+ * @property {number} lost Beds lost
391
+ * @property {number} broken Beds broken
392
+ * @property {number} BLRatio Beds broken/Beds lost ratio
393
+ */
394
+ /**
395
+ * @typedef {Object} BedWarsModeStats
396
+ * @property {number} winstreak Winstreak
397
+ * @property {number} playedGames Played games
398
+ * @property {number} kills Kills
399
+ * @property {number} deaths Deaths
400
+ * @property {number} wins Wins
401
+ * @property {number} losses Losses
402
+ * @property {number} finalKills Final kills
403
+ * @property {number} finalDeaths Final deaths
404
+ * @property {BedWarsBeds} beds Beds
405
+ * @property {BedWarsAvg} avg Average Kills/Final kills/Beds broken
406
+ * @property {number} KDRatio Kill Death ratio
407
+ * @property {number} WLRatio Win Loss ratio
408
+ * @property {number} finalKDRatio Final kills/Final deaths ratio
409
+ */
410
+ /**
411
+ * @typedef {Object} BedwarsDreamStats
412
+ * @property {BedwarsDreamModeStats} ultimate Ultimate stats
413
+ * @property {BedwarsDreamModeStats} rush Rush stats
414
+ * @property {BedwarsDreamModeStats} armed Armed stats
415
+ * @property {BedwarsDreamModeStats} lucky Lucky Blocks stats (true api naming)
416
+ * @property {BedwarsDreamModeStats} voidless Voidless stats
417
+ */
418
+ /**
419
+ * @typedef {Object} BedwarsDreamModeStats
420
+ * @property {BedWarsModeStats} doubles Doubles
421
+ * @property {BedWarsModeStats} fours Fours
422
+ */
423
+ module.exports = BedWars;