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