hive-bedrock-api 3.0.0-alpha.21 → 3.0.0-alpha.23

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 (91) hide show
  1. package/package.json +2 -2
  2. package/lib/helpers/fetchEndpoint.d.ts +0 -3
  3. package/lib/helpers/fetchEndpoint.js +0 -88
  4. package/lib/helpers/isGame.d.ts +0 -2
  5. package/lib/helpers/isGame.js +0 -7
  6. package/lib/helpers/toPoint.d.ts +0 -1
  7. package/lib/helpers/toPoint.js +0 -10
  8. package/lib/index.d.ts +0 -101
  9. package/lib/index.js +0 -404
  10. package/lib/methods/getAllTimeLeaderboard.d.ts +0 -4
  11. package/lib/methods/getAllTimeLeaderboard.js +0 -85
  12. package/lib/methods/getAllTimeStatistics.d.ts +0 -10
  13. package/lib/methods/getAllTimeStatistics.js +0 -126
  14. package/lib/methods/getGlobalStatistics.d.ts +0 -3
  15. package/lib/methods/getGlobalStatistics.js +0 -56
  16. package/lib/methods/getMaps.d.ts +0 -3
  17. package/lib/methods/getMaps.js +0 -81
  18. package/lib/methods/getMetadata.d.ts +0 -3
  19. package/lib/methods/getMetadata.js +0 -81
  20. package/lib/methods/getMonthlyLeaderboard.d.ts +0 -11
  21. package/lib/methods/getMonthlyLeaderboard.js +0 -88
  22. package/lib/methods/getMonthlyStatistics.d.ts +0 -10
  23. package/lib/methods/getMonthlyStatistics.js +0 -132
  24. package/lib/methods/getPlayerInfomation.d.ts +0 -3
  25. package/lib/methods/getPlayerInfomation.js +0 -72
  26. package/lib/methods/getSeasonLeaderboard.d.ts +0 -10
  27. package/lib/methods/getSeasonLeaderboard.js +0 -87
  28. package/lib/methods/getSeasonStatistics.d.ts +0 -10
  29. package/lib/methods/getSeasonStatistics.js +0 -87
  30. package/lib/processors/bed.d.ts +0 -19
  31. package/lib/processors/bed.js +0 -35
  32. package/lib/processors/bridge.d.ts +0 -24
  33. package/lib/processors/bridge.js +0 -40
  34. package/lib/processors/build.d.ts +0 -19
  35. package/lib/processors/build.js +0 -35
  36. package/lib/processors/ctf.d.ts +0 -19
  37. package/lib/processors/ctf.js +0 -35
  38. package/lib/processors/dr.d.ts +0 -19
  39. package/lib/processors/dr.js +0 -35
  40. package/lib/processors/drop.d.ts +0 -17
  41. package/lib/processors/drop.js +0 -34
  42. package/lib/processors/game.d.ts +0 -315
  43. package/lib/processors/game.js +0 -395
  44. package/lib/processors/global_statistics.d.ts +0 -9
  45. package/lib/processors/global_statistics.js +0 -2
  46. package/lib/processors/grav.d.ts +0 -17
  47. package/lib/processors/grav.js +0 -34
  48. package/lib/processors/ground.d.ts +0 -19
  49. package/lib/processors/ground.js +0 -35
  50. package/lib/processors/helpers/processBuildRatings.d.ts +0 -8
  51. package/lib/processors/helpers/processBuildRatings.js +0 -23
  52. package/lib/processors/helpers/processGameAndXP.d.ts +0 -6
  53. package/lib/processors/helpers/processGameAndXP.js +0 -10
  54. package/lib/processors/helpers/processHiderKillsAndDeaths.d.ts +0 -5
  55. package/lib/processors/helpers/processHiderKillsAndDeaths.js +0 -13
  56. package/lib/processors/helpers/processKillsAndDeaths.d.ts +0 -5
  57. package/lib/processors/helpers/processKillsAndDeaths.js +0 -13
  58. package/lib/processors/helpers/processMurdersAndDeaths.d.ts +0 -5
  59. package/lib/processors/helpers/processMurdersAndDeaths.js +0 -13
  60. package/lib/processors/helpers/processPlayedAndVictories.d.ts +0 -6
  61. package/lib/processors/helpers/processPlayedAndVictories.js +0 -12
  62. package/lib/processors/hide.d.ts +0 -19
  63. package/lib/processors/hide.js +0 -35
  64. package/lib/processors/index.d.ts +0 -12
  65. package/lib/processors/index.js +0 -73
  66. package/lib/processors/map.d.ts +0 -8
  67. package/lib/processors/map.js +0 -2
  68. package/lib/processors/meta.d.ts +0 -45
  69. package/lib/processors/meta.js +0 -2
  70. package/lib/processors/murder.d.ts +0 -19
  71. package/lib/processors/murder.js +0 -35
  72. package/lib/processors/parkour.d.ts +0 -5
  73. package/lib/processors/parkour.js +0 -99
  74. package/lib/processors/party.d.ts +0 -17
  75. package/lib/processors/party.js +0 -34
  76. package/lib/processors/player.d.ts +0 -61
  77. package/lib/processors/player.js +0 -54
  78. package/lib/processors/player_search.d.ts +0 -6
  79. package/lib/processors/player_search.js +0 -11
  80. package/lib/processors/sg.d.ts +0 -19
  81. package/lib/processors/sg.js +0 -35
  82. package/lib/processors/sky.d.ts +0 -19
  83. package/lib/processors/sky.js +0 -35
  84. package/lib/processors/wars.d.ts +0 -19
  85. package/lib/processors/wars.js +0 -35
  86. package/lib/types/output.d.ts +0 -62
  87. package/lib/types/output.js +0 -3
  88. package/lib/types/types.d.ts +0 -24
  89. package/lib/types/types.js +0 -2
  90. package/lib/utils.d.ts +0 -21
  91. package/lib/utils.js +0 -2
@@ -1,395 +0,0 @@
1
- "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- var _a;
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.processors = void 0;
21
- exports.default = processGame;
22
- exports.validateNumber = validateNumber;
23
- exports.calculateKDR = calculateKDR;
24
- exports.calculateWinPercentage = calculateWinPercentage;
25
- exports.calculateLosses = calculateLosses;
26
- exports.calculateTotal = calculateTotal;
27
- exports.roundTo = roundTo;
28
- var hive_bedrock_data_1 = require("hive-bedrock-data");
29
- function processGame(game, timeframe, isLeaderboard, response) {
30
- var _a;
31
- if (!response)
32
- return null;
33
- if ("index" in response && response.human_index === 2147483647)
34
- return null;
35
- if (Array.isArray(response))
36
- return null;
37
- var data = exports.processors[game](response);
38
- if (!data)
39
- return null;
40
- if ("played" in data && data.played === 0)
41
- return null;
42
- if (timeframe === hive_bedrock_data_1.Timeframe.AllTime && "xp" in data)
43
- data.level = (_a = (0, hive_bedrock_data_1.calculateLevelFromXP)(data.xp, game)) !== null && _a !== void 0 ? _a : 1;
44
- if (timeframe === hive_bedrock_data_1.Timeframe.AllTime && "first_played" in response)
45
- data.first_played = response.first_played;
46
- if ((isLeaderboard || timeframe === hive_bedrock_data_1.Timeframe.Monthly) && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
47
- data.position = response.human_index;
48
- if ((isLeaderboard || timeframe === hive_bedrock_data_1.Timeframe.Monthly) && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
49
- data.username = response.username;
50
- if (isLeaderboard && data.id !== hive_bedrock_data_1.Game.ParkourWorlds)
51
- data.UUID = response.UUID;
52
- return data;
53
- }
54
- exports.processors = (_a = {},
55
- _a[hive_bedrock_data_1.Game.BedWars] = function (response) {
56
- var _a, _b, _c, _d, _e, _f, _g;
57
- return ({
58
- id: hive_bedrock_data_1.Game.BedWars,
59
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
60
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
61
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
62
- losses: calculateLosses(response.played, response.victories),
63
- win_percentage: calculateWinPercentage(response.victories, response.played),
64
- kills: (_d = response.kills) !== null && _d !== void 0 ? _d : 0,
65
- deaths: (_e = response.deaths) !== null && _e !== void 0 ? _e : 0,
66
- kdr: calculateKDR(response.kills, response.deaths),
67
- final_kills: (_f = response.final_kills) !== null && _f !== void 0 ? _f : 0,
68
- beds_destroyed: (_g = response.beds_destroyed) !== null && _g !== void 0 ? _g : 0,
69
- });
70
- },
71
- _a[hive_bedrock_data_1.Game.BlockDrop] = function (response) {
72
- var _a, _b, _c, _d, _e, _f, _g;
73
- return ({
74
- id: hive_bedrock_data_1.Game.BlockDrop,
75
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
76
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
77
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
78
- losses: calculateLosses(response.played, response.victories),
79
- win_percentage: calculateWinPercentage(response.victories, response.played),
80
- deaths: (_d = response.deaths) !== null && _d !== void 0 ? _d : 0,
81
- blocks_destroyed: (_e = response.blocks_destroyed) !== null && _e !== void 0 ? _e : 0,
82
- powerups_collected: (_f = response.powerups_collected) !== null && _f !== void 0 ? _f : 0,
83
- vaults_used: (_g = response.vaults_used) !== null && _g !== void 0 ? _g : 0,
84
- });
85
- },
86
- _a[hive_bedrock_data_1.Game.BlockParty] = function (response) {
87
- var _a, _b, _c, _d, _e;
88
- return ({
89
- id: hive_bedrock_data_1.Game.BlockParty,
90
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
91
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
92
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
93
- losses: calculateLosses(response.played, response.victories),
94
- win_percentage: calculateWinPercentage(response.victories, response.played),
95
- powerups_collected: (_d = response.powerups_collected) !== null && _d !== void 0 ? _d : 0,
96
- rounds_survived: (_e = response.rounds_survived) !== null && _e !== void 0 ? _e : 0,
97
- });
98
- },
99
- _a[hive_bedrock_data_1.Game.CaptureTheFlag] = function (response) {
100
- var _a, _b, _c, _d, _e, _f, _g, _h;
101
- return ({
102
- id: hive_bedrock_data_1.Game.CaptureTheFlag,
103
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
104
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
105
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
106
- losses: calculateLosses(response.played, response.victories),
107
- win_percentage: calculateWinPercentage(response.victories, response.played),
108
- kills: (_d = response.kills) !== null && _d !== void 0 ? _d : 0,
109
- deaths: (_e = response.deaths) !== null && _e !== void 0 ? _e : 0,
110
- kdr: calculateKDR(response.kills, response.deaths),
111
- assists: (_f = response.assists) !== null && _f !== void 0 ? _f : 0,
112
- flags_captured: (_g = response.flags_captured) !== null && _g !== void 0 ? _g : 0,
113
- flags_returned: (_h = response.flags_returned) !== null && _h !== void 0 ? _h : 0,
114
- });
115
- },
116
- _a[hive_bedrock_data_1.Game.DeathRun] = function (response) {
117
- var _a, _b, _c, _d, _e, _f, _g;
118
- return ({
119
- id: hive_bedrock_data_1.Game.DeathRun,
120
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
121
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
122
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
123
- losses: calculateLosses(response.played, response.victories),
124
- win_percentage: calculateWinPercentage(response.victories, response.played),
125
- kills: (_d = response.kills) !== null && _d !== void 0 ? _d : 0,
126
- deaths: (_e = response.deaths) !== null && _e !== void 0 ? _e : 0,
127
- kdr: calculateKDR(response.kills, response.deaths),
128
- checkpoints: (_f = response.checkpoints) !== null && _f !== void 0 ? _f : 0,
129
- activated: (_g = response.activated) !== null && _g !== void 0 ? _g : 0,
130
- });
131
- },
132
- _a[hive_bedrock_data_1.Game.Gravity] = function (response) {
133
- var _a, _b, _c, _d, _e, _f;
134
- return ({
135
- id: hive_bedrock_data_1.Game.Gravity,
136
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
137
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
138
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
139
- losses: calculateLosses(response.played, response.victories),
140
- win_percentage: calculateWinPercentage(response.victories, response.played),
141
- deaths: (_d = response.deaths) !== null && _d !== void 0 ? _d : 0,
142
- maps_completed: (_e = response.maps_completed) !== null && _e !== void 0 ? _e : 0,
143
- maps_completed_without_dying: (_f = response.maps_completed_without_dying) !== null && _f !== void 0 ? _f : 0,
144
- });
145
- },
146
- _a[hive_bedrock_data_1.Game.GroundWars] = function (response) {
147
- var _a, _b, _c, _d, _e, _f, _g, _h;
148
- return ({
149
- id: hive_bedrock_data_1.Game.GroundWars,
150
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
151
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
152
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
153
- losses: calculateLosses(response.played, response.victories),
154
- win_percentage: calculateWinPercentage(response.victories, response.played),
155
- kills: (_d = response.kills) !== null && _d !== void 0 ? _d : 0,
156
- deaths: (_e = response.deaths) !== null && _e !== void 0 ? _e : 0,
157
- kdr: calculateKDR(response.kills, response.deaths),
158
- blocks_destroyed: (_f = response.blocks_destroyed) !== null && _f !== void 0 ? _f : 0,
159
- blocks_placed: (_g = response.blocks_placed) !== null && _g !== void 0 ? _g : 0,
160
- projectiles_fired: (_h = response.projectiles_fired) !== null && _h !== void 0 ? _h : 0,
161
- });
162
- },
163
- _a[hive_bedrock_data_1.Game.BuildBattle] = function (response) {
164
- var _a, _b, _c, _d, _e, _f, _g, _h;
165
- return ({
166
- id: hive_bedrock_data_1.Game.BuildBattle,
167
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
168
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
169
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
170
- losses: calculateLosses(response.played, response.victories),
171
- win_percentage: calculateWinPercentage(response.victories, response.played),
172
- rating_meh_received: (_d = response.rating_meh_received) !== null && _d !== void 0 ? _d : 0,
173
- rating_okay_received: (_e = response.rating_okay_received) !== null && _e !== void 0 ? _e : 0,
174
- rating_good_received: (_f = response.rating_good_received) !== null && _f !== void 0 ? _f : 0,
175
- rating_great_received: (_g = response.rating_great_received) !== null && _g !== void 0 ? _g : 0,
176
- rating_love_received: (_h = response.rating_love_received) !== null && _h !== void 0 ? _h : 0,
177
- total_ratings: calculateTotal([
178
- response.rating_meh_received,
179
- response.rating_okay_received,
180
- response.rating_good_received,
181
- response.rating_great_received,
182
- response.rating_love_received,
183
- ]),
184
- });
185
- },
186
- _a[hive_bedrock_data_1.Game.HideAndSeek] = function (response) {
187
- var _a, _b, _c, _d, _e, _f;
188
- return ({
189
- id: hive_bedrock_data_1.Game.HideAndSeek,
190
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
191
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
192
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
193
- losses: calculateLosses(response.played, response.victories),
194
- win_percentage: calculateWinPercentage(response.victories, response.played),
195
- deaths: (_d = response.deaths) !== null && _d !== void 0 ? _d : 0,
196
- hider_kills: (_e = response.hider_kills) !== null && _e !== void 0 ? _e : 0,
197
- kdr: calculateKDR(response.hider_kills, response.deaths),
198
- seeker_kills: (_f = response.seeker_kills) !== null && _f !== void 0 ? _f : 0,
199
- });
200
- },
201
- _a[hive_bedrock_data_1.Game.MurderMystery] = function (response) {
202
- var _a, _b, _c, _d, _e, _f, _g, _h;
203
- return ({
204
- id: hive_bedrock_data_1.Game.MurderMystery,
205
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
206
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
207
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
208
- losses: calculateLosses(response.played, response.victories),
209
- win_percentage: calculateWinPercentage(response.victories, response.played),
210
- murders: (_d = response.murders) !== null && _d !== void 0 ? _d : 0,
211
- deaths: (_e = response.deaths) !== null && _e !== void 0 ? _e : 0,
212
- kdr: calculateKDR(response.murders, response.deaths),
213
- coins: (_f = response.coins) !== null && _f !== void 0 ? _f : 0,
214
- murderer_eliminations: (_g = response.murderer_eliminations) !== null && _g !== void 0 ? _g : 0,
215
- prestige: (_h = response.prestige) !== null && _h !== void 0 ? _h : 0,
216
- });
217
- },
218
- _a[hive_bedrock_data_1.Game.SkyWars] = function (response) {
219
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
220
- return ({
221
- id: hive_bedrock_data_1.Game.SkyWars,
222
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
223
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
224
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
225
- losses: calculateLosses(response.played, response.victories),
226
- win_percentage: calculateWinPercentage(response.victories, response.played),
227
- kills: (_d = response.kills) !== null && _d !== void 0 ? _d : 0,
228
- deaths: (_e = response.deaths) !== null && _e !== void 0 ? _e : 0,
229
- kdr: calculateKDR(response.kills, response.deaths),
230
- mystery_chests_destroyed: (_f = response.mystery_chests_destroyed) !== null && _f !== void 0 ? _f : 0,
231
- ores_mined: (_g = response.ores_mined) !== null && _g !== void 0 ? _g : 0,
232
- spells_used: (_h = response.spells_used) !== null && _h !== void 0 ? _h : 0,
233
- prestige: (_j = response.prestige) !== null && _j !== void 0 ? _j : 0,
234
- });
235
- },
236
- _a[hive_bedrock_data_1.Game.SkyWarsKits] = function (response) {
237
- var _a, _b, _c, _d, _e, _f, _g, _h;
238
- return ({
239
- id: hive_bedrock_data_1.Game.SkyWarsKits,
240
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
241
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
242
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
243
- losses: calculateLosses(response.played, response.victories),
244
- win_percentage: calculateWinPercentage(response.victories, response.played),
245
- kills: (_d = response.kills) !== null && _d !== void 0 ? _d : 0,
246
- deaths: (_e = response.deaths) !== null && _e !== void 0 ? _e : 0,
247
- kdr: calculateKDR(response.kills, response.deaths),
248
- mystery_chests_destroyed: (_f = response.mystery_chests_destroyed) !== null && _f !== void 0 ? _f : 0,
249
- ores_mined: (_g = response.ores_mined) !== null && _g !== void 0 ? _g : 0,
250
- spells_used: (_h = response.spells_used) !== null && _h !== void 0 ? _h : 0,
251
- selected_kit: response.selected_kit,
252
- });
253
- },
254
- _a[hive_bedrock_data_1.Game.SkyWarsClassic] = function (response) {
255
- var _a, _b, _c, _d, _e;
256
- return ({
257
- id: hive_bedrock_data_1.Game.SkyWarsClassic,
258
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
259
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
260
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
261
- losses: calculateLosses(response.played, response.victories),
262
- win_percentage: calculateWinPercentage(response.victories, response.played),
263
- kills: (_d = response.kills) !== null && _d !== void 0 ? _d : 0,
264
- deaths: (_e = response.deaths) !== null && _e !== void 0 ? _e : 0,
265
- kdr: calculateKDR(response.kills, response.deaths),
266
- selected_kit: response.selected_kit,
267
- });
268
- },
269
- _a[hive_bedrock_data_1.Game.SurvivalGames] = function (response) {
270
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
271
- return ({
272
- id: hive_bedrock_data_1.Game.SurvivalGames,
273
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
274
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
275
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
276
- losses: calculateLosses(response.played, response.victories),
277
- win_percentage: calculateWinPercentage(response.victories, response.played),
278
- kills: (_d = response.kills) !== null && _d !== void 0 ? _d : 0,
279
- deaths: (_e = response.deaths) !== null && _e !== void 0 ? _e : 0,
280
- kdr: calculateKDR(response.kills, response.deaths),
281
- cows: (_f = response.cows) !== null && _f !== void 0 ? _f : 0,
282
- deathmatches: (_g = response.deathmatches) !== null && _g !== void 0 ? _g : 0,
283
- crates: (_h = response.crates) !== null && _h !== void 0 ? _h : 0,
284
- teleporters_used: (_j = response.teleporters_used) !== null && _j !== void 0 ? _j : 0,
285
- launchpads_used: (_k = response.launchpads_used) !== null && _k !== void 0 ? _k : 0,
286
- flares_used: (_l = response.flares_used) !== null && _l !== void 0 ? _l : 0,
287
- });
288
- },
289
- _a[hive_bedrock_data_1.Game.TheBridge] = function (response) {
290
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
291
- return ({
292
- id: hive_bedrock_data_1.Game.TheBridge,
293
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
294
- played: (_c = (_b = response.played) !== null && _b !== void 0 ? _b : response.m_solo_played) !== null && _c !== void 0 ? _c : 0,
295
- victories: (_e = (_d = response.victories) !== null && _d !== void 0 ? _d : response.m_solo_victories) !== null && _e !== void 0 ? _e : 0,
296
- losses: calculateLosses((_f = response.played) !== null && _f !== void 0 ? _f : response.m_solo_played, (_g = response.victories) !== null && _g !== void 0 ? _g : response.m_solo_victories),
297
- win_percentage: calculateWinPercentage((_h = response.victories) !== null && _h !== void 0 ? _h : response.m_solo_victories, (_j = response.played) !== null && _j !== void 0 ? _j : response.m_solo_played),
298
- kills: (_l = (_k = response.kills) !== null && _k !== void 0 ? _k : response.m_solo_kills) !== null && _l !== void 0 ? _l : 0,
299
- deaths: (_o = (_m = response.deaths) !== null && _m !== void 0 ? _m : response.m_solo_deaths) !== null && _o !== void 0 ? _o : 0,
300
- kdr: calculateKDR((_p = response.kills) !== null && _p !== void 0 ? _p : response.m_solo_kills, (_q = response.deaths) !== null && _q !== void 0 ? _q : response.m_solo_deaths),
301
- goals: (_s = (_r = response.goals) !== null && _r !== void 0 ? _r : response.m_solo_goals) !== null && _s !== void 0 ? _s : 0,
302
- });
303
- },
304
- _a[hive_bedrock_data_1.Game.TreasureWars] = function (response) {
305
- var _a, _b, _c, _d, _e, _f, _g, _h;
306
- return ({
307
- id: hive_bedrock_data_1.Game.TreasureWars,
308
- xp: (_a = response.xp) !== null && _a !== void 0 ? _a : 0,
309
- played: (_b = response.played) !== null && _b !== void 0 ? _b : 0,
310
- victories: (_c = response.victories) !== null && _c !== void 0 ? _c : 0,
311
- losses: calculateLosses(response.played, response.victories),
312
- win_percentage: calculateWinPercentage(response.victories, response.played),
313
- kills: (_d = response.kills) !== null && _d !== void 0 ? _d : 0,
314
- deaths: (_e = response.deaths) !== null && _e !== void 0 ? _e : 0,
315
- kdr: calculateKDR(response.kills, response.deaths),
316
- final_kills: (_f = response.final_kills) !== null && _f !== void 0 ? _f : 0,
317
- treasure_destroyed: (_g = response.treasure_destroyed) !== null && _g !== void 0 ? _g : 0,
318
- prestige: (_h = response.prestige) !== null && _h !== void 0 ? _h : 0,
319
- });
320
- },
321
- _a[hive_bedrock_data_1.Game.ParkourWorlds] = function (response) {
322
- var _a;
323
- return response.parkours
324
- ? {
325
- id: hive_bedrock_data_1.Game.ParkourWorlds,
326
- worlds: Object.entries(response.parkours)
327
- .filter(function (_a) {
328
- var _b = __read(_a, 2), _ = _b[0], value = _b[1];
329
- return typeof value === "object";
330
- })
331
- .map(function (_a) {
332
- var _b;
333
- var _c = __read(_a, 2), key = _c[0], value = _c[1];
334
- return ({
335
- name: key,
336
- parkour_stars: (_b = value.parkour_stars) !== null && _b !== void 0 ? _b : 0,
337
- courses: Object.entries(value)
338
- .filter(function (_a) {
339
- var _b = __read(_a, 2), _ = _b[0], value = _b[1];
340
- return typeof value === "object";
341
- })
342
- .map(function (_a) {
343
- var _b;
344
- var _c = __read(_a, 2), key = _c[0], value = _c[1];
345
- return ({
346
- name: key,
347
- best_run_time: value.best_run_time,
348
- best_checkpoint_times: Object.entries(value.best_checkpoint_times).map(function (_a) {
349
- var _b = __read(_a, 2), key = _b[0], value = _b[1];
350
- return ({
351
- position: { x: Number(key.split(",")[0]), y: Number(key.split(",")[1]), z: Number(key.split(",")[2]) },
352
- time: value,
353
- });
354
- }),
355
- collected_stars: value.collected_stars.map(function (value) { return ({
356
- x: Number(value.split(",")[0]),
357
- y: Number(value.split(",")[1]),
358
- z: Number(value.split(",")[2]),
359
- }); }),
360
- course_stars: (_b = value.course_stars) !== null && _b !== void 0 ? _b : 0,
361
- });
362
- }),
363
- });
364
- }),
365
- total_stars: (_a = response.parkours.total_stars) !== null && _a !== void 0 ? _a : 0,
366
- }
367
- : null;
368
- },
369
- _a);
370
- function validateNumber(value, def) {
371
- if (def === void 0) { def = 0; }
372
- if (isNaN(value) || !isFinite(value))
373
- return def;
374
- return value !== null && value !== void 0 ? value : def;
375
- }
376
- function calculateKDR(kills, deaths) {
377
- if (deaths === 0)
378
- return validateNumber(kills !== null && kills !== void 0 ? kills : 0);
379
- return roundTo(validateNumber((kills !== null && kills !== void 0 ? kills : 0) / (deaths !== null && deaths !== void 0 ? deaths : 0)), 2);
380
- }
381
- function calculateWinPercentage(victories, played) {
382
- if (victories === 0 && played === 0)
383
- return 0;
384
- return validateNumber((victories !== null && victories !== void 0 ? victories : 0) / (played !== null && played !== void 0 ? played : 0));
385
- }
386
- function calculateLosses(played, victories) {
387
- return validateNumber((played !== null && played !== void 0 ? played : 0) - (victories !== null && victories !== void 0 ? victories : 0));
388
- }
389
- function calculateTotal(values) {
390
- return validateNumber(values.reduce(function (a, b) { return (a !== null && a !== void 0 ? a : 0) + (b !== null && b !== void 0 ? b : 0); }, 0));
391
- }
392
- function roundTo(value, places) {
393
- if (places === void 0) { places = 2; }
394
- return validateNumber(Number(value.toFixed(places)));
395
- }
@@ -1,9 +0,0 @@
1
- import { Game } from "hive-bedrock-data";
2
- export interface ProcessedGlobalStatisticsResponse {
3
- unique_players: {
4
- [key in Game]: number;
5
- } & {
6
- global: number;
7
- main: number;
8
- };
9
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,17 +0,0 @@
1
- import { Game, Statistics, Timeframe } from "hive-bedrock-data";
2
- import { OmittedSpecialStatistics } from "../types/types";
3
- export interface Processed_Gravity_AllTimeStatistics extends OmittedSpecialStatistics<Game.Gravity, Timeframe.AllTime> {
4
- id: Game.Gravity;
5
- level: number;
6
- losses: number;
7
- win_percentage: number;
8
- first_played: number | null;
9
- }
10
- export interface Processed_Gravity_MonthlyStatistics extends Statistics<Game.Gravity, Timeframe.Monthly> {
11
- id: Game.Gravity;
12
- level: number;
13
- losses: number;
14
- win_percentage: number;
15
- }
16
- export declare function processAllTime_GRAV(statistics: Partial<Statistics<Game.Gravity, Timeframe.AllTime>>): Processed_Gravity_AllTimeStatistics | null;
17
- export declare function processMonthly_GRAV(statistics: Partial<Statistics<Game.Gravity, Timeframe.Monthly>>): Processed_Gravity_MonthlyStatistics | null;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.processAllTime_GRAV = processAllTime_GRAV;
18
- exports.processMonthly_GRAV = processMonthly_GRAV;
19
- var hive_bedrock_data_1 = require("hive-bedrock-data");
20
- var processGameAndXP_1 = __importDefault(require("./helpers/processGameAndXP"));
21
- var processPlayedAndVictories_1 = __importDefault(require("./helpers/processPlayedAndVictories"));
22
- function processAllTime_GRAV(statistics) {
23
- var _a, _b, _c, _d;
24
- if (!statistics || Array.isArray(statistics))
25
- return null;
26
- return __assign(__assign(__assign({ UUID: statistics.UUID }, (0, processGameAndXP_1.default)(hive_bedrock_data_1.Game.Gravity, statistics.xp)), (0, processPlayedAndVictories_1.default)(statistics.played, statistics.victories)), { deaths: (_a = statistics.deaths) !== null && _a !== void 0 ? _a : 0, maps_completed: (_b = statistics.maps_completed) !== null && _b !== void 0 ? _b : 0, maps_completed_without_dying: (_c = statistics.maps_completed_without_dying) !== null && _c !== void 0 ? _c : 0, first_played: (_d = statistics.first_played) !== null && _d !== void 0 ? _d : null });
27
- }
28
- function processMonthly_GRAV(statistics) {
29
- var _a, _b, _c, _d, _e;
30
- if (!statistics || Array.isArray(statistics))
31
- return null;
32
- var index = (_a = statistics.index) !== null && _a !== void 0 ? _a : 0;
33
- return __assign(__assign(__assign({ index: (_b = statistics.index) !== null && _b !== void 0 ? _b : 0, human_index: index + 1, username: statistics.username }, (0, processGameAndXP_1.default)(hive_bedrock_data_1.Game.Gravity, statistics.xp)), (0, processPlayedAndVictories_1.default)(statistics.played, statistics.victories)), { deaths: (_c = statistics.deaths) !== null && _c !== void 0 ? _c : 0, maps_completed: (_d = statistics.maps_completed) !== null && _d !== void 0 ? _d : 0, maps_completed_without_dying: (_e = statistics.maps_completed_without_dying) !== null && _e !== void 0 ? _e : 0 });
34
- }
@@ -1,19 +0,0 @@
1
- import { Game, Statistics, Timeframe } from "hive-bedrock-data";
2
- import { OmittedSpecialStatistics } from "../types/types";
3
- export interface Processed_GroundWars_AllTimeStatistics extends OmittedSpecialStatistics<Game.GroundWars, Timeframe.AllTime> {
4
- id: Game.GroundWars;
5
- level: number;
6
- losses: number;
7
- win_percentage: number;
8
- kdr: number;
9
- first_played: number | null;
10
- }
11
- export interface Processed_GroundWars_MonthlyStatistics extends Statistics<Game.GroundWars, Timeframe.Monthly> {
12
- id: Game.GroundWars;
13
- level: number;
14
- losses: number;
15
- win_percentage: number;
16
- kdr: number;
17
- }
18
- export declare function processAllTime_GROUND(statistics: Partial<Statistics<Game.GroundWars, Timeframe.AllTime>>): Processed_GroundWars_AllTimeStatistics | null;
19
- export declare function processMonthly_GROUND(statistics: Partial<Statistics<Game.GroundWars, Timeframe.Monthly>>): Processed_GroundWars_MonthlyStatistics | null;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.processAllTime_GROUND = processAllTime_GROUND;
18
- exports.processMonthly_GROUND = processMonthly_GROUND;
19
- var hive_bedrock_data_1 = require("hive-bedrock-data");
20
- var processGameAndXP_1 = __importDefault(require("./helpers/processGameAndXP"));
21
- var processPlayedAndVictories_1 = __importDefault(require("./helpers/processPlayedAndVictories"));
22
- var processKillsAndDeaths_1 = __importDefault(require("./helpers/processKillsAndDeaths"));
23
- function processAllTime_GROUND(statistics) {
24
- var _a, _b, _c, _d;
25
- if (!statistics || Array.isArray(statistics))
26
- return null;
27
- return __assign(__assign(__assign(__assign({ UUID: statistics.UUID }, (0, processGameAndXP_1.default)(hive_bedrock_data_1.Game.GroundWars, statistics.xp)), (0, processPlayedAndVictories_1.default)(statistics.played, statistics.victories)), (0, processKillsAndDeaths_1.default)(statistics.kills, statistics.deaths)), { blocks_placed: (_a = statistics.blocks_placed) !== null && _a !== void 0 ? _a : 0, blocks_destroyed: (_b = statistics.blocks_destroyed) !== null && _b !== void 0 ? _b : 0, projectiles_fired: (_c = statistics.projectiles_fired) !== null && _c !== void 0 ? _c : 0, first_played: (_d = statistics.first_played) !== null && _d !== void 0 ? _d : null });
28
- }
29
- function processMonthly_GROUND(statistics) {
30
- var _a, _b, _c, _d, _e;
31
- if (!statistics || Array.isArray(statistics))
32
- return null;
33
- var index = (_a = statistics.index) !== null && _a !== void 0 ? _a : 0;
34
- return __assign(__assign(__assign(__assign({ index: (_b = statistics.index) !== null && _b !== void 0 ? _b : 0, human_index: index + 1, username: statistics.username }, (0, processGameAndXP_1.default)(hive_bedrock_data_1.Game.GroundWars, statistics.xp)), (0, processPlayedAndVictories_1.default)(statistics.played, statistics.victories)), (0, processKillsAndDeaths_1.default)(statistics.kills, statistics.deaths)), { blocks_placed: (_c = statistics.blocks_placed) !== null && _c !== void 0 ? _c : 0, blocks_destroyed: (_d = statistics.blocks_destroyed) !== null && _d !== void 0 ? _d : 0, projectiles_fired: (_e = statistics.projectiles_fired) !== null && _e !== void 0 ? _e : 0 });
35
- }
@@ -1,8 +0,0 @@
1
- export default function processBuildRatings(rating_love_received?: number, rating_great_received?: number, rating_good_received?: number, rating_okay_received?: number, rating_meh_received?: number): {
2
- total_ratings: number;
3
- rating_love_received: number;
4
- rating_great_received: number;
5
- rating_good_received: number;
6
- rating_okay_received: number;
7
- rating_meh_received: number;
8
- };
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = processBuildRatings;
4
- function processBuildRatings(rating_love_received, rating_great_received, rating_good_received, rating_okay_received, rating_meh_received) {
5
- rating_love_received !== null && rating_love_received !== void 0 ? rating_love_received : (rating_love_received = 0);
6
- rating_great_received !== null && rating_great_received !== void 0 ? rating_great_received : (rating_great_received = 0);
7
- rating_good_received !== null && rating_good_received !== void 0 ? rating_good_received : (rating_good_received = 0);
8
- rating_okay_received !== null && rating_okay_received !== void 0 ? rating_okay_received : (rating_okay_received = 0);
9
- rating_meh_received !== null && rating_meh_received !== void 0 ? rating_meh_received : (rating_meh_received = 0);
10
- var total_ratings = rating_love_received +
11
- rating_great_received +
12
- rating_good_received +
13
- rating_okay_received +
14
- rating_meh_received;
15
- return {
16
- total_ratings: total_ratings,
17
- rating_love_received: rating_love_received,
18
- rating_great_received: rating_great_received,
19
- rating_good_received: rating_good_received,
20
- rating_okay_received: rating_okay_received,
21
- rating_meh_received: rating_meh_received,
22
- };
23
- }
@@ -1,6 +0,0 @@
1
- import { Game } from "hive-bedrock-data";
2
- export default function processGameAndXP<G extends Game>(game: G, xp?: number): {
3
- id: G;
4
- xp: number;
5
- level: number;
6
- };
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = processGameAndXP;
4
- var hive_bedrock_data_1 = require("hive-bedrock-data");
5
- function processGameAndXP(game, xp) {
6
- var _a;
7
- xp !== null && xp !== void 0 ? xp : (xp = 0);
8
- var level = (_a = (0, hive_bedrock_data_1.calculateLevelFromXP)(xp, game)) !== null && _a !== void 0 ? _a : 1;
9
- return { id: game, xp: xp, level: level };
10
- }
@@ -1,5 +0,0 @@
1
- export default function processHiderKillsAndDeaths(hider_kills?: number, deaths?: number): {
2
- hider_kills: number;
3
- deaths: number;
4
- kdr: number;
5
- };
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = processHiderKillsAndDeaths;
7
- var toPoint_1 = __importDefault(require("../../helpers/toPoint"));
8
- function processHiderKillsAndDeaths(hider_kills, deaths) {
9
- hider_kills !== null && hider_kills !== void 0 ? hider_kills : (hider_kills = 0);
10
- deaths !== null && deaths !== void 0 ? deaths : (deaths = 0);
11
- var kdr = (0, toPoint_1.default)(hider_kills / deaths, 2);
12
- return { hider_kills: hider_kills, deaths: deaths, kdr: kdr };
13
- }
@@ -1,5 +0,0 @@
1
- export default function processKillsAndDeaths(kills?: number, deaths?: number): {
2
- kills: number;
3
- deaths: number;
4
- kdr: number;
5
- };
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = processKillsAndDeaths;
7
- var toPoint_1 = __importDefault(require("../../helpers/toPoint"));
8
- function processKillsAndDeaths(kills, deaths) {
9
- kills !== null && kills !== void 0 ? kills : (kills = 0);
10
- deaths !== null && deaths !== void 0 ? deaths : (deaths = 0);
11
- var kdr = (0, toPoint_1.default)(kills / deaths, 2);
12
- return { kills: kills, deaths: deaths, kdr: kdr };
13
- }
@@ -1,5 +0,0 @@
1
- export default function processMurdersAndDeaths(murders?: number, deaths?: number): {
2
- murders: number;
3
- deaths: number;
4
- kdr: number;
5
- };
@@ -1,13 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = processMurdersAndDeaths;
7
- var toPoint_1 = __importDefault(require("../../helpers/toPoint"));
8
- function processMurdersAndDeaths(murders, deaths) {
9
- murders !== null && murders !== void 0 ? murders : (murders = 0);
10
- deaths !== null && deaths !== void 0 ? deaths : (deaths = 0);
11
- var kdr = (0, toPoint_1.default)(murders / deaths, 2);
12
- return { murders: murders, deaths: deaths, kdr: kdr };
13
- }
@@ -1,6 +0,0 @@
1
- export default function processPlayedAndVictories(played?: number, victories?: number): {
2
- played: number;
3
- victories: number;
4
- losses: number;
5
- win_percentage: number;
6
- };