hypixel-api-reborn 11.1.0 → 11.2.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 (93) hide show
  1. package/.prettierrc +3 -3
  2. package/README.md +5 -3
  3. package/package.json +20 -18
  4. package/src/API/getAchievements.js +6 -0
  5. package/src/API/getChallenges.js +6 -0
  6. package/src/API/getGuild.js +1 -1
  7. package/src/API/getGuildAchievements.js +6 -0
  8. package/src/API/getLeaderboards.js +3 -1
  9. package/src/API/getPlayer.js +1 -1
  10. package/src/API/getQuests.js +6 -0
  11. package/src/API/getRecentGames.js +1 -1
  12. package/src/API/getServerInfo.js +3 -1
  13. package/src/API/getStatus.js +1 -1
  14. package/src/API/index.js +28 -17
  15. package/src/API/skyblock/getAuction.js +19 -0
  16. package/src/API/skyblock/{getSkyblockAuctions.js → getAuctions.js} +6 -2
  17. package/src/API/skyblock/{getSkyblockAuctionsByPlayer.js → getAuctionsByPlayer.js} +1 -1
  18. package/src/API/skyblock/getBingo.js +8 -0
  19. package/src/API/skyblock/getBingoByPlayer.js +14 -0
  20. package/src/API/skyblock/getFireSales.js +7 -0
  21. package/src/API/skyblock/getGovernment.js +8 -0
  22. package/src/API/skyblock/{getSkyblockMember.js → getMember.js} +9 -3
  23. package/src/API/skyblock/getMuseum.js +14 -0
  24. package/src/API/skyblock/{getSkyblockProfiles.js → getProfiles.js} +13 -7
  25. package/src/Client.js +88 -14
  26. package/src/Errors.js +38 -17
  27. package/src/Private/rateLimit.js +10 -2
  28. package/src/Private/requests.js +19 -7
  29. package/src/Private/updater.js +9 -5
  30. package/src/Private/uuidCache.js +23 -29
  31. package/src/Private/validate.js +20 -9
  32. package/src/index.js +9 -0
  33. package/src/structures/APIIncident.js +3 -9
  34. package/src/structures/Boosters/Booster.js +5 -5
  35. package/src/structures/Color.js +93 -48
  36. package/src/structures/Game.js +3 -1
  37. package/src/structures/Guild/Guild.js +21 -17
  38. package/src/structures/Guild/GuildMember.js +6 -6
  39. package/src/structures/Guild/GuildRank.js +2 -2
  40. package/src/structures/MiniGames/Arcade.js +22 -17
  41. package/src/structures/MiniGames/BedWars.js +152 -24
  42. package/src/structures/MiniGames/Duels.js +84 -23
  43. package/src/structures/MiniGames/MegaWalls.js +3 -1
  44. package/src/structures/MiniGames/MurderMystery.js +2 -2
  45. package/src/structures/MiniGames/Pit.js +231 -2
  46. package/src/structures/MiniGames/PitInventoryItem.js +43 -0
  47. package/src/structures/MiniGames/SkyWars.js +19 -14
  48. package/src/structures/MiniGames/SmashHeroes.js +1 -1
  49. package/src/structures/MiniGames/TNTGames.js +1 -1
  50. package/src/structures/MiniGames/UHC.js +21 -3
  51. package/src/structures/Player.js +16 -20
  52. package/src/structures/PlayerCosmetics.js +64 -10
  53. package/src/structures/ServerInfo.js +1 -1
  54. package/src/structures/SkyBlock/Auctions/Auction.js +3 -1
  55. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +1 -0
  56. package/src/structures/SkyBlock/Auctions/BaseAuction.js +1 -0
  57. package/src/structures/SkyBlock/Auctions/Bid.js +1 -0
  58. package/src/structures/SkyBlock/Auctions/PartialAuction.js +1 -0
  59. package/src/structures/SkyBlock/PlayerBingo.js +56 -0
  60. package/src/structures/SkyBlock/SkyblockInventoryItem.js +86 -18
  61. package/src/structures/SkyBlock/SkyblockMember.js +252 -144
  62. package/src/structures/SkyBlock/SkyblockMuseum.js +60 -0
  63. package/src/structures/SkyBlock/SkyblockMuseumItem.js +54 -0
  64. package/src/structures/SkyBlock/SkyblockPet.js +1 -0
  65. package/src/structures/SkyBlock/SkyblockProfile.js +37 -23
  66. package/src/structures/SkyBlock/Static/Bingo.js +102 -0
  67. package/src/structures/SkyBlock/Static/BingoData.js +45 -0
  68. package/src/structures/SkyBlock/Static/Candidate.js +40 -0
  69. package/src/structures/SkyBlock/Static/FireSale.js +55 -0
  70. package/src/structures/SkyBlock/Static/Government.js +74 -0
  71. package/src/structures/SkyBlock/Static/Perk.js +24 -0
  72. package/src/structures/Static/Achievement.js +86 -0
  73. package/src/structures/Static/AchievementTier.js +33 -0
  74. package/src/structures/Static/Achievements.js +30 -0
  75. package/src/structures/Static/Challenges.js +29 -0
  76. package/src/structures/Static/GameAchievements.js +36 -0
  77. package/src/structures/Static/GameChallenges.js +40 -0
  78. package/src/structures/Static/GameQuests.js +24 -0
  79. package/src/structures/Static/GuildAchievements.js +34 -0
  80. package/src/structures/Static/Quest.js +66 -0
  81. package/src/structures/Static/Quests.js +31 -0
  82. package/src/structures/Status.js +2 -2
  83. package/src/utils/Constants.js +382 -41
  84. package/src/utils/SkyblockUtils.js +12 -7
  85. package/src/utils/guildExp.js +4 -1
  86. package/src/utils/removeSnakeCase.js +9 -2
  87. package/src/utils/romanize.js +32 -1
  88. package/src/utils/toIGN.js +6 -2
  89. package/src/utils/toUuid.js +10 -5
  90. package/typings/index.d.ts +985 -295
  91. /package/src/API/skyblock/{getSkyblockBazaar.js → getBazaar.js} +0 -0
  92. /package/src/API/skyblock/{getEndedSkyblockAuctions.js → getEndedAuctions.js} +0 -0
  93. /package/src/API/skyblock/{getSkyblockNews.js → getNews.js} +0 -0
@@ -9,7 +9,7 @@ const { getGuildLevel, parseHistory } = require('../../utils/guildExp');
9
9
  class Guild {
10
10
  /**
11
11
  * @param {data} data Guild data
12
- * @param {string} [me] Player uuid used to search for this guild
12
+ * @param {string} [me] Player uuid u#sed to search for this guild
13
13
  */
14
14
  constructor(data, me = '') {
15
15
  /**
@@ -19,22 +19,22 @@ class Guild {
19
19
  this.id = data._id;
20
20
  /**
21
21
  * Guild name
22
- * @type {String}
22
+ * @type {string}
23
23
  */
24
24
  this.name = data.name;
25
25
  /**
26
26
  * Guild description
27
- * @type {String}
27
+ * @type {string}
28
28
  */
29
- this.description = data.description ? data.description : null;
29
+ this.description = data.description ?? '';
30
30
  /**
31
31
  * Guild experience
32
- * @type {Number}
32
+ * @type {number}
33
33
  */
34
34
  this.experience = data.exp || 0;
35
35
  /**
36
36
  * Guild level
37
- * @type {Number}
37
+ * @type {number}
38
38
  */
39
39
  this.level = getGuildLevel(this.experience);
40
40
  /**
@@ -64,7 +64,9 @@ class Guild {
64
64
  * @return {Array<GuildRank>}
65
65
  */
66
66
  this.getRanksByNewest = function () {
67
- return this.ranks.length ? this.ranks.map((r) => new GuildRank(r)).sort((a, b) => b.createdAt - a.createdAt) : null;
67
+ return this.ranks.length
68
+ ? this.ranks.map((r) => new GuildRank(r)).sort((a, b) => b.createdAt - a.createdAt)
69
+ : null;
68
70
  };
69
71
  /**
70
72
  * A map containing all guild members, keyed by their uuids
@@ -86,7 +88,7 @@ class Guild {
86
88
  };
87
89
  /**
88
90
  * Date of guild creation as timestamp
89
- * @type {String}
91
+ * @type {string}
90
92
  */
91
93
  this.createdAtTimestamp = data.created;
92
94
  /**
@@ -98,7 +100,7 @@ class Guild {
98
100
  * Whether this guild can be joined using /g join
99
101
  * @type {boolean}
100
102
  */
101
- this.joinable = data.joinable ? data.joinable : false;
103
+ this.joinable = data.joinable ?? false;
102
104
  /**
103
105
  * Whether this guild is listed in the Guild Finder
104
106
  * @type {boolean}
@@ -108,22 +110,22 @@ class Guild {
108
110
  * Timestamp guild chat will be unmuted at.
109
111
  * @type {number|null}
110
112
  */
111
- this.chatMuteUntilTimestamp = data.chatMute ? data.chatMute : null;
113
+ this.chatMuteUntilTimestamp = data.chatMute ?? null;
112
114
  /**
113
115
  * Timestamp guild chat will be unmuted at as Date.
114
116
  * @type {Date|null}
115
117
  */
116
- this.chatMuteUntil = data.chatMute ? new Date(data.chatMute) : null;
118
+ this.chatMuteUntil = new Date(data.chatMute) ?? null;
117
119
  /**
118
120
  * Timestamp guild chat will be unmuted at.
119
121
  * @type {Array<{ Pattern: string, Color: string }>}
120
122
  */
121
- this.banner = data.banner ? data.banner : null;
123
+ this.banner = data.banner ?? null;
122
124
  /**
123
125
  * Guild tag
124
126
  * @type {string}
125
127
  */
126
- this.tag = data.tag ? data.tag : null;
128
+ this.tag = data.tag ?? null;
127
129
  /**
128
130
  * Guild tag color
129
131
  * @type {Color}
@@ -145,9 +147,9 @@ class Guild {
145
147
  * @type {{winners: number, experienceKings: number, onlinePlayers: number}}
146
148
  */
147
149
  this.achievements = {
148
- winners: data.achievements ? data.achievements.WINNERS : 0,
149
- experienceKings: data.achievements ? data.achievements.EXPERIENCE_KINGS : 0,
150
- onlinePlayers: data.achievements ? data.achievements.ONLINE_PLAYERS : 0
150
+ winners: data.achievements.WINNERS ?? 0,
151
+ experienceKings: data.achievements.EXPERIENCE_KINGS ?? 0,
152
+ onlinePlayers: data.achievements.ONLINE_PLAYERS ?? 0
151
153
  };
152
154
  /**
153
155
  * Guild preferred games
@@ -176,7 +178,9 @@ function members(data) {
176
178
  }
177
179
  // eslint-disable-next-line require-jsdoc
178
180
  function ranks(data) {
179
- return data.ranks && data.ranks.length ? data.ranks.map((r) => new GuildRank(r)).sort((a, b) => a.priority - b.priority) : [];
181
+ return data.ranks && data.ranks.length
182
+ ? data.ranks.map((r) => new GuildRank(r)).sort((a, b) => a.priority - b.priority)
183
+ : [];
180
184
  }
181
185
  // eslint-disable-next-line require-jsdoc
182
186
  function totalWeeklyGexp(data) {
@@ -9,12 +9,12 @@ class GuildMember {
9
9
  constructor(data) {
10
10
  /**
11
11
  * Guild member UUID
12
- * @type {String}
12
+ * @type {string}
13
13
  */
14
14
  this.uuid = data.uuid;
15
15
  /**
16
16
  * Timestamp this member joined at
17
- * @type {Number}
17
+ * @type {number}
18
18
  */
19
19
  this.joinedAtTimestamp = data.joined;
20
20
  /**
@@ -24,19 +24,19 @@ class GuildMember {
24
24
  this.joinedAt = new Date(data.joined);
25
25
  /**
26
26
  * The number of challenges completed that count towards the current quest
27
- * @type {Number}
27
+ * @type {number}
28
28
  */
29
29
  this.questParticipation = data.questParticipation || 0;
30
30
  /**
31
31
  * Member's rank
32
- * @type {String}
32
+ * @type {string}
33
33
  */
34
34
  this.rank = data.rank;
35
35
  /**
36
36
  * Timestamp this member will be unmuted at ( if muted )
37
37
  * @type {Number|null}
38
38
  */
39
- this.mutedUntilTimestamp = data.mutedTill ? data.mutedTill : null;
39
+ this.mutedUntilTimestamp = data.mutedTill ?? null;
40
40
  /**
41
41
  * Timestamp this member will be unmuted at as Date ( if muted )
42
42
  * @type {Date|null}
@@ -50,7 +50,7 @@ class GuildMember {
50
50
  this.expHistory = parseHistory(data.expHistory);
51
51
  /**
52
52
  * Experience per week, resets every Monday at 5 am UTC
53
- * @type {Number}
53
+ * @type {number}
54
54
  */
55
55
  this.weeklyExperience = xpCheck ? Object.values(data.expHistory).reduce((pV, cV) => pV + cV, 0) : null;
56
56
  }
@@ -8,7 +8,7 @@ class GuildRank {
8
8
  constructor(data) {
9
9
  /**
10
10
  * Guild rank name
11
- * @type {String}
11
+ * @type {string}
12
12
  */
13
13
  this.name = data.name;
14
14
  /**
@@ -20,7 +20,7 @@ class GuildRank {
20
20
  * Guild rank tag that appears in guild chat. null if none
21
21
  * @type {string|null}
22
22
  */
23
- this.tag = data.tag ? data.tag : null;
23
+ this.tag = data.tag ?? null;
24
24
  /**
25
25
  * Timestamp this rank was created at
26
26
  * @type {number}
@@ -13,16 +13,6 @@ class Arcade {
13
13
  * @param {Object} data Data from the API
14
14
  */
15
15
  constructor(data = {}) {
16
- /**
17
- * Last Tournament Advertisement as timestamp, only appears when a tournament is announced
18
- * @type {number}
19
- */
20
- this.lastTourneyAdTimestamp = data.lastTourneyAd || undefined;
21
- /**
22
- * Last Tournament Advertisement as Date, only appears when a tournament is announced
23
- * @type {Date}
24
- */
25
- this.lastTourneyAdAt = this.lastTourneyAdTimestamp ? new Date(data.lastTourneyAd) : undefined;
26
16
  /**
27
17
  * Amount of coins
28
18
  * @type {number}
@@ -40,12 +30,12 @@ class Arcade {
40
30
  this.monthlyCoins = parseInt(data[`monthly_coins_${monthAB()}`] || 0, 10);
41
31
  /**
42
32
  * Hints Disabled
43
- * @type {Boolean}
33
+ * @type {boolean}
44
34
  */
45
35
  this.hintsDisabled = !data.hints;
46
36
  /**
47
37
  * Flash Disabled
48
- * @type {Boolean}
38
+ * @type {boolean}
49
39
  */
50
40
  this.flashDisabled = !data.flash;
51
41
  /**
@@ -62,22 +52,34 @@ class Arcade {
62
52
  * Easter Simulator stats
63
53
  * @type {EasterSimulator}
64
54
  */
65
- this.easterSimulator = new BaseGame(data, 'easter_simulator').extend('eggsFound', data.eggs_found_easter_simulator || 0);
55
+ this.easterSimulator = new BaseGame(data, 'easter_simulator').extend(
56
+ 'eggsFound',
57
+ data.eggs_found_easter_simulator || 0
58
+ );
66
59
  /**
67
60
  * Grinch Simulator stats
68
61
  * @type {GrinchSimulator}
69
62
  */
70
- this.grinchSimulator = new BaseGame(data, 'grinch_simulator_v2').extend('giftsFound', data.gifts_grinch_simulator_v2 || 0);
63
+ this.grinchSimulator = new BaseGame(data, 'grinch_simulator_v2').extend(
64
+ 'giftsFound',
65
+ data.gifts_grinch_simulator_v2 || 0
66
+ );
71
67
  /**
72
68
  * Scuba Simulator stats
73
69
  * @type {ScubaSimulator}
74
70
  */
75
- this.scubaSimulator = new BaseGame(data, 'scuba_simulator').extend('itemsFound', data.items_found_scuba_simulator || 0);
71
+ this.scubaSimulator = new BaseGame(data, 'scuba_simulator').extend(
72
+ 'itemsFound',
73
+ data.items_found_scuba_simulator || 0
74
+ );
76
75
  /**
77
76
  * Santa Simulator stats
78
77
  * @type {SantaSimulator}
79
78
  */
80
- this.santaSimulator = new BaseGame(data, 'santa_simulator').extend('giftsDelivered', data.delivered_santa_simulator || 0);
79
+ this.santaSimulator = new BaseGame(data, 'santa_simulator').extend(
80
+ 'giftsDelivered',
81
+ data.delivered_santa_simulator || 0
82
+ );
81
83
  /**
82
84
  * Santa Says stats
83
85
  * @type {BaseGame}
@@ -156,7 +158,10 @@ class Arcade {
156
158
  * OITQ / One In The Quiver stats
157
159
  * @type {OITQ}
158
160
  */
159
- this.oitq = this.oneInTheQuiver = new BaseGame(data, 'oneinthequiver').extend('bountyKills', data.bounty_kills_oneinthequiver || 0);
161
+ this.oitq = this.oneInTheQuiver = new BaseGame(data, 'oneinthequiver').extend(
162
+ 'bountyKills',
163
+ data.bounty_kills_oneinthequiver || 0
164
+ );
160
165
  /**
161
166
  * Zombies
162
167
  * @type {Zombies}
@@ -41,10 +41,10 @@ class BedWars {
41
41
  */
42
42
  constructor(data) {
43
43
  /**
44
- * Coins
44
+ * Tokens
45
45
  * @type {number}
46
46
  */
47
- this.coins = data.coins || 0;
47
+ this.tokens = data.coins || 0;
48
48
  /**
49
49
  * Level
50
50
  * @type {number}
@@ -110,19 +110,6 @@ class BedWars {
110
110
  diamond: data.diamond_resources_collected_bedwars || 0,
111
111
  emerald: data.emerald_resources_collected_bedwars || 0
112
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
113
  /**
127
114
  * Beds lost/broken/BL Ratio
128
115
  * @type {BedWarsBeds}
@@ -200,6 +187,21 @@ class BedWars {
200
187
  * @type {BedWarsModeStats}
201
188
  */
202
189
  this.castle = generateStatsForMode(data, 'castle');
190
+ /**
191
+ * BedWars Practice Stats
192
+ * @type {BedWarsPracticeStats}
193
+ */
194
+ this.practice = generateStatsForPractice(data);
195
+ /**
196
+ * Bedwars Slumber Tickets
197
+ * @type {number}
198
+ */
199
+ this.slumberTickets = data.slumber?.tickets ?? 0;
200
+ /**
201
+ * Bedwars Slumber Total Tickets
202
+ * @type {number}
203
+ */
204
+ this.totalSlumberTicket = data.slumber?.total_tickets ?? 0;
203
205
  }
204
206
  }
205
207
  // eslint-disable-next-line require-jsdoc
@@ -309,6 +311,93 @@ function getLevelForExp(exp) {
309
311
  }
310
312
  return level + Math.floor(expWithoutPrestiges / 5000);
311
313
  }
314
+ // eslint-disable-next-line require-jsdoc
315
+ function generateStatsForPractice(data) {
316
+ return {
317
+ selected: data?.practice?.selected || 'NONE',
318
+ bridging: {
319
+ blocksPlaced: data?.practice?.bridging?.blocks_placed ?? 0,
320
+ attempts: {
321
+ failed: data?.practice?.bridging?.failed_attempts ?? 0,
322
+ successful: data?.practice?.bridging?.successful_attempts ?? 0,
323
+ total: data?.practice?.bridging?.failed_attempts + data?.practice?.bridging?.successful_attempts
324
+ },
325
+ records: {
326
+ '30Blocks': {
327
+ elevation: {
328
+ none: {
329
+ straight: data?.practice?.records?.['bridging_distance_30:elevation_NONE:angle_STRAIGHT:'] ?? 0,
330
+ diagonal: data?.practice?.records?.['bridging_distance_30:elevation_NONE:angle_DIAGONAL:'] ?? 0
331
+ },
332
+ slight: {
333
+ straight: data?.practice?.records?.['bridging_distance_30:elevation_SLIGHT:angle_STRAIGHT:'] ?? 0,
334
+ diagonal: data?.practice?.records?.['bridging_distance_30:elevation_SLIGHT:angle_DIAGONAL:'] ?? 0
335
+ },
336
+ staircase: {
337
+ straight: data?.practice?.records?.['bridging_distance_30:elevation_STAIRCASE:angle_STRAIGHT:'] ?? 0,
338
+ diagonal: data?.practice?.records?.['bridging_distance_30:elevation_STAIRCASE:angle_DIAGONAL:'] ?? 0
339
+ }
340
+ }
341
+ },
342
+ '50Blocks': {
343
+ elevation: {
344
+ none: {
345
+ straight: data?.practice?.records?.['bridging_distance_50:elevation_NONE:angle_STRAIGHT:'] ?? 0,
346
+ diagonal: data?.practice?.records?.['bridging_distance_50:elevation_NONE:angle_DIAGONAL:'] ?? 0
347
+ },
348
+ slight: {
349
+ straight: data?.practice?.records?.['bridging_distance_50:elevation_SLIGHT:angle_STRAIGHT:'] ?? 0,
350
+ diagonal: data?.practice?.records?.['bridging_distance_50:elevation_SLIGHT:angle_DIAGONAL:'] ?? 0
351
+ },
352
+ staircase: {
353
+ straight: data?.practice?.records?.['bridging_distance_50:elevation_STAIRCASE:angle_STRAIGHT:'] ?? 0,
354
+ diagonal: data?.practice?.records?.['bridging_distance_50:elevation_STAIRCASE:angle_DIAGONAL:'] ?? 0
355
+ }
356
+ }
357
+ },
358
+ '100Blocks': {
359
+ elevation: {
360
+ none: {
361
+ straight: data?.practice?.records?.['bridging_distance_100:elevation_NONE:angle_STRAIGHT:'] ?? 0,
362
+ diagonal: data?.practice?.records?.['bridging_distance_100:elevation_NONE:angle_DIAGONAL:'] ?? 0
363
+ },
364
+ slight: {
365
+ straight: data?.practice?.records?.['bridging_distance_100:elevation_SLIGHT:angle_STRAIGHT:'] ?? 0,
366
+ diagonal: data?.practice?.records?.['bridging_distance_100:elevation_SLIGHT:angle_DIAGONAL:'] ?? 0
367
+ },
368
+ staircase: {
369
+ straight: data?.practice?.records?.['bridging_distance_100:elevation_STAIRCASE:angle_STRAIGHT:'] ?? 0,
370
+ diagonal: data?.practice?.records?.['bridging_distance_100:elevation_STAIRCASE:angle_DIAGONAL:'] ?? 0
371
+ }
372
+ }
373
+ }
374
+ }
375
+ },
376
+ fireballJumping: {
377
+ blocksPlaced: data?.practice?.fireball_jumping?.blocks_placed ?? 0,
378
+ attempts: {
379
+ failed: data?.practice?.fireball_jumping?.failed_attempts ?? 0,
380
+ successful: data?.practice?.fireball_jumping?.successful_attempts ?? 0,
381
+ total: data?.practice?.fireball_jumping?.failed_attempts + data?.practice?.fireball_jumping?.successful_attempts
382
+ }
383
+ },
384
+ pearlClutching: {
385
+ attempts: {
386
+ failed: data?.practice?.pearl_clutching?.failed_attempts ?? 0,
387
+ successful: data?.practice?.pearl_clutching?.successful_attempts ?? 0,
388
+ total: data?.practice?.pearl_clutching?.failed_attempts + data?.practice?.pearl_clutching?.successful_attempts
389
+ }
390
+ },
391
+ mlg: {
392
+ blocksPlaced: data?.practice?.mlg?.blocks_placed ?? 0,
393
+ attempts: {
394
+ failed: data?.practice?.mlg?.failed_attempts ?? 0,
395
+ successful: data?.practice?.mlg?.successful_attempts ?? 0,
396
+ total: data?.practice?.mlg?.failed_attempts + data?.practice?.mlg?.successful_attempts
397
+ }
398
+ }
399
+ };
400
+ }
312
401
  /**
313
402
  * @typedef {string} BedWarsPrestige
314
403
  * * `Stone`
@@ -376,15 +465,6 @@ function getLevelForExp(exp) {
376
465
  * @property {number} diamond Diamond
377
466
  * @property {number} emerald Emerald
378
467
  */
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
468
  /**
389
469
  * @typedef {object} BedWarsBeds
390
470
  * @property {number} lost Beds lost
@@ -420,4 +500,52 @@ function getLevelForExp(exp) {
420
500
  * @property {BedWarsModeStats} doubles Doubles
421
501
  * @property {BedWarsModeStats} fours Fours
422
502
  */
503
+ /**
504
+ * @typedef {Object} BedWarsPracticeAttempts
505
+ * @property {number} failed Total failed attempts
506
+ * @property {number} successful Total successful attempts
507
+ * @property {number} total Total Number of attempts
508
+ */
509
+ /**
510
+ * @typedef {Object} BedWarsPracticeElevation
511
+ * @property {number} straight straight
512
+ * @property {number} diagonal diagonal
513
+ */
514
+ /**
515
+ * @typedef {Object} BedWarsPracticeElevations
516
+ * @property {BedWarsPracticeElevation} none none
517
+ * @property {BedWarsPracticeElevation} slight slight
518
+ * @property {BedWarsPracticeElevation} staircase staircase
519
+ */
520
+ /**
521
+ * @typedef {Object} BedWarsPracticeRecord
522
+ * @property {BedWarsPracticeElevations} elevation Elevation
523
+ */
524
+ /**
525
+ * @typedef {Object} BedWarsPracticeRecords
526
+ * @property {BedWarsPracticeRecord} 30Blocks 30 Blocks
527
+ * @property {BedWarsPracticeRecord} 50Blocks 50 Blocks
528
+ * @property {BedWarsPracticeRecord} 100Blocks 100 Blocks
529
+ */
530
+ /**
531
+ * @typedef {Object} BedWarsPracticeBridging
532
+ * @property {number} blocksPlaced Blocks placed
533
+ * @property {BedWarsPracticeAttempts} attempts Attempts
534
+ */
535
+ /**
536
+ * @typedef {Object} BedWarsPracticePearlClutching
537
+ * @property {BedWarsPracticeAttempts} attempts Attempts
538
+ */
539
+ /**
540
+ * @typedef {Object} BedWarsPracticeMLG
541
+ * @property {number} blocksPlaced Blocks placed
542
+ * @property {BedWarsPracticeAttempts} attempts Attempts
543
+ */
544
+ /**
545
+ * @typedef {Object} BedWarsPracticeStats
546
+ * @property {string} selected Selected Type of Practice
547
+ * @property {BedWarsPracticeBridging} bridging Bridging stats
548
+ * @property {BedWarsPracticePearlClutching} pearlClutching Pearl Clutching stats
549
+ * @property {BedWarsPracticeMLG} mlg MLG stats
550
+ */
423
551
  module.exports = BedWars;
@@ -6,6 +6,7 @@ const { duels_divisions } = require('../../utils/Constants');
6
6
 
7
7
  // eslint-disable-next-line require-jsdoc
8
8
  function getDivision(data, mode = null) {
9
+ // eslint-disable-next-line camelcase
9
10
  for (const div of duels_divisions.slice().reverse()) {
10
11
  const prestige = data[`${mode ? mode : 'all_modes'}_${div.key}_title_prestige`];
11
12
  if (prestige) {
@@ -39,10 +40,10 @@ class Duels {
39
40
  */
40
41
  constructor(data) {
41
42
  /**
42
- * Coins
43
+ * Tokens
43
44
  * @type {number}
44
45
  */
45
- this.coins = data.coins || 0;
46
+ this.tokens = data.coins || 0;
46
47
  /**
47
48
  * All modes division
48
49
  * @type {string|null}
@@ -102,19 +103,51 @@ class Duels {
102
103
  division: getDivision(data, 'uhc'),
103
104
  winstreak: data.current_uhc_winstreak || 0,
104
105
  bestWinstreak: data.best_uhc_winstreak || 0,
105
- kills: (data.uhc_duel_kills || 0) + (data.uhc_doubles_kills || 0) + (data.uhc_four_kills || 0) + (data.uhc_meetup_kills || 0),
106
- deaths: (data.uhc_duel_deaths || 0) + (data.uhc_doubles_deaths || 0) + (data.uhc_four_deaths || 0) + (data.uhc_meetup_deaths || 0),
106
+ kills:
107
+ (data.uhc_duel_kills || 0) +
108
+ (data.uhc_doubles_kills || 0) +
109
+ (data.uhc_four_kills || 0) +
110
+ (data.uhc_meetup_kills || 0),
111
+ deaths:
112
+ (data.uhc_duel_deaths || 0) +
113
+ (data.uhc_doubles_deaths || 0) +
114
+ (data.uhc_four_deaths || 0) +
115
+ (data.uhc_meetup_deaths || 0),
107
116
  KDRatio: divide(
108
- (data.uhc_duel_kills || 0) + (data.uhc_doubles_kills || 0) + (data.uhc_four_kills || 0) + (data.uhc_meetup_kills || 0),
109
- (data.uhc_duel_deaths || 0) + (data.uhc_doubles_deaths || 0) + (data.uhc_four_deaths || 0) + (data.uhc_meetup_deaths || 0)
117
+ (data.uhc_duel_kills || 0) +
118
+ (data.uhc_doubles_kills || 0) +
119
+ (data.uhc_four_kills || 0) +
120
+ (data.uhc_meetup_kills || 0),
121
+ (data.uhc_duel_deaths || 0) +
122
+ (data.uhc_doubles_deaths || 0) +
123
+ (data.uhc_four_deaths || 0) +
124
+ (data.uhc_meetup_deaths || 0)
110
125
  ),
111
- wins: (data.uhc_duel_wins || 0) + (data.uhc_doubles_wins || 0) + (data.uhc_four_wins || 0) + (data.uhc_meetup_wins || 0),
112
- losses: (data.uhc_duel_losses || 0) + (data.uhc_doubles_losses || 0) + (data.uhc_four_losses || 0) + (data.uhc_meetup_losses || 0),
126
+ wins:
127
+ (data.uhc_duel_wins || 0) +
128
+ (data.uhc_doubles_wins || 0) +
129
+ (data.uhc_four_wins || 0) +
130
+ (data.uhc_meetup_wins || 0),
131
+ losses:
132
+ (data.uhc_duel_losses || 0) +
133
+ (data.uhc_doubles_losses || 0) +
134
+ (data.uhc_four_losses || 0) +
135
+ (data.uhc_meetup_losses || 0),
113
136
  WLRatio: divide(
114
- (data.uhc_duel_wins || 0) + (data.uhc_doubles_wins || 0) + (data.uhc_four_wins || 0) + (data.uhc_meetup_wins || 0),
115
- (data.uhc_duel_losses || 0) + (data.uhc_doubles_losses || 0) + (data.uhc_four_losses || 0) + (data.uhc_meetup_losses || 0)
137
+ (data.uhc_duel_wins || 0) +
138
+ (data.uhc_doubles_wins || 0) +
139
+ (data.uhc_four_wins || 0) +
140
+ (data.uhc_meetup_wins || 0),
141
+ (data.uhc_duel_losses || 0) +
142
+ (data.uhc_doubles_losses || 0) +
143
+ (data.uhc_four_losses || 0) +
144
+ (data.uhc_meetup_losses || 0)
116
145
  ),
117
- playedGames: (data.uhc_duel_rounds_played || 0) + (data.uhc_doubles_rounds_played || 0) + (data.uhc_four_rounds_played || 0) + (data.uhc_meetup_rounds_played || 0)
146
+ playedGames:
147
+ (data.uhc_duel_rounds_played || 0) +
148
+ (data.uhc_doubles_rounds_played || 0) +
149
+ (data.uhc_four_rounds_played || 0) +
150
+ (data.uhc_meetup_rounds_played || 0)
118
151
  },
119
152
  '1v1': {
120
153
  division: getDivision(data, 'uhc'),
@@ -242,10 +275,16 @@ class Duels {
242
275
  bestWinstreak: data.best_op_winstreak || 0,
243
276
  kills: (data.op_duel_kills || 0) + (data.op_doubles_kills || 0),
244
277
  deaths: (data.op_duel_deaths || 0) + (data.op_doubles_deaths || 0),
245
- KDRatio: divide((data.op_duel_kills || 0) + (data.op_doubles_kills || 0), (data.op_duel_deaths || 0) + (data.op_doubles_deaths || 0)),
278
+ KDRatio: divide(
279
+ (data.op_duel_kills || 0) + (data.op_doubles_kills || 0),
280
+ (data.op_duel_deaths || 0) + (data.op_doubles_deaths || 0)
281
+ ),
246
282
  wins: (data.op_duel_wins || 0) + (data.op_doubles_wins || 0),
247
283
  losses: (data.op_duel_losses || 0) + (data.op_doubles_losses || 0),
248
- WLRatio: divide((data.op_duel_wins || 0) + (data.op_doubles_wins || 0), (data.op_duel_losses || 0) + (data.op_doubles_losses || 0)),
284
+ WLRatio: divide(
285
+ (data.op_duel_wins || 0) + (data.op_doubles_wins || 0),
286
+ (data.op_duel_losses || 0) + (data.op_doubles_losses || 0)
287
+ ),
249
288
  playedGames: (data.op_duel_rounds_played || 0) + (data.op_doubles_rounds_played || 0)
250
289
  },
251
290
  '1v1': {
@@ -284,10 +323,16 @@ class Duels {
284
323
  bestWinstreak: data.best_skywars_winstreak || 0,
285
324
  kills: (data.sw_duel_kills || 0) + (data.sw_doubles_kills || 0),
286
325
  deaths: (data.sw_duel_deaths || 0) + (data.sw_doubles_deaths || 0),
287
- KDRatio: divide((data.sw_duel_kills || 0) + (data.sw_doubles_kills || 0), (data.sw_duel_deaths || 0) + (data.sw_doubles_deaths || 0)),
326
+ KDRatio: divide(
327
+ (data.sw_duel_kills || 0) + (data.sw_doubles_kills || 0),
328
+ (data.sw_duel_deaths || 0) + (data.sw_doubles_deaths || 0)
329
+ ),
288
330
  wins: (data.sw_duel_wins || 0) + (data.sw_doubles_wins || 0),
289
331
  losses: (data.sw_duel_losses || 0) + (data.sw_doubles_losses || 0),
290
- WLRatio: divide((data.sw_duel_wins || 0) + (data.sw_doubles_wins || 0), (data.sw_duel_losses || 0) + (data.sw_doubles_losses || 0)),
332
+ WLRatio: divide(
333
+ (data.sw_duel_wins || 0) + (data.sw_doubles_wins || 0),
334
+ (data.sw_duel_losses || 0) + (data.sw_doubles_losses || 0)
335
+ ),
291
336
  playedGames: (data.sw_duel_rounds_played || 0) + (data.sw_doubles_rounds_played || 0)
292
337
  },
293
338
  '1v1': {
@@ -443,7 +488,15 @@ class Duels {
443
488
  (data.bridge_3v3v3v3_rounds_played || 0) +
444
489
  (data.bridge_four_rounds_played || 0) +
445
490
  (data.bridge_threes_bridge_rounds_played || 0) +
446
- (data.capture_threes_rounds_played || 0)
491
+ (data.capture_threes_rounds_played || 0),
492
+ goals:
493
+ (data.bridge_duel_goals || 0) +
494
+ (data.bridge_doubles_goals || 0) +
495
+ (data.bridge_2v2v2v2_goals || 0) +
496
+ (data.bridge_3v3v3v3_goals || 0) +
497
+ (data.bridge_four_goals || 0) +
498
+ (data.bridge_threes_bridge_goals || 0) +
499
+ (data.capture_threes_goals || 0)
447
500
  },
448
501
  '1v1': {
449
502
  division: getDivision(data, 'bridge'),
@@ -455,7 +508,8 @@ class Duels {
455
508
  wins: data.bridge_duel_wins || 0,
456
509
  losses: data.bridge_duel_losses || 0,
457
510
  WLRatio: divide(data.bridge_duel_wins, data.bridge_duel_losses),
458
- playedGames: data.bridge_duel_rounds_played || 0
511
+ playedGames: data.bridge_duel_rounds_played || 0,
512
+ goals: data.bridge_duel_goals || 0
459
513
  },
460
514
  '2v2': {
461
515
  division: getDivision(data, 'bridge'),
@@ -467,7 +521,8 @@ class Duels {
467
521
  wins: data.bridge_doubles_wins || 0,
468
522
  losses: data.bridge_doubles_losses || 0,
469
523
  WLRatio: divide(data.bridge_doubles_wins, data.bridge_doubles_losses),
470
- playedGames: data.bridge_doubles_rounds_played || 0
524
+ playedGames: data.bridge_doubles_rounds_played || 0,
525
+ goals: data.bridge_doubles_goals || 0
471
526
  },
472
527
  '3v3': {
473
528
  division: getDivision(data, 'bridge'),
@@ -479,7 +534,8 @@ class Duels {
479
534
  wins: data.bridge_threes_wins || 0,
480
535
  losses: data.bridge_threes_losses || 0,
481
536
  WLRatio: divide(data.bridge_threes_wins, data.bridge_threes_losses),
482
- playedGames: data.bridge_threes_rounds_played || 0
537
+ playedGames: data.bridge_threes_rounds_played || 0,
538
+ goals: data.bridge_threes_goals || 0
483
539
  },
484
540
  '2v2v2v2': {
485
541
  division: getDivision(data, 'bridge'),
@@ -491,7 +547,8 @@ class Duels {
491
547
  wins: data.bridge_2v2v2v2_wins || 0,
492
548
  losses: data.bridge_2v2v2v2_losses || 0,
493
549
  WLRatio: divide(data.bridge_2v2v2v2_wins, data.bridge_2v2v2v2_losses),
494
- playedGames: data.bridge_2v2v2v2_rounds_played || 0
550
+ playedGames: data.bridge_2v2v2v2_rounds_played || 0,
551
+ goals: data.bridge_2v2v2v2_goals || 0
495
552
  },
496
553
  '3v3v3v3': {
497
554
  division: getDivision(data, 'bridge'),
@@ -503,7 +560,8 @@ class Duels {
503
560
  wins: data.bridge_3v3v3v3_wins || 0,
504
561
  losses: data.bridge_3v3v3v3_losses || 0,
505
562
  WLRatio: divide(data.bridge_3v3v3v3_wins, data.bridge_3v3v3v3_losses),
506
- playedGames: data.bridge_3v3v3v3_rounds_played || 0
563
+ playedGames: data.bridge_3v3v3v3_rounds_played || 0,
564
+ goals: data.bridge_3v3v3v3_goals || 0
507
565
  },
508
566
  '4v4': {
509
567
  division: getDivision(data, 'bridge'),
@@ -515,7 +573,8 @@ class Duels {
515
573
  wins: data.bridge_four_wins || 0,
516
574
  losses: data.bridge_four_losses || 0,
517
575
  WLRatio: divide(data.bridge_four_wins, data.bridge_four_losses),
518
- playedGames: data.bridge_four_rounds_played || 0
576
+ playedGames: data.bridge_four_rounds_played || 0,
577
+ goals: data.bridge_four_goals || 0
519
578
  },
520
579
  // eslint-disable-next-line quote-props
521
580
  ctf: {
@@ -527,7 +586,8 @@ class Duels {
527
586
  losses: data.capture_threes_losses || 0,
528
587
  WLRatio: divide(data.capture_threes_wins, data.capture_threes_losses),
529
588
  captures: data.capture_threes_captures || 0,
530
- playedGames: data.capture_threes_rounds_played || 0
589
+ playedGames: data.capture_threes_rounds_played || 0,
590
+ goals: data.capture_threes_goals || 0
531
591
  }
532
592
  };
533
593
  /**
@@ -605,6 +665,7 @@ class Duels {
605
665
  * @property {number} KDRatio Kill/Death ratio
606
666
  * @property {number} WLRatio Win/Loss ratio
607
667
  * @property {number} playedGames Played games
668
+ * @property {number} goals Goals
608
669
  */
609
670
  /**
610
671
  * @typedef {object} DuelsBowspleef