hypixel-api-reborn 10.0.0 → 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 +27 -15
  3. package/package.json +60 -58
  4. package/src/API/getAPIStatus.js +8 -8
  5. package/src/API/getBoosters.js +6 -6
  6. package/src/API/getGameCounts.js +6 -6
  7. package/src/API/getGuild.js +18 -18
  8. package/src/API/getLeaderboards.js +13 -13
  9. package/src/API/getPlayer.js +22 -27
  10. package/src/API/getRecentGames.js +18 -18
  11. package/src/API/getServerInfo.js +66 -77
  12. package/src/API/getStatus.js +8 -8
  13. package/src/API/getWatchdogStats.js +6 -6
  14. package/src/API/index.js +19 -23
  15. package/src/API/skyblock/getEndedSkyblockAuctions.js +10 -10
  16. package/src/API/skyblock/getSkyblockAuctions.js +64 -64
  17. package/src/API/skyblock/getSkyblockAuctionsByPlayer.js +11 -11
  18. package/src/API/skyblock/getSkyblockBazaar.js +10 -10
  19. package/src/API/skyblock/getSkyblockMember.js +28 -25
  20. package/src/API/skyblock/getSkyblockNews.js +6 -6
  21. package/src/API/skyblock/getSkyblockProfiles.js +44 -41
  22. package/src/Client.js +406 -450
  23. package/src/Errors.js +44 -39
  24. package/src/Private/defaultCache.js +77 -78
  25. package/src/Private/rateLimit.js +79 -98
  26. package/src/Private/requests.js +65 -54
  27. package/src/Private/updater.js +45 -45
  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 -351
  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 -630
  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 -176
  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 -449
  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 -130
  79. package/src/structures/SkyBlock/SkyblockMember.js +820 -687
  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 -809
  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 -13
  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 -8
  95. package/src/utils/romanize.js +11 -13
  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 -2644
  100. package/src/API/getFriends.js +0 -14
  101. package/src/API/getKeyInfo.js +0 -10
  102. package/src/API/getRankedSkyWars.js +0 -11
  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,351 +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
- * Loot chests
110
- * @type {BedWarsLootChests}
111
- */
112
- this.lootChests = {
113
- christmas: data.bedwars_christmas_boxes || 0,
114
- lunar: data.bedwars_lunar_boxes || 0,
115
- normal: data.bedwars_boxes || 0,
116
- easter: data.bedwars_easter_boxes || 0,
117
- halloween: data.bedwars_halloween_boxes || 0,
118
- golden: data.bedwars_golden_boxes || 0,
119
- 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
120
- };
121
- /**
122
- * Beds lost/broken/BL Ratio
123
- * @type {BedWarsBeds}
124
- */
125
- this.beds = {
126
- lost: data.beds_lost_bedwars || 0,
127
- broken: data.beds_broken_bedwars || 0,
128
- BLRatio: divide(data.beds_broken_bedwars, data.beds_lost_bedwars)
129
- };
130
- /**
131
- * Average Kills/Final kills/Beds broken
132
- * @type {BedWarsAvg}
133
- */
134
- this.avg = {
135
- kills: divide(this.kills, this.playedGames),
136
- finalKills: divide(this.finalKills, this.playedGames),
137
- bedsBroken: divide(this.beds.broken, this.playedGames)
138
- };
139
- /**
140
- * Kill Death ratio
141
- * @type {number}
142
- */
143
- this.KDRatio = divide(this.kills, this.deaths);
144
- /**
145
- * Final kill death ratio
146
- * @type {number}
147
- */
148
- this.finalKDRatio = divide(this.finalKills, this.finalDeaths);
149
- /**
150
- * Win Loss ratio
151
- * @type {number}
152
- */
153
- this.WLRatio = divide(this.wins, this.losses);
154
- /**
155
- * BedWars Solo stats
156
- * @type {BedWarsModeStats}
157
- */
158
- this.solo = generateStatsForMode(data, 'eight_one');
159
- /**
160
- * BedWars Doubles stats
161
- * @type {BedWarsModeStats}
162
- */
163
- this.doubles = generateStatsForMode(data, 'eight_two');
164
- /**
165
- * BedWars 3v3v3v3 stats
166
- * @type {BedWarsModeStats}
167
- */
168
- this.threes = generateStatsForMode(data, 'four_three');
169
- /**
170
- * BedWars 4v4v4v4 stats
171
- * @type {BedWarsModeStats}
172
- */
173
- this.fours = generateStatsForMode(data, 'four_four');
174
- /**
175
- * BedWars 4v4 stats
176
- * @type {BedWarsModeStats}
177
- */
178
- this['4v4'] = generateStatsForMode(data, 'two_four');
179
- /**
180
- * BedWars Dream Mode Stats
181
- * @type {BedwarsDreamStats}
182
- */
183
- this.dream = ['ultimate', 'rush', 'armed', 'lucky', 'voidless'].reduce((ac, mode) => ({
184
- [mode]: {
185
- doubles: generateStatsForMode(data, `eight_two_${mode}`),
186
- fours: generateStatsForMode(data, `four_four_${mode}`)
187
- }, ...ac
188
- }), {});
189
- /**
190
- * BedWars Castle Stats
191
- * @type {BedWarsModeStats}
192
- */
193
- this.castle = generateStatsForMode(data, 'castle');
194
- }
195
- }
196
- /**
197
- * @param {number} level
198
- * @return {string}
199
- */
200
- function getBedWarsPrestige (level) {
201
- // eslint-disable-next-line max-len
202
- 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';
203
- }
204
- const EASY_LEVELS = 4;
205
- const EASY_LEVELS_XP = 7000;
206
- const XP_PER_PRESTIGE = 96 * 5000 + EASY_LEVELS_XP;
207
- const LEVELS_PER_PRESTIGE = 100;
208
- const HIGHEST_PRESTIGE = 10;
209
-
210
- /**
211
- * @param {number} level
212
- * @return {number}
213
- */
214
- function getExpForLevel (level) {
215
- if (level === 0) return 0;
216
- const respectedLevel = getLevelRespectingPrestige(level);
217
- if (respectedLevel > EASY_LEVELS) return 5000;
218
- switch (respectedLevel) {
219
- case 1:
220
- return 500;
221
- case 2:
222
- return 1000;
223
- case 3:
224
- return 2000;
225
- case 4:
226
- return 3500;
227
- }
228
- return 5000;
229
- }
230
- /**
231
- * @param {number} level
232
- * @return {number}
233
- */
234
- function getLevelRespectingPrestige (level) {
235
- if (level > HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE) {
236
- return level - HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE;
237
- } else {
238
- return level % LEVELS_PER_PRESTIGE;
239
- }
240
- }
241
- /**
242
- * @param {number} exp
243
- * @return {number}
244
- */
245
- function getLevelForExp (exp) {
246
- const prestiges = Math.floor(exp / XP_PER_PRESTIGE);
247
- let level = prestiges * LEVELS_PER_PRESTIGE;
248
- let expWithoutPrestiges = exp - (prestiges * XP_PER_PRESTIGE);
249
-
250
- for (let i = 1; i <= EASY_LEVELS; ++i) {
251
- const expForEasyLevel = getExpForLevel(i);
252
- if (expWithoutPrestiges < expForEasyLevel) {
253
- break;
254
- }
255
- level++;
256
- expWithoutPrestiges -= expForEasyLevel;
257
- }
258
- return level + Math.floor(expWithoutPrestiges / 5000);
259
- }
260
- /**
261
- * @typedef {string} BedWarsPrestige
262
- * * `Stone`
263
- * * `Iron`
264
- * * `Gold`
265
- * * `Diamond`
266
- * * `Emerald`
267
- * * `Sapphire`
268
- * * `Ruby`
269
- * * `Crystal`
270
- * * `Opal`
271
- * * `Amethyst`
272
- * * `Rainbow`
273
- * * `Iron Prime`
274
- * * `Gold Prime`
275
- * * `Diamond Prime`
276
- * * `Emerald Prime`
277
- * * `Sapphire Prime`
278
- * * `Ruby Prime`
279
- * * `Crystal Prime`
280
- * * `Opal Prime`
281
- * * `Amethyst Prime`
282
- * * `Mirror`
283
- * * `Light`
284
- * * `Dawn`
285
- * * `Dusk`
286
- * * `Air`
287
- * * `Wind`
288
- * * `Nebula`
289
- * * `Thunder`
290
- * * `Earth`
291
- * * `Water`
292
- * * `Fire`
293
- */
294
- /**
295
- * @typedef {object} BedWarsAvg
296
- * @property {number} kills Average kills
297
- * @property {number} finalKills Average final kills
298
- * @property {number} bedsBroken Average beds broken
299
- */
300
- /**
301
- * @typedef {object} BedWarsCollectedItems
302
- * @property {number} iron Iron
303
- * @property {number} gold Gold
304
- * @property {number} diamond Diamond
305
- * @property {number} emerald Emerald
306
- */
307
- /**
308
- * @typedef {object} BedWarsLootChests
309
- * @property {number} christmas Christmas chests
310
- * @property {number} halloween Halloween chests
311
- * @property {number} easter Easter chests
312
- * @property {number} christmas Christmas chests
313
- * @property {number} golden Golden chests
314
- * @property {number} normal Normal chests
315
- */
316
- /**
317
- * @typedef {object} BedWarsBeds
318
- * @property {number} lost Beds lost
319
- * @property {number} broken Beds broken
320
- * @property {number} BLRatio Beds broken/Beds lost ratio
321
- */
322
- /**
323
- * @typedef {Object} BedWarsModeStats
324
- * @property {number} winstreak Winstreak
325
- * @property {number} playedGames Played games
326
- * @property {number} kills Kills
327
- * @property {number} deaths Deaths
328
- * @property {number} wins Wins
329
- * @property {number} losses Losses
330
- * @property {number} finalKills Final kills
331
- * @property {number} finalDeaths Final deaths
332
- * @property {BedWarsBeds} beds Beds
333
- * @property {BedWarsAvg} avg Average Kills/Final kills/Beds broken
334
- * @property {number} KDRatio Kill Death ratio
335
- * @property {number} WLRatio Win Loss ratio
336
- * @property {number} finalKDRatio Final kills/Final deaths ratio
337
- */
338
- /**
339
- * @typedef {Object} BedwarsDreamStats
340
- * @property {BedwarsDreamModeStats} ultimate Ultimate stats
341
- * @property {BedwarsDreamModeStats} rush Rush stats
342
- * @property {BedwarsDreamModeStats} armed Armed stats
343
- * @property {BedwarsDreamModeStats} lucky Lucky Blocks stats (true api naming)
344
- * @property {BedwarsDreamModeStats} voidless Voidless stats
345
- */
346
- /**
347
- * @typedef {Object} BedwarsDreamModeStats
348
- * @property {BedWarsModeStats} doubles Doubles
349
- * @property {BedWarsModeStats} fours Fours
350
- */
351
- 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;