hypixel-api-reborn 11.2.0 → 11.3.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 (101) hide show
  1. package/README.md +1 -1
  2. package/eslint.config.mjs +71 -0
  3. package/package.json +14 -20
  4. package/src/API/getAchievements.js +1 -0
  5. package/src/API/getBoosters.js +1 -0
  6. package/src/API/getChallenges.js +1 -0
  7. package/src/API/getGameCounts.js +1 -0
  8. package/src/API/getGuild.js +4 -3
  9. package/src/API/getGuildAchievements.js +1 -0
  10. package/src/API/getLeaderboards.js +1 -1
  11. package/src/API/getPlayer.js +1 -0
  12. package/src/API/getQuests.js +1 -0
  13. package/src/API/getRecentGames.js +5 -9
  14. package/src/API/getServerInfo.js +40 -37
  15. package/src/API/getStatus.js +1 -0
  16. package/src/API/getWatchdogStats.js +1 -0
  17. package/src/API/housing/getActiveHouses.js +7 -0
  18. package/src/API/housing/getHouse.js +9 -0
  19. package/src/API/housing/getPlayerHouses.js +11 -0
  20. package/src/API/index.js +6 -1
  21. package/src/API/skyblock/getAuction.js +8 -6
  22. package/src/API/skyblock/getAuctions.js +15 -12
  23. package/src/API/skyblock/getAuctionsByPlayer.js +1 -1
  24. package/src/API/skyblock/getBazaar.js +1 -3
  25. package/src/API/skyblock/getBingo.js +1 -2
  26. package/src/API/skyblock/getBingoByPlayer.js +3 -3
  27. package/src/API/skyblock/getEndedAuctions.js +1 -0
  28. package/src/API/skyblock/getFireSales.js +1 -1
  29. package/src/API/skyblock/getGarden.js +7 -0
  30. package/src/API/skyblock/getGovernment.js +1 -2
  31. package/src/API/skyblock/getMember.js +5 -2
  32. package/src/API/skyblock/getMuseum.js +1 -0
  33. package/src/API/skyblock/getNews.js +1 -0
  34. package/src/API/skyblock/getProfiles.js +5 -2
  35. package/src/Client.js +88 -16
  36. package/src/Private/rateLimit.js +7 -11
  37. package/src/Private/requests.js +12 -13
  38. package/src/Private/updater.js +2 -3
  39. package/src/Private/uuidCache.js +1 -2
  40. package/src/Private/validate.js +19 -19
  41. package/src/index.js +5 -0
  42. package/src/structures/APIIncident.js +1 -2
  43. package/src/structures/APIStatus.js +0 -1
  44. package/src/structures/Boosters/Booster.js +9 -8
  45. package/src/structures/Game.js +1 -1
  46. package/src/structures/Guild/Guild.js +19 -36
  47. package/src/structures/Guild/GuildMember.js +2 -2
  48. package/src/structures/House.js +54 -0
  49. package/src/structures/MiniGames/Arcade.js +798 -312
  50. package/src/structures/MiniGames/ArenaBrawl.js +98 -32
  51. package/src/structures/MiniGames/BedWars.js +197 -194
  52. package/src/structures/MiniGames/BlitzSurvivalGames.js +381 -129
  53. package/src/structures/MiniGames/BuildBattle.js +19 -8
  54. package/src/structures/MiniGames/CopsAndCrims.js +253 -25
  55. package/src/structures/MiniGames/Duels.js +905 -664
  56. package/src/structures/MiniGames/MegaWalls.js +390 -51
  57. package/src/structures/MiniGames/MurderMystery.js +151 -30
  58. package/src/structures/MiniGames/Paintball.js +31 -11
  59. package/src/structures/MiniGames/Pit.js +4 -5
  60. package/src/structures/MiniGames/Quakecraft.js +113 -50
  61. package/src/structures/MiniGames/SkyWars.js +528 -372
  62. package/src/structures/MiniGames/SmashHeroes.js +201 -73
  63. package/src/structures/MiniGames/SpeedUHC.js +77 -24
  64. package/src/structures/MiniGames/TNTGames.js +242 -73
  65. package/src/structures/MiniGames/TurboKartRacers.js +55 -115
  66. package/src/structures/MiniGames/UHC.js +144 -132
  67. package/src/structures/MiniGames/VampireZ.js +70 -37
  68. package/src/structures/MiniGames/Warlords.js +126 -1
  69. package/src/structures/MiniGames/WoolWars.js +60 -9
  70. package/src/structures/Pet.js +1 -1
  71. package/src/structures/Player.js +43 -128
  72. package/src/structures/PlayerCosmetics.js +5 -4
  73. package/src/structures/SkyBlock/Auctions/AuctionInfo.js +2 -1
  74. package/src/structures/SkyBlock/Auctions/BaseAuction.js +1 -1
  75. package/src/structures/SkyBlock/News/SkyblockNews.js +15 -15
  76. package/src/structures/SkyBlock/PlayerBingo.js +7 -14
  77. package/src/structures/SkyBlock/SkyblockGarden.js +146 -0
  78. package/src/structures/SkyBlock/SkyblockInventoryItem.js +4 -28
  79. package/src/structures/SkyBlock/SkyblockMember.js +90 -228
  80. package/src/structures/SkyBlock/SkyblockPet.js +3 -4
  81. package/src/structures/SkyBlock/Static/Bingo.js +10 -11
  82. package/src/structures/SkyBlock/Static/BingoData.js +1 -1
  83. package/src/structures/Static/Achievement.js +16 -15
  84. package/src/structures/Static/AchievementTier.js +2 -2
  85. package/src/structures/Static/Quest.js +2 -2
  86. package/src/utils/Constants.js +522 -520
  87. package/src/utils/{guildExp.js → Guild.js} +42 -12
  88. package/src/utils/Player.js +112 -0
  89. package/src/utils/SkyblockUtils.js +482 -192
  90. package/src/utils/arrayTools.js +1 -1
  91. package/src/utils/divide.js +1 -1
  92. package/src/utils/index.js +2 -1
  93. package/src/utils/isGuildID.js +1 -1
  94. package/src/utils/oscillation.js +4 -2
  95. package/src/utils/removeSnakeCase.js +11 -7
  96. package/src/utils/rgbToHexColor.js +1 -1
  97. package/src/utils/romanize.js +3 -3
  98. package/src/utils/toUuid.js +4 -4
  99. package/src/utils/varInt.js +2 -2
  100. package/typings/index.d.ts +1186 -967
  101. package/src/utils/toIGN.js +0 -24
@@ -1,36 +1,811 @@
1
- /* eslint-disable max-len */
2
- const divide = require('../../utils/divide');
1
+ const { duelsDivisions } = require('../../utils/Constants');
3
2
  const romanize = require('../../utils/romanize');
4
- // eslint-disable-next-line camelcase
5
- const { duels_divisions } = require('../../utils/Constants');
3
+ const divide = require('../../utils/divide');
6
4
 
7
- // eslint-disable-next-line require-jsdoc
8
- function getDivision(data, mode = null) {
9
- // eslint-disable-next-line camelcase
10
- for (const div of duels_divisions.slice().reverse()) {
5
+ // eslint-disable-next-line jsdoc/require-jsdoc
6
+ function getTitle(data, mode = null) {
7
+ for (const div of duelsDivisions.slice().reverse()) {
11
8
  const prestige = data[`${mode ? mode : 'all_modes'}_${div.key}_title_prestige`];
12
9
  if (prestige) {
13
10
  return `${div.name} ${romanize(prestige)}`;
14
11
  }
15
12
  }
16
- return null;
13
+ return null;
14
+ }
15
+
16
+ class DuelsGamemode {
17
+ /**
18
+ * @param {object} data Duels data
19
+ */
20
+ constructor(data, mode, title = '') {
21
+ /**
22
+ * Title
23
+ * @type {string}
24
+ */
25
+ this.title = title;
26
+ /**
27
+ * Winstreak
28
+ * @type {number}
29
+ */
30
+ this.winstreak = data[`current_winstreak_mode_${mode}`] || 0;
31
+ /**
32
+ * Best Winstreak
33
+ * @type {number}
34
+ */
35
+ this.bestWinstreak = data[`best_winstreak_mode_${mode}`] || 0;
36
+ /**
37
+ * Kills
38
+ * @type {number}
39
+ */
40
+ this.kills = data[`${mode}_kills`] || 0;
41
+ /**
42
+ * Deaths
43
+ * @type {number}
44
+ */
45
+ this.deaths = data[`${mode}_deaths`] || 0;
46
+ /**
47
+ * KDRatio
48
+ * @type {number}
49
+ */
50
+ this.KDRatio = divide(this.kills, this.deaths);
51
+ /**
52
+ * Wins
53
+ * @type {number}
54
+ */
55
+ this.wins = data[`${mode}_wins`] || 0;
56
+ /**
57
+ * Losses
58
+ * @type {number}
59
+ */
60
+ this.losses = data[`${mode}_losses`] || 0;
61
+ /**
62
+ * WLRatio
63
+ * @type {number}
64
+ */
65
+ this.WLRatio = divide(this.wins, this.losses);
66
+ /**
67
+ * Played Games
68
+ * @type {number}
69
+ */
70
+ this.playedGames = data[`${mode}_rounds_played`] || 0;
71
+ /**
72
+ * Swings
73
+ * @type {number}
74
+ */
75
+ this.swings = data[`${mode}_melee_swings`] || 0;
76
+ /**
77
+ * Hits
78
+ * @type {number}
79
+ */
80
+ this.hits = data[`${mode}_melee_hits`] || 0;
81
+ /**
82
+ * Melee Accuracy
83
+ * @type {number}
84
+ */
85
+ this.meleeAccuracy = divide(this.swings, this.hits);
86
+ /**
87
+ * Bow Shots
88
+ * @type {number}
89
+ */
90
+ this.bowShots = data[`${mode}_bow_shots`] || 0;
91
+ /**
92
+ * Bow Hits
93
+ * @type {number}
94
+ */
95
+ this.bowHits = data[`${mode}_bow_hits`] || 0;
96
+ /**
97
+ * Bow Accuracy
98
+ * @type {number}
99
+ */
100
+ this.bowAccuracy = divide(this.bowShots, this.bowHits);
101
+ /**
102
+ * Blocks Placed
103
+ * @type {number}
104
+ */
105
+ this.blocksPlaced = data[`${mode}_blocks_placed`] || 0;
106
+ /**
107
+ * Health Regenerated
108
+ * @type {number}
109
+ */
110
+ this.healthRegenerated = data[`${mode}_health_regenerated`] || 0;
111
+ /**
112
+ * Golden Apples Eatan
113
+ * @type {number}
114
+ */
115
+ this.goldenApplesEatan = data[`${mode}_golden_apples_eaten`] || 0;
116
+ }
117
+ }
118
+
119
+ class DuelsUHC {
120
+ /**
121
+ * @param {object} data Duels data
122
+ */
123
+ constructor(data) {
124
+ /**
125
+ * Title
126
+ * @type {string}
127
+ */
128
+ this.title = getTitle(data, 'uhc');
129
+ /**
130
+ * Winstreak
131
+ * @type {number}
132
+ */
133
+ this.winstreak = data.current_uhc_winstreak || 0;
134
+ /**
135
+ * Best Winstreak
136
+ * @type {number}
137
+ */
138
+ this.bestWinstreak = data.best_uhc_winstreak || 0;
139
+ /**
140
+ * Solo Game Mode Stats
141
+ * @type {DuelsGamemode}
142
+ */
143
+ this.solo = new DuelsGamemode(data, 'uhc_duel', this.title);
144
+ /**
145
+ * Doubles Game Mode Stats
146
+ * @type {DuelsGamemode}
147
+ */
148
+ this.doubles = new DuelsGamemode(data, 'uhc_doubles', this.title);
149
+ /**
150
+ * Fours Game Mode Stats
151
+ * @type {DuelsGamemode}
152
+ */
153
+ this.fours = new DuelsGamemode(data, 'uhc_four', this.title);
154
+ /**
155
+ * Deathmatch Game Mode Stats
156
+ * @type {DuelsGamemode}
157
+ */
158
+ this.deathmatch = new DuelsGamemode(data, 'uhc_meetup', this.title);
159
+ /**
160
+ * Kills
161
+ * @type {number}
162
+ */
163
+ this.kills = this.solo.kills + this.doubles.kills + this.fours.kills + this.deathmatch.kills;
164
+ /**
165
+ * Deaths
166
+ * @type {number}
167
+ */
168
+ this.deaths = this.solo.deaths + this.doubles.deaths + this.fours.deaths + this.deathmatch.deaths;
169
+ /**
170
+ * KDRatio
171
+ * @type {number}
172
+ */
173
+ this.KDRatio = divide(this.kills, this.deaths);
174
+ /**
175
+ * Wins
176
+ * @type {number}
177
+ */
178
+ this.wins = this.solo.wins + this.doubles.wins + this.fours.wins + this.deathmatch.wins;
179
+ /**
180
+ * Losses
181
+ * @type {number}
182
+ */
183
+ this.losses = this.solo.losses + this.doubles.losses + this.fours.losses + this.deathmatch.losses;
184
+ /**
185
+ * WLRatio
186
+ * @type {number}
187
+ */
188
+ this.WLRatio = divide(this.wins, this.losses);
189
+ /**
190
+ * Played Games
191
+ * @type {number}
192
+ */
193
+ this.playedGames =
194
+ this.solo.playedGames + this.doubles.playedGames + this.fours.playedGames + this.deathmatch.playedGames;
195
+ /**
196
+ * Swings
197
+ * @type {number}
198
+ */
199
+ this.swings = this.solo.swings + this.doubles.swings + this.fours.swings + this.deathmatch.swings;
200
+ /**
201
+ * Hits
202
+ * @type {number}
203
+ */
204
+ this.hits = this.solo.hits + this.doubles.hits + this.fours.hits + this.deathmatch.hits;
205
+ /**
206
+ * Melee Accuracy
207
+ * @type {number}
208
+ */
209
+ this.meleeAccuracy = divide(this.hits, this.swings);
210
+ /**
211
+ * Bow Shots
212
+ * @type {number}
213
+ */
214
+ this.bowShots = this.solo.bowShots + this.doubles.bowShots + this.fours.bowShots + this.deathmatch.bowShots;
215
+ /**
216
+ * Bow Hits
217
+ * @type {number}
218
+ */
219
+ this.bowHits = this.solo.bowHits + this.doubles.bowHits + this.fours.bowHits + this.deathmatch.bowHits;
220
+ /**
221
+ * Bow Accuracy
222
+ * @type {number}
223
+ */
224
+ this.bowAccuracy = divide(this.bowHits, this.bowShots);
225
+ /**
226
+ * Blocks Placed
227
+ * @type {number}
228
+ */
229
+ this.blocksPlaced =
230
+ this.solo.blocksPlaced + this.doubles.blocksPlaced + this.fours.blocksPlaced + this.deathmatch.blocksPlaced;
231
+ /**
232
+ * Health Regenerated
233
+ * @type {number}
234
+ */
235
+ this.healthRegenerated =
236
+ this.solo.healthRegenerated +
237
+ this.doubles.healthRegenerated +
238
+ this.fours.healthRegenerated +
239
+ this.deathmatch.healthRegenerated;
240
+ /**
241
+ * Golden Apples Eatan
242
+ * @type {number}
243
+ */
244
+ this.goldenApplesEatan =
245
+ this.solo.goldenApplesEatan +
246
+ this.doubles.goldenApplesEatan +
247
+ this.fours.goldenApplesEatan +
248
+ this.deathmatch.goldenApplesEatan;
249
+ }
250
+ }
251
+ class DuelsSkyWars {
252
+ /**
253
+ * @param {object} data Duels data
254
+ */
255
+ constructor(data) {
256
+ /**
257
+ * Title
258
+ * @type {string}
259
+ */
260
+ this.title = getTitle(data, 'sw');
261
+ /**
262
+ * Winstreak
263
+ * @type {number}
264
+ */
265
+ this.winstreak = data.current_sw_winstreak || 0;
266
+ /**
267
+ * Best Winstreak
268
+ * @type {number}
269
+ */
270
+ this.bestWinstreak = data.best_sw_winstreak || 0;
271
+ /**
272
+ * Solo Game Mode Stats
273
+ * @type {DuelsGamemode}
274
+ */
275
+ this.solo = new DuelsGamemode(data, 'sw_duel', this.title);
276
+ /**
277
+ * Doubles Game Mode Stats
278
+ * @type {DuelsGamemode}
279
+ */
280
+ this.doubles = new DuelsGamemode(data, 'sw_doubles', this.title);
281
+ /**
282
+ * Kills
283
+ * @type {number}
284
+ */
285
+ this.kills = this.solo.kills + this.doubles.kills;
286
+ /**
287
+ * Deaths
288
+ * @type {number}
289
+ */
290
+ this.deaths = this.solo.deaths + this.doubles.deaths;
291
+ /**
292
+ * KDRatio
293
+ * @type {number}
294
+ */
295
+ this.KDRatio = divide(this.kills, this.deaths);
296
+ /**
297
+ * Wins
298
+ * @type {number}
299
+ */
300
+ this.wins = this.solo.wins + this.doubles.wins;
301
+ /**
302
+ * Losses
303
+ * @type {number}
304
+ */
305
+ this.losses = this.solo.losses + this.doubles.losses;
306
+ /**
307
+ * WLRatio
308
+ * @type {number}
309
+ */
310
+ this.WLRatio = divide(this.wins, this.losses);
311
+ /**
312
+ * Played Games
313
+ * @type {number}
314
+ */
315
+ this.playedGames = this.solo.playedGames + this.doubles.playedGames;
316
+ /**
317
+ * Swings
318
+ * @type {number}
319
+ */
320
+ this.swings = this.solo.swings + this.doubles.swings;
321
+ /**
322
+ * Hits
323
+ * @type {number}
324
+ */
325
+ this.hits = this.solo.hits + this.doubles.hits;
326
+ /**
327
+ * Melee Accuracy
328
+ * @type {number}
329
+ */
330
+ this.meleeAccuracy = divide(this.hits, this.swings);
331
+ /**
332
+ * Bow Shots
333
+ * @type {number}
334
+ */
335
+ this.bowShots = this.solo.bowShots + this.doubles.bowShots;
336
+ /**
337
+ * Bow Hits
338
+ * @type {number}
339
+ */
340
+ this.bowHits = this.solo.bowHits + this.doubles.bowHits;
341
+ /**
342
+ * Bow Accuracy
343
+ * @type {number}
344
+ */
345
+ this.bowAccuracy = divide(this.bowHits, this.bowShots);
346
+ /**
347
+ * Blocks Placed
348
+ * @type {number}
349
+ */
350
+ this.blocksPlaced = this.solo.blocksPlaced + this.doubles.blocksPlaced;
351
+ /**
352
+ * Health Regenerated
353
+ * @type {number}
354
+ */
355
+ this.healthRegenerated = this.solo.healthRegenerated + this.doubles.healthRegenerated;
356
+ /**
357
+ * Golden Apples Eatan
358
+ * @type {number}
359
+ */
360
+ this.goldenApplesEatan = this.solo.goldenApplesEatan + this.doubles.goldenApplesEatan;
361
+ }
362
+ }
363
+ class DuelsMegaWalls {
364
+ /**
365
+ * @param {object} data Duels data
366
+ */
367
+ constructor(data) {
368
+ /**
369
+ * Title
370
+ * @type {string}
371
+ */
372
+ this.title = getTitle(data, 'mega_walls');
373
+ /**
374
+ * Winstreak
375
+ * @type {number}
376
+ */
377
+ this.winstreak = data.current_mega_walls_winstreak || 0;
378
+ /**
379
+ * Best Winstreak
380
+ * @type {number}
381
+ */
382
+ this.bestWinstreak = data.best_mega_walls_winstreak || 0;
383
+ /**
384
+ * Solo Game Mode Stats
385
+ * @type {DuelsGamemode}
386
+ */
387
+ this.solo = new DuelsGamemode(data, 'mw_duel', this.title);
388
+ /**
389
+ * Doubles Game Mode Stats
390
+ * @type {DuelsGamemode}
391
+ */
392
+ this.doubles = new DuelsGamemode(data, 'mw_doubles', this.title);
393
+ /**
394
+ * Kills
395
+ * @type {number}
396
+ */
397
+ this.kills = this.solo.kills + this.doubles.kills;
398
+ /**
399
+ * Deaths
400
+ * @type {number}
401
+ */
402
+ this.deaths = this.solo.deaths + this.doubles.deaths;
403
+ /**
404
+ * KDRatio
405
+ * @type {number}
406
+ */
407
+ this.KDRatio = divide(this.kills, this.deaths);
408
+ /**
409
+ * Wins
410
+ * @type {number}
411
+ */
412
+ this.wins = this.solo.wins + this.doubles.wins;
413
+ /**
414
+ * Losses
415
+ * @type {number}
416
+ */
417
+ this.losses = this.solo.losses + this.doubles.losses;
418
+ /**
419
+ * WLRatio
420
+ * @type {number}
421
+ */
422
+ this.WLRatio = divide(this.wins, this.losses);
423
+ /**
424
+ * Played Games
425
+ * @type {number}
426
+ */
427
+ this.playedGames = this.solo.playedGames + this.doubles.playedGames;
428
+ /**
429
+ * Swings
430
+ * @type {number}
431
+ */
432
+ this.swings = this.solo.swings + this.doubles.swings;
433
+ /**
434
+ * Hits
435
+ * @type {number}
436
+ */
437
+ this.hits = this.solo.hits + this.doubles.hits;
438
+ /**
439
+ * Melee Accuracy
440
+ * @type {number}
441
+ */
442
+ this.meleeAccuracy = divide(this.hits, this.swings);
443
+ /**
444
+ * Bow Shots
445
+ * @type {number}
446
+ */
447
+ this.bowShots = this.solo.bowShots + this.doubles.bowShots;
448
+ /**
449
+ * Bow Hits
450
+ * @type {number}
451
+ */
452
+ this.bowHits = this.solo.bowHits + this.doubles.bowHits;
453
+ /**
454
+ * Bow Accuracy
455
+ * @type {number}
456
+ */
457
+ this.bowAccuracy = divide(this.bowHits, this.bowShots);
458
+ /**
459
+ * Blocks Placed
460
+ * @type {number}
461
+ */
462
+ this.blocksPlaced = this.solo.blocksPlaced + this.doubles.blocksPlaced;
463
+ /**
464
+ * Health Regenerated
465
+ * @type {number}
466
+ */
467
+ this.healthRegenerated = this.solo.healthRegenerated + this.doubles.healthRegenerated;
468
+ /**
469
+ * Golden Apples Eatan
470
+ * @type {number}
471
+ */
472
+ this.goldenApplesEatan = this.solo.goldenApplesEatan + this.doubles.goldenApplesEatan;
473
+ }
17
474
  }
18
- // eslint-disable-next-line require-jsdoc
19
- function getTotalKillsDeaths(data) {
20
- let totalDeaths = 0;
21
- let totalKills = 0;
22
- for (const [k, v] of Object.entries(data)) {
23
- if (k.includes('deaths') && k !== 'deaths') {
24
- totalDeaths += v;
25
- } else if (k.includes('kills') && k !== 'kills') {
26
- totalKills += v;
27
- }
475
+ class DuelsOP {
476
+ /**
477
+ * @param {object} data Duels data
478
+ */
479
+ constructor(data) {
480
+ /**
481
+ * Title
482
+ * @type {string}
483
+ */
484
+ this.title = getTitle(data, 'op');
485
+ /**
486
+ * Winstreak
487
+ * @type {number}
488
+ */
489
+ this.winstreak = data.current_op_winstreak || 0;
490
+ /**
491
+ * Best Winstreak
492
+ * @type {number}
493
+ */
494
+ this.bestWinstreak = data.best_op_winstreak || 0;
495
+ /**
496
+ * Solo Game Mode Stats
497
+ * @type {DuelsGamemode}
498
+ */
499
+ this.solo = new DuelsGamemode(data, 'op_duel', this.title);
500
+ /**
501
+ * Doubles Game Mode Stats
502
+ * @type {DuelsGamemode}
503
+ */
504
+ this.doubles = new DuelsGamemode(data, 'op_doubles', this.title);
505
+ /**
506
+ * Kills
507
+ * @type {number}
508
+ */
509
+ this.kills = this.solo.kills + this.doubles.kills;
510
+ /**
511
+ * Deaths
512
+ * @type {number}
513
+ */
514
+ this.deaths = this.solo.deaths + this.doubles.deaths;
515
+ /**
516
+ * KDRatio
517
+ * @type {number}
518
+ */
519
+ this.KDRatio = divide(this.kills, this.deaths);
520
+ /**
521
+ * Wins
522
+ * @type {number}
523
+ */
524
+ this.wins = this.solo.wins + this.doubles.wins;
525
+ /**
526
+ * Losses
527
+ * @type {number}
528
+ */
529
+ this.losses = this.solo.losses + this.doubles.losses;
530
+ /**
531
+ * WLRatio
532
+ * @type {number}
533
+ */
534
+ this.WLRatio = divide(this.wins, this.losses);
535
+ /**
536
+ * Played Games
537
+ * @type {number}
538
+ */
539
+ this.playedGames = this.solo.playedGames + this.doubles.playedGames;
540
+ /**
541
+ * Swings
542
+ * @type {number}
543
+ */
544
+ this.swings = this.solo.swings + this.doubles.swings;
545
+ /**
546
+ * Hits
547
+ * @type {number}
548
+ */
549
+ this.hits = this.solo.hits + this.doubles.hits;
550
+ /**
551
+ * Melee Accuracy
552
+ * @type {number}
553
+ */
554
+ this.meleeAccuracy = divide(this.hits, this.swings);
555
+ /**
556
+ * Bow Shots
557
+ * @type {number}
558
+ */
559
+ this.bowShots = this.solo.bowShots + this.doubles.bowShots;
560
+ /**
561
+ * Bow Hits
562
+ * @type {number}
563
+ */
564
+ this.bowHits = this.solo.bowHits + this.doubles.bowHits;
565
+ /**
566
+ * Bow Accuracy
567
+ * @type {number}
568
+ */
569
+ this.bowAccuracy = divide(this.bowHits, this.bowShots);
570
+ /**
571
+ * Blocks Placed
572
+ * @type {number}
573
+ */
574
+ this.blocksPlaced = this.solo.blocksPlaced + this.doubles.blocksPlaced;
575
+ /**
576
+ * Health Regenerated
577
+ * @type {number}
578
+ */
579
+ this.healthRegenerated = this.solo.healthRegenerated + this.doubles.healthRegenerated;
580
+ /**
581
+ * Golden Apples Eatan
582
+ * @type {number}
583
+ */
584
+ this.goldenApplesEatan = this.solo.goldenApplesEatan + this.doubles.goldenApplesEatan;
585
+ }
586
+ }
587
+ class DuelsBridge {
588
+ /**
589
+ * @param {object} data Duels data
590
+ */
591
+ constructor(data) {
592
+ /**
593
+ * Title
594
+ * @type {string}
595
+ */
596
+ this.title = getTitle(data, 'bridge');
597
+ /**
598
+ * Winstreak
599
+ * @type {number}
600
+ */
601
+ this.winstreak = data.current_bridge_winstreak || 0;
602
+ /**
603
+ * Best Winstreak
604
+ * @type {number}
605
+ */
606
+ this.bestWinstreak = data.best_bridge_winstreak || 0;
607
+ /**
608
+ * Solo Game Mode Stats
609
+ * @type {DuelsGamemode}
610
+ */
611
+ this.solo = new DuelsGamemode(data, 'bridge_duel', this.title);
612
+ /**
613
+ * Doubles Game Mode Stats
614
+ * @type {DuelsGamemode}
615
+ */
616
+ this.doubles = new DuelsGamemode(data, 'bridge_doubles', this.title);
617
+ /**
618
+ * Threes Game Mode Stats
619
+ * @type {DuelsGamemode}
620
+ */
621
+ this.threes = new DuelsGamemode(data, 'bridge_threes', this.title);
622
+ /**
623
+ * Fours Game Mode Stats
624
+ * @type {DuelsGamemode}
625
+ */
626
+ this.fours = new DuelsGamemode(data, 'bridge_fours', this.title);
627
+ /**
628
+ * 2v2v2v2 Game Mode Stats
629
+ * @type {DuelsGamemode}
630
+ */
631
+ this['2v2v2v2'] = new DuelsGamemode(data, '2v2v2v2', this.title);
632
+ /**
633
+ * 3v3v3v3 Game Mode Stats
634
+ * @type {DuelsGamemode}
635
+ */
636
+ this['3v3v3v3'] = new DuelsGamemode(data, '3v3v3v3', this.title);
637
+ /**
638
+ * Capture The Flag Game Mode Stats
639
+ * @type {DuelsGamemode}
640
+ */
641
+ this.ctf = new DuelsGamemode(data, 'capture_threes', this.title);
642
+ /**
643
+ * Kills
644
+ * @type {number}
645
+ */
646
+ this.kills =
647
+ this.solo.kills +
648
+ this.doubles.kills +
649
+ this.threes.kills +
650
+ this.fours.kills +
651
+ this['2v2v2v2'].kills +
652
+ this['3v3v3v3'].kills +
653
+ this.ctf.kills;
654
+ /**
655
+ * Deaths
656
+ * @type {number}
657
+ */
658
+ this.deaths =
659
+ this.solo.deaths +
660
+ this.doubles.deaths +
661
+ this.threes.deaths +
662
+ this.fours.deaths +
663
+ this['2v2v2v2'].deaths +
664
+ this['3v3v3v3'].deaths +
665
+ this.ctf.deaths;
666
+ /**
667
+ * KDRatio
668
+ * @type {number}
669
+ */
670
+ this.KDRatio = divide(this.kills, this.deaths);
671
+ /**
672
+ * Wins
673
+ * @type {number}
674
+ */
675
+ this.wins =
676
+ this.solo.wins +
677
+ this.doubles.wins +
678
+ this.threes.wins +
679
+ this.fours.wins +
680
+ this['2v2v2v2'].wins +
681
+ this['3v3v3v3'].wins +
682
+ this.ctf.wins;
683
+ /**
684
+ * Losses
685
+ * @type {number}
686
+ */
687
+ this.losses =
688
+ this.solo.losses +
689
+ this.doubles.losses +
690
+ this.threes.losses +
691
+ this.fours.losses +
692
+ this['2v2v2v2'].losses +
693
+ this['3v3v3v3'].losses +
694
+ this.ctf.losses;
695
+ /**
696
+ * WLRatio
697
+ * @type {number}
698
+ */
699
+ this.WLRatio = divide(this.wins, this.losses);
700
+ /**
701
+ * Played Games
702
+ * @type {number}
703
+ */
704
+ this.playedGames =
705
+ this.solo.playedGames +
706
+ this.doubles.playedGames +
707
+ this.threes.playedGames +
708
+ this.fours.playedGames +
709
+ this['2v2v2v2'].playedGames +
710
+ this['3v3v3v3'].playedGames +
711
+ this.ctf.playedGames;
712
+ /**
713
+ * Swings
714
+ * @type {number}
715
+ */
716
+ this.swings =
717
+ this.solo.swings +
718
+ this.doubles.swings +
719
+ this.threes.swings +
720
+ this.fours.swings +
721
+ this['2v2v2v2'].swings +
722
+ this['3v3v3v3'].swings +
723
+ this.ctf.swings;
724
+ /**
725
+ * Hits
726
+ * @type {number}
727
+ */
728
+ this.hits =
729
+ this.solo.hits +
730
+ this.doubles.hits +
731
+ this.threes.hits +
732
+ this.fours.hits +
733
+ this['2v2v2v2'].hits +
734
+ this['3v3v3v3'].hits +
735
+ this.ctf.hits;
736
+ /**
737
+ * Melee Accuracy
738
+ * @type {number}
739
+ */
740
+ this.meleeAccuracy = divide(this.hits, this.swings);
741
+ /**
742
+ * Bow Shots
743
+ * @type {number}
744
+ */
745
+ this.bowShots =
746
+ this.solo.bowShots +
747
+ this.doubles.bowShots +
748
+ this.threes.bowShots +
749
+ this.fours.bowShots +
750
+ this['2v2v2v2'].bowShots +
751
+ this['3v3v3v3'].bowShots +
752
+ this.ctf.bowShots;
753
+ /**
754
+ * Bow Hits
755
+ * @type {number}
756
+ */
757
+ this.bowHits =
758
+ this.solo.bowHits +
759
+ this.doubles.bowHits +
760
+ this.threes.bowHits +
761
+ this.fours.bowHits +
762
+ this['2v2v2v2'].bowHits +
763
+ this['3v3v3v3'].bowHits +
764
+ this.ctf.bowHits;
765
+ /**
766
+ * Bow Accuracy
767
+ * @type {number}
768
+ */
769
+ this.bowAccuracy = divide(this.bowHits, this.bowShots);
770
+ /**
771
+ * Blocks Placed
772
+ * @type {number}
773
+ */
774
+ this.blocksPlaced =
775
+ this.solo.blocksPlaced +
776
+ this.doubles.blocksPlaced +
777
+ this.threes.blocksPlaced +
778
+ this.fours.blocksPlaced +
779
+ this['2v2v2v2'].blocksPlaced +
780
+ this['3v3v3v3'].blocksPlaced +
781
+ this.ctf.blocksPlaced;
782
+ /**
783
+ * Health Regenerated
784
+ * @type {number}
785
+ */
786
+ this.healthRegenerated =
787
+ this.solo.healthRegenerated +
788
+ this.doubles.healthRegenerated +
789
+ this.threes.healthRegenerated +
790
+ this.fours.healthRegenerated +
791
+ this['2v2v2v2'].healthRegenerated +
792
+ this['3v3v3v3'].healthRegenerated +
793
+ this.ctf.healthRegenerated;
794
+ /**
795
+ * Golden Apples Eatan
796
+ * @type {number}
797
+ */
798
+ this.goldenApplesEatan =
799
+ this.solo.goldenApplesEatan +
800
+ this.doubles.goldenApplesEatan +
801
+ this.threes.goldenApplesEatan +
802
+ this.fours.goldenApplesEatan +
803
+ this['2v2v2v2'].goldenApplesEatan +
804
+ this['3v3v3v3'].goldenApplesEatan +
805
+ this.ctf.goldenApplesEatan;
28
806
  }
29
- return {
30
- kills: totalKills,
31
- deaths: totalDeaths
32
- };
33
807
  }
808
+
34
809
  /**
35
810
  * Duels class
36
811
  */
@@ -45,20 +820,20 @@ class Duels {
45
820
  */
46
821
  this.tokens = data.coins || 0;
47
822
  /**
48
- * All modes division
823
+ * All modes Title
49
824
  * @type {string|null}
50
825
  */
51
- this.division = getDivision(data);
826
+ this.title = getTitle(data);
52
827
  /**
53
828
  * Kills
54
829
  * @type {number}
55
830
  */
56
- this.kills = getTotalKillsDeaths(data).kills;
831
+ this.kills = data.kills || 0;
57
832
  /**
58
833
  * Deaths
59
834
  * @type {number}
60
835
  */
61
- this.deaths = getTotalKillsDeaths(data).deaths;
836
+ this.deaths = data.deaths || 0;
62
837
  /**
63
838
  * Kill Death ratio
64
839
  * @type {number}
@@ -94,662 +869,128 @@ class Duels {
94
869
  * @type {number}
95
870
  */
96
871
  this.bestWinstreak = data.best_overall_winstreak || 0;
872
+ /**
873
+ * Ping Range Preference
874
+ * @type {number}
875
+ */
876
+ this.ping = data.pingPreference || 0;
877
+ /**
878
+ * Blocks Placed
879
+ * @type {number}
880
+ */
881
+ this.blocksPlaced = data.blocks_placed || 0;
882
+ /**
883
+ * Swings
884
+ * @type {number}
885
+ */
886
+ this.swings = data.melee_swings || 0;
887
+ /**
888
+ * Hits
889
+ * @type {number}
890
+ */
891
+ this.hits = data.melee_hits || 0;
892
+ /**
893
+ * Melee Accuracy
894
+ * @type {number}
895
+ */
896
+ this.meleeAccuracy = divide(this.hits, this.swings);
897
+ /**
898
+ * Bow Shots
899
+ * @type {number}
900
+ */
901
+ this.bowShots = data.bow_shots || 0;
902
+ /**
903
+ * Bow Hits
904
+ * @type {number}
905
+ */
906
+ this.bowHits = data.bow_hits || 0;
907
+ /**
908
+ * Bow Accuracy
909
+ * @type {number}
910
+ */
911
+ this.bowAccuracy = divide(this.bowHits, this.bowShots);
912
+ /**
913
+ * Health Regenerated
914
+ * @type {number}
915
+ */
916
+ this.healthRegenerated = data.health_regenerated || 0;
917
+ /**
918
+ * Golden Apples Eaten
919
+ * @type {number}
920
+ */
921
+ this.goldenApplesEatan = data.golden_apples_eaten || 0;
97
922
  /**
98
923
  * UHC duels stats
99
924
  * @type {DuelsUHC}
100
925
  */
101
- this.uhc = {
102
- overall: {
103
- division: getDivision(data, 'uhc'),
104
- winstreak: data.current_uhc_winstreak || 0,
105
- bestWinstreak: data.best_uhc_winstreak || 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),
116
- KDRatio: divide(
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)
125
- ),
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),
136
- WLRatio: divide(
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)
145
- ),
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)
151
- },
152
- '1v1': {
153
- division: getDivision(data, 'uhc'),
154
- winstreak: data.current_winstreak_mode_uhc_duel || 0,
155
- bestWinstreak: data.best_winstreak_mode_uhc_duel || 0,
156
- kills: data.uhc_duel_kills || 0,
157
- deaths: data.uhc_duel_deaths || 0,
158
- KDRatio: divide(data.uhc_duel_kills, data.uhc_duel_deaths),
159
- wins: data.uhc_duel_wins || 0,
160
- losses: data.uhc_duel_losses || 0,
161
- WLRatio: divide(data.uhc_duel_wins, data.uhc_duel_losses),
162
- playedGames: data.uhc_duel_rounds_played || 0
163
- },
164
- '2v2': {
165
- division: getDivision(data, 'uhc'),
166
- winstreak: data.current_winstreak_mode_uhc_doubles || 0,
167
- bestWinstreak: data.best_winstreak_mode_uhc_doubles || 0,
168
- kills: data.uhc_doubles_kills || 0,
169
- deaths: data.uhc_doubles_deaths || 0,
170
- KDRatio: divide(data.uhc_doubles_kills, data.uhc_doubles_deaths),
171
- wins: data.uhc_doubles_wins || 0,
172
- losses: data.uhc_doubles_losses || 0,
173
- WLRatio: divide(data.uhc_doubles_wins, data.uhc_doubles_losses),
174
- playedGames: data.uhc_doubles_rounds_played || 0
175
- },
176
- '4v4': {
177
- division: getDivision(data, 'uhc'),
178
- winstreak: data.current_winstreak_mode_uhc_four || 0,
179
- bestWinstreak: data.best_winstreak_mode_uhc_four || 0,
180
- kills: data.uhc_four_kills || 0,
181
- deaths: data.uhc_four_deaths || 0,
182
- KDRatio: divide(data.uhc_four_kills, data.uhc_four_deaths),
183
- wins: data.uhc_four_wins || 0,
184
- losses: data.uhc_four_losses || 0,
185
- WLRatio: divide(data.uhc_four_wins, data.uhc_four_losses),
186
- playedGames: data.uhc_four_rounds_played || 0
187
- },
188
- meetup: {
189
- division: getDivision(data, 'uhc'),
190
- winstreak: data.current_winstreak_mode_uhc_meetup || 0,
191
- bestWinstreak: data.best_winstreak_mode_uhc_meetup || 0,
192
- kills: data.uhc_meetup_kills || 0,
193
- deaths: data.uhc_meetup_deaths || 0,
194
- KDRatio: divide(data.uhc_meetup_kills, data.uhc_meetup_deaths),
195
- wins: data.uhc_meetup_wins || 0,
196
- losses: data.uhc_meetup_losses || 0,
197
- WLRatio: divide(data.uhc_meetup_wins, data.uhc_meetup_losses),
198
- playedGames: data.uhc_meetup_rounds_played || 0
199
- }
200
- };
201
- /**
202
- * @type {DuelsParkour}
203
- */
204
- this.parkour = {
205
- division: getDivision(data, 'parkour'),
206
- deaths: data.parkour_eight_deaths || 0,
207
- wins: data.parkour_eight_wins || 0,
208
- losses: data.parkour_eight_losses || 0,
209
- WLRatio: divide(data.parkour_eight_wins, data.parkour_eight_losses),
210
- playedGames: data.parkour_eight_rounds_played || 0
211
- };
212
- /**
213
- * @type {DuelsBoxing}
214
- */
215
- this.boxing = {
216
- division: getDivision(data, 'boxing'),
217
- kills: data.boxing_duel_kills || 0,
218
- wins: data.boxing_duel_wins || 0,
219
- losses: data.boxing_duel_losses || 0,
220
- WLRatio: divide(data.boxing_duel_wins, data.boxing_duel_losses),
221
- playedGames: data.boxing_duel_rounds_played || 0,
222
- meleeSwings: data.boxing_duel_melee_swings || 0,
223
- meleeHits: data.boxing_duel_melee_hits || 0
224
- };
225
- /**
226
- * @type {DuelsBowspleef}
227
- */
228
- this.bowspleef = {
229
- division: getDivision(data, 'tnt_games'),
230
- winstreak: data.current_tnt_games_winstreak || 0,
231
- bestWinstreak: data.best_tnt_games_winstreak || 0,
232
- bowShots: data.bowspleef_duel_bow_shots || 0,
233
- deaths: data.bowspleef_duel_deaths || 0,
234
- wins: data.bowspleef_duel_wins || 0,
235
- losses: data.bowspleef_duel_losses || 0,
236
- WLRatio: divide(data.bowspleef_duel_wins || 0, data.bowspleef_duel_losses || 0),
237
- playedGames: data.bowspleef_duel_rounds_played || 0
238
- };
239
- /**
240
- * @type {DuelsArena}
241
- */
242
- this.arena = {
243
- kills: data.duel_arena_kills || 0,
244
- deaths: data.duel_arena_deaths || 0,
245
- KDRatio: divide(data.duel_arena_kills, data.duel_arena_deaths),
246
- wins: data.duel_arena_wins || 0,
247
- losses: data.duel_arena_losses || 0,
248
- WLRatio: divide(data.duel_arena_wins, data.duel_arena_losses),
249
- playedGames: data.duel_arena_rounds_played || 0
250
- };
926
+ this.uhc = new DuelsUHC(data);
927
+
928
+ /**
929
+ * SkyWars duels stats
930
+ * @type {DuelsSkyWars}
931
+ */
932
+ this.skywars = new DuelsSkyWars(data);
251
933
  /**
252
934
  * MegaWalls duels stats
253
- * @type {DuelsModeStats}
254
- */
255
- this.megawalls = {
256
- division: getDivision(data, 'mega_walls'),
257
- winstreak: data.current_winstreak_mode_mw_duel || 0,
258
- bestWinstreak: data.best_winstreak_mode_mw_duel || 0,
259
- kills: data.mw_duel_kills || 0,
260
- deaths: data.mw_duel_deaths || 0,
261
- KDRatio: divide(data.mw_duel_kills, data.mw_duel_deaths),
262
- wins: data.mw_duel_wins || 0,
263
- losses: data.mw_duel_losses || 0,
264
- WLRatio: divide(data.mw_duel_wins, data.mw_duel_losses),
265
- playedGames: data.mw_duel_rounds_played || 0
266
- };
935
+ * @type {DuelsMegaWalls}
936
+ */
937
+ this.megawalls = new DuelsMegaWalls(data);
938
+ /**
939
+ * Blitz duel stats
940
+ * @type {DuelsGamemode}
941
+ */
942
+ this.blitz = new DuelsGamemode(data, 'blitz_duel', getTitle(data, 'blitz'));
267
943
  /**
268
944
  * OP duels stats
269
945
  * @type {DuelsOP}
270
946
  */
271
- this.op = {
272
- overall: {
273
- division: getDivision(data, 'op'),
274
- winstreak: data.current_op_winstreak || 0,
275
- bestWinstreak: data.best_op_winstreak || 0,
276
- kills: (data.op_duel_kills || 0) + (data.op_doubles_kills || 0),
277
- deaths: (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
- ),
282
- wins: (data.op_duel_wins || 0) + (data.op_doubles_wins || 0),
283
- losses: (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
- ),
288
- playedGames: (data.op_duel_rounds_played || 0) + (data.op_doubles_rounds_played || 0)
289
- },
290
- '1v1': {
291
- division: getDivision(data, 'op'),
292
- winstreak: data.current_winstreak_mode_op_duel || 0,
293
- bestWinstreak: data.best_winstreak_mode_op_duel || 0,
294
- kills: data.op_duel_kills || 0,
295
- deaths: data.op_duel_deaths || 0,
296
- KDRatio: divide(data.op_duel_kills, data.op_duel_deaths),
297
- wins: data.op_duel_wins || 0,
298
- losses: data.op_duel_losses || 0,
299
- WLRatio: divide(data.op_duel_wins, data.op_duel_losses),
300
- playedGames: data.op_duel_rounds_played || 0
301
- },
302
- '2v2': {
303
- division: getDivision(data, 'op'),
304
- winstreak: data.current_winstreak_mode_op_doubles || 0,
305
- bestWinstreak: data.best_winstreak_mode_op_doubles || 0,
306
- kills: data.op_doubles_kills || 0,
307
- deaths: data.op_doubles_deaths || 0,
308
- KDRatio: divide(data.op_doubles_kills, data.op_doubles_deaths),
309
- wins: data.op_doubles_wins || 0,
310
- losses: data.op_doubles_losses || 0,
311
- WLRatio: divide(data.op_doubles_wins, data.op_doubles_losses),
312
- playedGames: data.op_doubles_rounds_played || 0
313
- }
314
- };
947
+ this.op = new DuelsOP(data);
315
948
  /**
316
- * SkyWars duels stats
317
- * @type {DuelsSkyWars}
949
+ * Classic duels stats
950
+ * @type {DuelsGamemode}
318
951
  */
319
- this.skywars = {
320
- overall: {
321
- division: getDivision(data, 'skywars'),
322
- winstreak: data.current_skywars_winstreak || 0,
323
- bestWinstreak: data.best_skywars_winstreak || 0,
324
- kills: (data.sw_duel_kills || 0) + (data.sw_doubles_kills || 0),
325
- deaths: (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
- ),
330
- wins: (data.sw_duel_wins || 0) + (data.sw_doubles_wins || 0),
331
- losses: (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
- ),
336
- playedGames: (data.sw_duel_rounds_played || 0) + (data.sw_doubles_rounds_played || 0)
337
- },
338
- '1v1': {
339
- division: getDivision(data, 'skywars'),
340
- winstreak: data.current_winstreak_mode_sw_duel || 0,
341
- bestWinstreak: data.best_winstreak_mode_sw_duel || 0,
342
- kills: data.sw_duel_kills || 0,
343
- deaths: data.sw_duel_deaths || 0,
344
- KDRatio: divide(data.sw_duel_kills, data.sw_duel_deaths),
345
- wins: data.sw_duel_wins || 0,
346
- losses: data.sw_duel_losses || 0,
347
- WLRatio: divide(data.sw_duel_wins, data.sw_duel_losses),
348
- playedGames: data.sw_duel_rounds_played || 0
349
- },
350
- '2v2': {
351
- division: getDivision(data, 'skywars'),
352
- winstreak: data.current_winstreak_mode_sw_doubles || 0,
353
- bestWinstreak: data.best_winstreak_mode_sw_doubles || 0,
354
- kills: data.sw_doubles_kills || 0,
355
- deaths: data.sw_doubles_deaths || 0,
356
- KDRatio: divide(data.sw_doubles_kills, data.sw_doubles_deaths),
357
- wins: data.sw_doubles_wins || 0,
358
- losses: data.sw_doubles_losses || 0,
359
- WLRatio: divide(data.sw_doubles_wins, data.sw_doubles_losses),
360
- playedGames: data.sw_doubles_rounds_played || 0
361
- }
362
- };
952
+ this.classic = new DuelsGamemode(data, 'classic_duel', getTitle(data, 'classic'));
363
953
  /**
364
- * Sumo duels stats
365
- * @type {DuelsModeStats}
366
- */
367
- this.sumo = {
368
- division: getDivision(data, 'sumo'),
369
- winstreak: data.current_winstreak_mode_sumo_duel || 0,
370
- bestWinstreak: data.best_winstreak_mode_sumo_duel || 0,
371
- kills: data.sumo_duel_kills || 0,
372
- deaths: data.sumo_duel_deaths || 0,
373
- KDRatio: divide(data.sumo_duel_kills, data.sumo_duel_deaths),
374
- wins: data.sumo_duel_wins || 0,
375
- losses: data.sumo_duel_losses || 0,
376
- WLRatio: divide(data.sumo_duel_wins, data.sumo_duel_losses),
377
- playedGames: data.sumo_duel_rounds_played || 0
378
- };
954
+ * Bow duels stats
955
+ * @type {DuelsGamemode}
956
+ */
957
+ this.bow = new DuelsGamemode(data, 'bow_duel', getTitle(data, 'bow'));
379
958
  /**
380
- * Classic duels stats
381
- * @type {DuelsModeStats}
382
- */
383
- this.classic = {
384
- division: getDivision(data, 'classic'),
385
- winstreak: data.current_winstreak_mode_classic_duel || 0,
386
- bestWinstreak: data.best_winstreak_mode_classic_duel || 0,
387
- kills: data.classic_duel_kills || 0,
388
- deaths: data.classic_duel_deaths || 0,
389
- KDRatio: divide(data.classic_duel_kills, data.classic_duel_deaths),
390
- wins: data.classic_duel_wins || 0,
391
- losses: data.classic_duel_losses || 0,
392
- WLRatio: divide(data.classic_duel_wins, data.classic_duel_losses),
393
- playedGames: data.classic_duel_rounds_played || 0
394
- };
959
+ * No Debuff duels stats
960
+ * @type {DuelsGamemode}
961
+ */
962
+ this.noDebuff = new DuelsGamemode(data, 'potion_duel', getTitle(data, 'no_debuff'));
395
963
  /**
396
964
  * Combo duels stats
397
- * @type {DuelsModeStats}
398
- */
399
- this.combo = {
400
- division: getDivision(data, 'combo'),
401
- winstreak: data.current_winstreak_mode_combo_duel || 0,
402
- bestWinstreak: data.best_winstreak_mode_combo_duel || 0,
403
- kills: data.combo_duel_kills || 0,
404
- deaths: data.combo_duel_deaths || 0,
405
- KDRatio: divide(data.combo_duel_kills, data.combo_duel_deaths),
406
- wins: data.combo_duel_wins || 0,
407
- losses: data.combo_duel_losses || 0,
408
- WLRatio: divide(data.combo_duel_wins, data.combo_duel_losses),
409
- playedGames: data.combo_duel_rounds_played || 0
410
- };
411
- /**
412
- * The bridge duels stats
965
+ * @type {DuelsGamemode}
966
+ */
967
+ this.combo = new DuelsGamemode(data, 'combo_duel', getTitle(data, 'combo'));
968
+ /**
969
+ * Bow Spleef duels stats
970
+ * @type {DuelsGamemode}
971
+ */
972
+ this.bowSpleef = new DuelsGamemode(data, 'bowspleef_duel', getTitle(data, 'tnt_games'));
973
+ /**
974
+ * Sumo duels stats
975
+ * @type {DuelsGamemode}
976
+ */
977
+ this.sumo = new DuelsGamemode(data, 'sumo_duel', getTitle(data, 'sumo'));
978
+ /**
979
+ * Bridge duels stats
413
980
  * @type {DuelsBridge}
414
981
  */
415
- this.bridge = {
416
- overall: {
417
- division: getDivision(data, 'bridge'),
418
- winstreak: data.current_bridge_winstreak || 0,
419
- bestWinstreak: data.best_bridge_winstreak || 0,
420
- kills:
421
- (data.bridge_duel_bridge_kills || 0) +
422
- (data.bridge_doubles_bridge_kills || 0) +
423
- (data.bridge_2v2v2v2_bridge_kills || 0) +
424
- (data.bridge_3v3v3v3_bridge_kills || 0) +
425
- (data.bridge_four_bridge_kills || 0) +
426
- (data.bridge_threes_bridge_kills || 0) +
427
- (data.capture_threes_bridge_kills || 0),
428
- deaths:
429
- (data.bridge_duel_bridge_deaths || 0) +
430
- (data.bridge_doubles_bridge_deaths || 0) +
431
- (data.bridge_2v2v2v2_bridge_deaths || 0) +
432
- (data.bridge_3v3v3v3_bridge_deaths || 0) +
433
- (data.bridge_four_bridge_deaths || 0) +
434
- (data.bridge_threes_bridge_deaths || 0) +
435
- (data.capture_threes_bridge_deaths || 0),
436
- KDRatio: divide(
437
- (data.bridge_duel_bridge_kills || 0) +
438
- (data.bridge_doubles_bridge_kills || 0) +
439
- (data.bridge_2v2v2v2_bridge_kills || 0) +
440
- (data.bridge_3v3v3v3_bridge_kills || 0) +
441
- (data.bridge_four_bridge_kills || 0) +
442
- (data.bridge_threes_bridge_kills || 0) +
443
- (data.capture_threes_bridge_kills || 0),
444
- (data.bridge_duel_bridge_deaths || 0) +
445
- (data.bridge_doubles_bridge_deaths || 0) +
446
- (data.bridge_2v2v2v2_bridge_deaths || 0) +
447
- (data.bridge_3v3v3v3_bridge_deaths || 0) +
448
- (data.bridge_four_bridge_deaths || 0) +
449
- (data.bridge_threes_bridge_deaths || 0) +
450
- (data.capture_threes_bridge_deaths || 0)
451
- ),
452
- wins:
453
- (data.bridge_duel_wins || 0) +
454
- (data.bridge_doubles_wins || 0) +
455
- (data.bridge_2v2v2v2_wins || 0) +
456
- (data.bridge_3v3v3v3_wins || 0) +
457
- (data.bridge_four_wins || 0) +
458
- (data.bridge_threes_wins || 0) +
459
- (data.capture_threes_wins || 0),
460
- losses:
461
- (data.bridge_duel_losses || 0) +
462
- (data.bridge_doubles_losses || 0) +
463
- (data.bridge_2v2v2v2_losses || 0) +
464
- (data.bridge_3v3v3v3_losses || 0) +
465
- (data.bridge_four_losses || 0) +
466
- (data.bridge_threes_bridge_losses || 0) +
467
- (data.capture_threes_bridge_losses || 0),
468
- WLRatio: divide(
469
- (data.bridge_duel_wins || 0) +
470
- (data.bridge_doubles_wins || 0) +
471
- (data.bridge_2v2v2v2_wins || 0) +
472
- (data.bridge_3v3v3v3_wins || 0) +
473
- (data.bridge_four_wins || 0) +
474
- (data.bridge_threes_bridge_wins || 0) +
475
- (data.capture_threes_wins || 0),
476
- (data.bridge_duel_losses || 0) +
477
- (data.bridge_doubles_losses || 0) +
478
- (data.bridge_2v2v2v2_losses || 0) +
479
- (data.bridge_3v3v3v3_losses || 0) +
480
- (data.bridge_four_losses || 0) +
481
- (data.bridge_threes_bridge_losses || 0) +
482
- (data.capture_threes_bridge_losses || 0)
483
- ),
484
- playedGames:
485
- (data.bridge_duel_rounds_played || 0) +
486
- (data.bridge_doubles_rounds_played || 0) +
487
- (data.bridge_2v2v2v2_rounds_played || 0) +
488
- (data.bridge_3v3v3v3_rounds_played || 0) +
489
- (data.bridge_four_rounds_played || 0) +
490
- (data.bridge_threes_bridge_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)
500
- },
501
- '1v1': {
502
- division: getDivision(data, 'bridge'),
503
- winstreak: data.current_winstreak_mode_bridge_duel || 0,
504
- bestWinstreak: data.best_winstreak_mode_bridge_duel || 0,
505
- kills: data.bridge_duel_bridge_kills || 0,
506
- deaths: data.bridge_duel_bridge_deaths || 0,
507
- KDRatio: divide(data.bridge_duel_bridge_kills, data.bridge_duel_bridge_deaths),
508
- wins: data.bridge_duel_wins || 0,
509
- losses: data.bridge_duel_losses || 0,
510
- WLRatio: divide(data.bridge_duel_wins, data.bridge_duel_losses),
511
- playedGames: data.bridge_duel_rounds_played || 0,
512
- goals: data.bridge_duel_goals || 0
513
- },
514
- '2v2': {
515
- division: getDivision(data, 'bridge'),
516
- winstreak: data.current_winstreak_mode_bridge_doubles || 0,
517
- bestWinstreak: data.best_winstreak_mode_bridge_doubles || 0,
518
- kills: data.bridge_doubles_bridge_kills || 0,
519
- deaths: data.bridge_doubles_bridge_deaths || 0,
520
- KDRatio: divide(data.bridge_doubles_bridge_kills, data.bridge_doubles_bridge_deaths),
521
- wins: data.bridge_doubles_wins || 0,
522
- losses: data.bridge_doubles_losses || 0,
523
- WLRatio: divide(data.bridge_doubles_wins, data.bridge_doubles_losses),
524
- playedGames: data.bridge_doubles_rounds_played || 0,
525
- goals: data.bridge_doubles_goals || 0
526
- },
527
- '3v3': {
528
- division: getDivision(data, 'bridge'),
529
- winstreak: data.current_winstreak_mode_bridge_threes || 0,
530
- bestWinstreak: data.best_winstreak_mode_bridge_threes || 0,
531
- kills: data.bridge_threes_bridge_kills || 0,
532
- deaths: data.bridge_threes_bridge_deaths || 0,
533
- KDRatio: divide(data.bridge_threes_bridge_kills, data.bridge_threes_bridge_deaths),
534
- wins: data.bridge_threes_wins || 0,
535
- losses: data.bridge_threes_losses || 0,
536
- WLRatio: divide(data.bridge_threes_wins, data.bridge_threes_losses),
537
- playedGames: data.bridge_threes_rounds_played || 0,
538
- goals: data.bridge_threes_goals || 0
539
- },
540
- '2v2v2v2': {
541
- division: getDivision(data, 'bridge'),
542
- winstreak: data.current_winstreak_mode_bridge_2v2v2v2 || 0,
543
- bestWinstreak: data.best_winstreak_mode_bridge_2v2v2v2 || 0,
544
- kills: data.bridge_2v2v2v2_bridge_kills || 0,
545
- deaths: data.bridge_2v2v2v2_bridge_deaths || 0,
546
- KDRatio: divide(data.bridge_2v2v2v2_bridge_kills, data.bridge_2v2v2v2_bridge_deaths),
547
- wins: data.bridge_2v2v2v2_wins || 0,
548
- losses: data.bridge_2v2v2v2_losses || 0,
549
- WLRatio: divide(data.bridge_2v2v2v2_wins, data.bridge_2v2v2v2_losses),
550
- playedGames: data.bridge_2v2v2v2_rounds_played || 0,
551
- goals: data.bridge_2v2v2v2_goals || 0
552
- },
553
- '3v3v3v3': {
554
- division: getDivision(data, 'bridge'),
555
- winstreak: data.current_winstreak_mode_bridge_3v3v3v3 || 0,
556
- bestWinstreak: data.best_winstreak_mode_bridge_3v3v3v3 || 0,
557
- kills: data.bridge_3v3v3v3_bridge_kills || 0,
558
- deaths: data.bridge_3v3v3v3_bridge_deaths || 0,
559
- KDRatio: divide(data.bridge_3v3v3v3_bridge_kills, data.bridge_3v3v3v3_bridge_deaths),
560
- wins: data.bridge_3v3v3v3_wins || 0,
561
- losses: data.bridge_3v3v3v3_losses || 0,
562
- WLRatio: divide(data.bridge_3v3v3v3_wins, data.bridge_3v3v3v3_losses),
563
- playedGames: data.bridge_3v3v3v3_rounds_played || 0,
564
- goals: data.bridge_3v3v3v3_goals || 0
565
- },
566
- '4v4': {
567
- division: getDivision(data, 'bridge'),
568
- winstreak: data.current_winstreak_mode_bridge_four || 0,
569
- bestWinstreak: data.best_winstreak_mode_bridge_four || 0,
570
- kills: data.bridge_four_bridge_kills || 0,
571
- deaths: data.bridge_four_bridge_deaths || 0,
572
- KDRatio: divide(data.bridge_four_bridge_kills, data.bridge_four_bridge_deaths),
573
- wins: data.bridge_four_wins || 0,
574
- losses: data.bridge_four_losses || 0,
575
- WLRatio: divide(data.bridge_four_wins, data.bridge_four_losses),
576
- playedGames: data.bridge_four_rounds_played || 0,
577
- goals: data.bridge_four_goals || 0
578
- },
579
- // eslint-disable-next-line quote-props
580
- ctf: {
581
- division: getDivision(data, 'bridge'),
582
- kills: data.capture_threes_bridge_kills || 0,
583
- deaths: data.capture_threes_bridge_deaths || 0,
584
- KDRatio: divide(data.capture_threes_bridge_kills, data.capture_threes_bridge_deaths),
585
- wins: data.capture_threes_wins || 0,
586
- losses: data.capture_threes_losses || 0,
587
- WLRatio: divide(data.capture_threes_wins, data.capture_threes_losses),
588
- captures: data.capture_threes_captures || 0,
589
- playedGames: data.capture_threes_rounds_played || 0,
590
- goals: data.capture_threes_goals || 0
591
- }
592
- };
982
+ this.bridge = new DuelsBridge(data);
593
983
  /**
594
- * Blitz duel stats
595
- * @type {DuelsModeStats}
596
- */
597
- this.blitz = {
598
- division: getDivision(data, 'blitz'),
599
- winstreak: data.current_winstreak_mode_blitz_duel || 0,
600
- bestWinstreak: data.best_winstreak_mode_blitz_duel || 0,
601
- kills: data.blitz_duel_kills || 0,
602
- deaths: data.blitz_duel_deaths || 0,
603
- KDRatio: divide(data.blitz_duel_kills, data.blitz_duel_deaths),
604
- wins: data.blitz_duel_wins || 0,
605
- losses: data.blitz_duel_losses || 0,
606
- WLRatio: divide(data.blitz_duel_wins, data.blitz_duel_losses),
607
- playedGames: data.blitz_duel_rounds_played || 0
608
- };
609
- /**
610
- * Nodebuff duel stats
611
- * @type {DuelsModeStats}
612
- */
613
- this.nodebuff = {
614
- division: getDivision(data, 'no_debuff'),
615
- winstreak: data.current_winstreak_mode_potion_duel || 0,
616
- bestWinstreak: data.best_winstreak_mode_potion_duel || 0,
617
- kills: data.potion_duel_kills || 0,
618
- deaths: data.potion_duel_deaths || 0,
619
- KDRatio: divide(data.potion_duel_kills, data.potion_duel_deaths),
620
- wins: data.potion_duel_wins || 0,
621
- losses: data.potion_duel_losses || 0,
622
- WLRatio: divide(data.potion_duel_wins, data.potion_duel_losses),
623
- playedGames: data.potion_duel_rounds_played || 0
624
- };
625
- /**
626
- * Bow duel stats
627
- * @type {DuelsModeStats}
628
- */
629
- this.bow = {
630
- division: getDivision(data, 'bow'),
631
- winstreak: data.current_winstreak_mode_bow_duel || 0,
632
- bestWinstreak: data.best_winstreak_mode_bow_duel || 0,
633
- kills: data.bow_duel_kills || 0,
634
- deaths: data.bow_duel_deaths || 0,
635
- KDRatio: divide(data.bow_duel_kills, data.bow_duel_deaths),
636
- wins: data.bow_duel_wins || 0,
637
- losses: data.bow_duel_losses || 0,
638
- WLRatio: divide(data.bow_duel_wins, data.bow_duel_losses),
639
- playedGames: data.bow_duel_rounds_played || 0
640
- };
984
+ * Parkour duels stats
985
+ * @type {DuelsGamemode}
986
+ */
987
+ this.parkour = new DuelsGamemode(data, 'parkour_eight', getTitle(data, 'parkour'));
988
+ /**
989
+ * Arena duels stats
990
+ * @type {DuelsGamemode}
991
+ */
992
+ this.arena = new DuelsGamemode(data, 'duel_arena');
641
993
  }
642
994
  }
643
- /**
644
- * @typedef {object} DuelsModeStats
645
- * @property {number} winstreak Current winstreak
646
- * @property {number} bestWinstreak Best winstreak
647
- * @property {string|null} division Division
648
- * @property {number} kills Kills
649
- * @property {number} deaths Deaths
650
- * @property {number} wins Wins
651
- * @property {number} losses Losses
652
- * @property {number} KDRatio Kill/Death ratio
653
- * @property {number} WLRatio Win/Loss ratio
654
- * @property {number} playedGames Played games
655
- */
656
- /**
657
- * @typedef {object} BridgeModeStats
658
- * @property {number} winstreak Current winstreak
659
- * @property {number} bestWinstreak Best winstreak
660
- * @property {string|null} division Division
661
- * @property {number} kills Kills
662
- * @property {number} deaths Deaths
663
- * @property {number} wins Wins
664
- * @property {number} losses Losses
665
- * @property {number} KDRatio Kill/Death ratio
666
- * @property {number} WLRatio Win/Loss ratio
667
- * @property {number} playedGames Played games
668
- * @property {number} goals Goals
669
- */
670
- /**
671
- * @typedef {object} DuelsBowspleef
672
- * @property {string|null} division Division
673
- * @property {number} winstreak Winstreak
674
- * @property {number} bestWinstreak Best winstreak
675
- * @property {number} bowShots Bow shots
676
- * @property {number} deaths Deaths
677
- * @property {number} wins Wins
678
- * @property {number} losses Losses
679
- * @property {number} WLRatio Win/Loss ratio
680
- * @property {number} playedGames Played games
681
- */
682
- /**
683
- * @typedef {object} BridgeCTFModeStats
684
- * @property {string|null} division Division
685
- * @property {number} kills Kills
686
- * @property {number} deaths Deaths
687
- * @property {number} wins Wins
688
- * @property {number} losses Losses
689
- * @property {number} KDRatio Kill/Death ratio
690
- * @property {number} WLRatio Win/Loss ratio
691
- * @property {number} playedGames Played games
692
- * @property {number} captures Captures
693
- */
694
- /**
695
- * @typedef {object} DuelsParkour
696
- * @property {string|null} division Division
697
- * @property {number} deaths Deaths
698
- * @property {number} wins Wins
699
- * @property {number} losses Losses
700
- * @property {number} WLRatio Win/Loss ratio
701
- * @property {number} playedGames Played games
702
- */
703
- /**
704
- * @typedef {object} DuelsBoxing
705
- * @property {string|null} division Division
706
- * @property {number} kills Kills
707
- * @property {number} wins Wins
708
- * @property {number} losses Losses
709
- * @property {number} WLRatio Win/Loss ratio
710
- * @property {number} playedGames Played games
711
- * @property {number} meleeSwings Melee swings
712
- * @property {number} meleeHits Melee hits
713
- */
714
- /**
715
- * @typedef {object} DuelsArena
716
- * @property {number} kills Kills
717
- * @property {number} deaths Deaths
718
- * @property {number} wins Wins
719
- * @property {number} losses Losses
720
- * @property {number} KDRatio Kill/Death ratio
721
- * @property {number} WLRatio Win/Loss ratio
722
- * @property {number} playedGames Played games
723
- */
724
- /**
725
- * @typedef {object} DuelsOP
726
- * @property {DuelsModeStats} overall Overall OP duel stats
727
- * @property {DuelsModeStats} '1v1' OP Duel 1v1 stats
728
- * @property {DuelsModeStats} '2v2' OP Duel 2v2 stats
729
- */
730
- /**
731
- * @typedef {object} DuelsUHC
732
- * @property {DuelsModeStats} overall Overall UHC duel stats
733
- * @property {DuelsModeStats} '1v1' UHC Duel 1v1 stats
734
- * @property {DuelsModeStats} '2v2' UHC Duel 2v2 stats
735
- * @property {DuelsModeStats} '4v4' UHC Duel 4v4 stats
736
- * @property {DuelsModeStats} meetup UHC Meetup
737
- */
738
- /**
739
- * @typedef {object} DuelsSkyWars
740
- * @property {DuelsModeStats} overall Overall SkyWars duel stats
741
- * @property {DuelsModeStats} '1v1' SkyWars Duel 1v1 stats
742
- * @property {DuelsModeStats} '2v2' SkyWars Duel 2v2 stats
743
- */
744
- /**
745
- * @typedef {object} DuelsBridge
746
- * @property {BridgeModeStats} overall Overall The Bridge duel stats
747
- * @property {BridgeModeStats} '1v1' The Bridge Duel 1v1 stats
748
- * @property {BridgeModeStats} '2v2' The Bridge Duel 2v2 stats
749
- * @property {BridgeModeStats} '3v3' The Bridge Duel 3v3 stats
750
- * @property {BridgeModeStats} '4v4' The Bridge Duel 4v4 stats
751
- * @property {BridgeModeStats} '2v2v2v2' The Bridge Duel 2v2v2v2 stats
752
- * @property {BridgeModeStats} '3v3v3v3' The Bridge Duel 3v3v3v3 stats
753
- * @property {BridgeCTFModeStats} ctf The Bridge Capture The Flag duel 3v3 stats
754
- */
995
+
755
996
  module.exports = Duels;