@rian8337/osu-droid-utilities 1.4.16 → 2.0.0-alpha.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/dist/index.js +340 -15
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/typings/index.d.ts +209 -229
- package/dist/Player.js +0 -137
- package/dist/Player.js.map +0 -1
- package/dist/Score.js +0 -155
- package/dist/Score.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,340 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var osuBase = require('@rian8337/osu-base');
|
|
6
|
+
var osuDroidReplayAnalyzer = require('@rian8337/osu-droid-replay-analyzer');
|
|
7
|
+
var cryptoJs = require('crypto-js');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents an osu!droid score.
|
|
11
|
+
*/
|
|
12
|
+
class Score {
|
|
13
|
+
/**
|
|
14
|
+
* The uid of the player.
|
|
15
|
+
*/
|
|
16
|
+
uid;
|
|
17
|
+
/**
|
|
18
|
+
* The ID of the score.
|
|
19
|
+
*/
|
|
20
|
+
scoreID;
|
|
21
|
+
/**
|
|
22
|
+
* The player's name.
|
|
23
|
+
*/
|
|
24
|
+
username;
|
|
25
|
+
/**
|
|
26
|
+
* The title of the beatmap.
|
|
27
|
+
*/
|
|
28
|
+
title;
|
|
29
|
+
/**
|
|
30
|
+
* The maximum combo achieved in the play.
|
|
31
|
+
*/
|
|
32
|
+
combo;
|
|
33
|
+
/**
|
|
34
|
+
* The score achieved in the play.
|
|
35
|
+
*/
|
|
36
|
+
score;
|
|
37
|
+
/**
|
|
38
|
+
* The rank achieved in the play.
|
|
39
|
+
*/
|
|
40
|
+
rank;
|
|
41
|
+
/**
|
|
42
|
+
* The date of which the play was set.
|
|
43
|
+
*/
|
|
44
|
+
date;
|
|
45
|
+
/**
|
|
46
|
+
* The accuracy achieved in the play.
|
|
47
|
+
*/
|
|
48
|
+
accuracy;
|
|
49
|
+
/**
|
|
50
|
+
* Enabled modifications in the score.
|
|
51
|
+
*/
|
|
52
|
+
mods;
|
|
53
|
+
/**
|
|
54
|
+
* MD5 hash of the play.
|
|
55
|
+
*/
|
|
56
|
+
hash;
|
|
57
|
+
/**
|
|
58
|
+
* The speed multiplier of the play.
|
|
59
|
+
*/
|
|
60
|
+
speedMultiplier = 1;
|
|
61
|
+
/**
|
|
62
|
+
* The forced AR of the play.
|
|
63
|
+
*/
|
|
64
|
+
forcedAR;
|
|
65
|
+
/**
|
|
66
|
+
* The replay of the score.
|
|
67
|
+
*/
|
|
68
|
+
replay;
|
|
69
|
+
constructor(values) {
|
|
70
|
+
this.uid = values?.uid ?? 0;
|
|
71
|
+
this.scoreID = values?.scoreID ?? 0;
|
|
72
|
+
this.username = values?.username ?? "";
|
|
73
|
+
this.title = values?.title ?? "";
|
|
74
|
+
this.combo = values?.combo ?? 0;
|
|
75
|
+
this.score = values?.score ?? 0;
|
|
76
|
+
this.rank = values?.rank ?? "";
|
|
77
|
+
this.date = new Date(values?.date ?? 0);
|
|
78
|
+
this.accuracy = values?.accuracy ?? new osuBase.Accuracy({});
|
|
79
|
+
this.hash = values?.hash ?? "";
|
|
80
|
+
const modstrings = (values?.mods ?? "").split("|");
|
|
81
|
+
let actualMods = "";
|
|
82
|
+
for (let i = 0; i < modstrings.length; ++i) {
|
|
83
|
+
if (!modstrings[i]) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (modstrings[i].startsWith("AR")) {
|
|
87
|
+
this.forcedAR = parseFloat(modstrings[i].replace("AR", ""));
|
|
88
|
+
}
|
|
89
|
+
else if (modstrings[i].startsWith("x")) {
|
|
90
|
+
this.speedMultiplier = parseFloat(modstrings[i].replace("x", ""));
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
actualMods += modstrings[i];
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
this.mods = osuBase.ModUtil.droidStringToMods(actualMods);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Retrieves play information.
|
|
100
|
+
*
|
|
101
|
+
* @param params Function parameters.
|
|
102
|
+
*/
|
|
103
|
+
static async getFromHash(params) {
|
|
104
|
+
const score = new Score();
|
|
105
|
+
const uid = (score.uid = params.uid);
|
|
106
|
+
const hash = (score.hash = params.hash);
|
|
107
|
+
if (!uid || !hash) {
|
|
108
|
+
throw new Error("Uid and hash must be specified");
|
|
109
|
+
}
|
|
110
|
+
const apiRequestBuilder = new osuBase.DroidAPIRequestBuilder()
|
|
111
|
+
.setEndpoint("scoresearchv2.php")
|
|
112
|
+
.addParameter("uid", uid)
|
|
113
|
+
.addParameter("hash", hash);
|
|
114
|
+
const result = await apiRequestBuilder.sendRequest();
|
|
115
|
+
if (result.statusCode !== 200) {
|
|
116
|
+
throw new Error("Error retrieving score data");
|
|
117
|
+
}
|
|
118
|
+
const entry = result.data.toString("utf-8").split("<br>");
|
|
119
|
+
entry.shift();
|
|
120
|
+
if (entry.length === 0) {
|
|
121
|
+
return score;
|
|
122
|
+
}
|
|
123
|
+
score.fillInformation(entry[0]);
|
|
124
|
+
return score;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Fills this instance with score information.
|
|
128
|
+
*
|
|
129
|
+
* @param info The score information from API response to fill with.
|
|
130
|
+
*/
|
|
131
|
+
fillInformation(info) {
|
|
132
|
+
const play = info.split(" ");
|
|
133
|
+
this.scoreID = parseInt(play[0]);
|
|
134
|
+
this.uid = parseInt(play[1]);
|
|
135
|
+
this.username = play[2];
|
|
136
|
+
this.score = parseInt(play[3]);
|
|
137
|
+
this.combo = parseInt(play[4]);
|
|
138
|
+
this.rank = play[5];
|
|
139
|
+
const modstrings = play[6].split("|");
|
|
140
|
+
let actualMods = "";
|
|
141
|
+
for (let i = 0; i < modstrings.length; ++i) {
|
|
142
|
+
if (!modstrings[i]) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (modstrings[i].startsWith("AR")) {
|
|
146
|
+
this.forcedAR = parseFloat(modstrings[i].replace("AR", ""));
|
|
147
|
+
}
|
|
148
|
+
else if (modstrings[i].startsWith("x")) {
|
|
149
|
+
this.speedMultiplier = parseFloat(modstrings[i].replace("x", ""));
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
actualMods += modstrings[i];
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
this.mods = osuBase.ModUtil.droidStringToMods(actualMods);
|
|
156
|
+
this.accuracy = new osuBase.Accuracy({
|
|
157
|
+
n300: parseInt(play[8]),
|
|
158
|
+
n100: parseInt(play[9]),
|
|
159
|
+
n50: parseInt(play[10]),
|
|
160
|
+
nmiss: parseInt(play[11]),
|
|
161
|
+
});
|
|
162
|
+
const date = new Date(parseInt(play[12]) * 1000);
|
|
163
|
+
date.setUTCHours(date.getUTCHours() + 6);
|
|
164
|
+
this.date = date;
|
|
165
|
+
this.title = play[13]
|
|
166
|
+
.substring(0, play[13].length - 4)
|
|
167
|
+
.replace(/_/g, " ");
|
|
168
|
+
this.hash = play[14];
|
|
169
|
+
return this;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Returns the complete mod string of this score (mods, speed multiplier, and force AR combined).
|
|
173
|
+
*/
|
|
174
|
+
getCompleteModString() {
|
|
175
|
+
let finalString = `+${this.mods.length > 0 ? this.mods.map((v) => v.acronym) : "No Mod"}`;
|
|
176
|
+
if (this.forcedAR !== undefined || this.speedMultiplier !== 1) {
|
|
177
|
+
finalString += " (";
|
|
178
|
+
if (this.forcedAR !== undefined) {
|
|
179
|
+
finalString += `AR${this.forcedAR}`;
|
|
180
|
+
}
|
|
181
|
+
if (this.speedMultiplier !== 1) {
|
|
182
|
+
if (this.forcedAR !== undefined) {
|
|
183
|
+
finalString += ", ";
|
|
184
|
+
}
|
|
185
|
+
finalString += `${this.speedMultiplier}x`;
|
|
186
|
+
}
|
|
187
|
+
finalString += ")";
|
|
188
|
+
}
|
|
189
|
+
return finalString;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Downloads the replay of this score.
|
|
193
|
+
*/
|
|
194
|
+
async downloadReplay() {
|
|
195
|
+
if (!this.scoreID || this.replay) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
this.replay = await new osuDroidReplayAnalyzer.ReplayAnalyzer({
|
|
199
|
+
scoreID: this.scoreID,
|
|
200
|
+
}).analyze();
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Returns a string representative of the class.
|
|
204
|
+
*/
|
|
205
|
+
toString() {
|
|
206
|
+
return `Player: ${this.username}, uid: ${this.uid}, title: ${this.title}, score: ${this.score}, combo: ${this.combo}, rank: ${this.rank}, acc: ${this.accuracy}%, date: ${this.date}, mods: ${this.mods}, hash: ${this.hash}`;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Represents an osu!droid player.
|
|
212
|
+
*/
|
|
213
|
+
class Player {
|
|
214
|
+
/**
|
|
215
|
+
* The uid of the player.
|
|
216
|
+
*/
|
|
217
|
+
uid = 0;
|
|
218
|
+
/**
|
|
219
|
+
* The username of the player.
|
|
220
|
+
*/
|
|
221
|
+
username = "";
|
|
222
|
+
/**
|
|
223
|
+
* The avatar URL of the player.
|
|
224
|
+
*/
|
|
225
|
+
avatarURL = "";
|
|
226
|
+
/**
|
|
227
|
+
* The location of the player based on ISO 3166-1 country codes. See {@link https://en.wikipedia.org/wiki/ISO_3166-1 this} Wikipedia page for more information.
|
|
228
|
+
*/
|
|
229
|
+
location = "";
|
|
230
|
+
/**
|
|
231
|
+
* The email that is attached to the player's account.
|
|
232
|
+
*/
|
|
233
|
+
email = "";
|
|
234
|
+
/**
|
|
235
|
+
* The overall rank of the player.
|
|
236
|
+
*/
|
|
237
|
+
rank = 0;
|
|
238
|
+
/**
|
|
239
|
+
* The total score of the player.
|
|
240
|
+
*/
|
|
241
|
+
score = 0;
|
|
242
|
+
/**
|
|
243
|
+
* The overall accuracy of the player.
|
|
244
|
+
*/
|
|
245
|
+
accuracy = 0;
|
|
246
|
+
/**
|
|
247
|
+
* The amount of times the player has played.
|
|
248
|
+
*/
|
|
249
|
+
playCount = 0;
|
|
250
|
+
/**
|
|
251
|
+
* Recent plays of the player.
|
|
252
|
+
*/
|
|
253
|
+
recentPlays = [];
|
|
254
|
+
/**
|
|
255
|
+
* Retrieves a player's info based on uid or username.
|
|
256
|
+
*
|
|
257
|
+
* Either uid or username must be specified.
|
|
258
|
+
*/
|
|
259
|
+
static async getInformation(params) {
|
|
260
|
+
const player = new Player();
|
|
261
|
+
const uid = params.uid;
|
|
262
|
+
const username = params.username;
|
|
263
|
+
if (!uid && !username) {
|
|
264
|
+
throw new Error("Uid must be integer or enter username");
|
|
265
|
+
}
|
|
266
|
+
const apiRequestBuilder = new osuBase.DroidAPIRequestBuilder().setEndpoint("getuserinfo.php");
|
|
267
|
+
if (uid) {
|
|
268
|
+
apiRequestBuilder.addParameter("uid", uid);
|
|
269
|
+
}
|
|
270
|
+
else if (username) {
|
|
271
|
+
apiRequestBuilder.addParameter("username", username);
|
|
272
|
+
}
|
|
273
|
+
const result = await apiRequestBuilder.sendRequest();
|
|
274
|
+
if (result.statusCode !== 200) {
|
|
275
|
+
throw new Error("Error retrieving player data");
|
|
276
|
+
}
|
|
277
|
+
const data = result.data.toString("utf-8");
|
|
278
|
+
const resArr = data.split("<br>");
|
|
279
|
+
const headerRes = resArr[0].split(" ");
|
|
280
|
+
if (headerRes[0] === "FAILED") {
|
|
281
|
+
return player;
|
|
282
|
+
}
|
|
283
|
+
player.fillInformation(data);
|
|
284
|
+
return player;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Fills this instance with player information.
|
|
288
|
+
*
|
|
289
|
+
* @param info The player information from API response to fill with.
|
|
290
|
+
*/
|
|
291
|
+
fillInformation(info) {
|
|
292
|
+
const resArr = info.split("<br>");
|
|
293
|
+
const headerRes = resArr[0].split(" ");
|
|
294
|
+
if (headerRes[0] === "FAILED") {
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
const obj = JSON.parse(resArr[1]);
|
|
298
|
+
this.uid = parseInt(headerRes[1]);
|
|
299
|
+
this.username = headerRes[2];
|
|
300
|
+
this.score = parseInt(headerRes[3]);
|
|
301
|
+
this.playCount = parseInt(headerRes[4]);
|
|
302
|
+
this.accuracy = parseFloat((parseFloat(headerRes[5]) * 100).toFixed(2));
|
|
303
|
+
this.email = headerRes[6];
|
|
304
|
+
this.location = headerRes[7];
|
|
305
|
+
this.avatarURL = `https://osudroid.moe/user/avatar?id=${cryptoJs.MD5(this.email.trim().toLowerCase()).toString()}&s=200`;
|
|
306
|
+
this.rank = obj.rank;
|
|
307
|
+
const recent = obj.recent;
|
|
308
|
+
for (const play of recent) {
|
|
309
|
+
this.recentPlays.push(new Score({
|
|
310
|
+
uid: this.uid,
|
|
311
|
+
username: this.username,
|
|
312
|
+
scoreID: play.scoreid,
|
|
313
|
+
score: play.score,
|
|
314
|
+
accuracy: new osuBase.Accuracy({
|
|
315
|
+
n300: play.perfect,
|
|
316
|
+
n100: play.good,
|
|
317
|
+
n50: play.bad,
|
|
318
|
+
nmiss: play.miss,
|
|
319
|
+
}),
|
|
320
|
+
rank: play.mark,
|
|
321
|
+
combo: play.combo,
|
|
322
|
+
title: play.filename,
|
|
323
|
+
date: (play.date + 3600 * 6) * 1000,
|
|
324
|
+
mods: play.mode,
|
|
325
|
+
hash: play.hash,
|
|
326
|
+
}));
|
|
327
|
+
}
|
|
328
|
+
return this;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* Returns a string representative of the class.
|
|
332
|
+
*/
|
|
333
|
+
toString() {
|
|
334
|
+
return `Username: ${this.username}\nUID: ${this.uid}\nRank: ${this.rank}\nScore: ${this.score}\nPlay count: ${this.playCount}`;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
exports.Player = Player;
|
|
339
|
+
exports.Score = Score;
|
|
340
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/Score.ts","../src/Player.ts"],"sourcesContent":[null,null],"names":["Accuracy","ModUtil","DroidAPIRequestBuilder","ReplayAnalyzer","MD5"],"mappings":";;;;;;;;AAkEA;;AAEG;MACU,KAAK,CAAA;AACd;;AAEG;AACH,IAAA,GAAG,CAAS;AAEZ;;AAEG;AACH,IAAA,OAAO,CAAS;AAEhB;;AAEG;AACH,IAAA,QAAQ,CAAS;AAEjB;;AAEG;AACH,IAAA,KAAK,CAAS;AAEd;;AAEG;AACH,IAAA,KAAK,CAAS;AAEd;;AAEG;AACH,IAAA,KAAK,CAAS;AAEd;;AAEG;AACH,IAAA,IAAI,CAAS;AAEb;;AAEG;AACH,IAAA,IAAI,CAAO;AAEX;;AAEG;AACH,IAAA,QAAQ,CAAW;AAEnB;;AAEG;AACH,IAAA,IAAI,CAAQ;AAEZ;;AAEG;AACH,IAAA,IAAI,CAAS;AAEb;;AAEG;IACH,eAAe,GAAW,CAAC,CAAC;AAE5B;;AAEG;AACH,IAAA,QAAQ,CAAU;AAElB;;AAEG;AACH,IAAA,MAAM,CAAkB;AAExB,IAAA,WAAA,CAAY,MAAyB,EAAA;QACjC,IAAI,CAAC,GAAG,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,OAAO,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,QAAQ,GA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AAI,CAAC,GAAG;oBACb,KAAK,EAAE,IAAI,CAAC,IAAI;iBACnB,CAAC;gBACF,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,KAAK,EAAE,IAAI,CAAC,QAAQ;gBACpB,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,IAAI;gBACnC,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,IAAI,EAAE,IAAI,CAAC,IAAI;AAClB,aAAA,CAAC,CACL,CAAC;AACL,SAAA;AAED,QAAA,OAAO,IAAI,CAAC;KACf;AAED;;AAEG;IACH,QAAQ,GAAA;QACJ,OAAO,CAAA,UAAA,EAAa,IAAI,CAAC,QAAQ,UAAU,IAAI,CAAC,GAAG,CAAW,QAAA,EAAA,IAAI,CAAC,IAAI,CAAA,SAAA,EAAY,IAAI,CAAC,KAAK,iBAAiB,IAAI,CAAC,SAAS,CAAA,CAAE,CAAC;KAClI;AACJ;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rian8337/osu-droid-utilities",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
4
|
"description": "A module containing utilities for osu!droid.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"osu",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "git+https://github.com/Rian8337/osu-droid-module.git"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
-
"build": "
|
|
24
|
+
"build": "rollup -c ../../rollup.config.js",
|
|
25
25
|
"lint": "eslint --ext ts",
|
|
26
26
|
"prepare": "npm run build",
|
|
27
27
|
"test": "jest -i"
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"url": "https://github.com/Rian8337/osu-droid-module/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@rian8337/osu-base": "^
|
|
34
|
-
"@rian8337/osu-droid-replay-analyzer": "^
|
|
33
|
+
"@rian8337/osu-base": "^2.0.0-alpha.0",
|
|
34
|
+
"@rian8337/osu-droid-replay-analyzer": "^2.0.0-alpha.0",
|
|
35
35
|
"crypto-js": "^4.1.1"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/crypto-js": "^4.1.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "3e2183f37265200ad7bed4f097bd11b3da8c5909"
|
|
44
44
|
}
|
package/typings/index.d.ts
CHANGED
|
@@ -1,231 +1,211 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
* Retrieves play information.
|
|
146
|
-
*
|
|
147
|
-
* @param params Function parameters.
|
|
148
|
-
*/
|
|
149
|
-
static getFromHash(params: {
|
|
150
|
-
/**
|
|
151
|
-
* The uid of the player.
|
|
152
|
-
*/
|
|
153
|
-
uid: number;
|
|
154
|
-
/**
|
|
155
|
-
* The MD5 hash to retrieve.
|
|
156
|
-
*/
|
|
157
|
-
hash: string;
|
|
158
|
-
}): Promise<Score>;
|
|
159
|
-
/**
|
|
160
|
-
* Fills this instance with score information.
|
|
161
|
-
*
|
|
162
|
-
* @param info The score information from API response to fill with.
|
|
163
|
-
*/
|
|
164
|
-
fillInformation(info: string): Score;
|
|
165
|
-
/**
|
|
166
|
-
* Returns the complete mod string of this score (mods, speed multiplier, and force AR combined).
|
|
167
|
-
*/
|
|
168
|
-
getCompleteModString(): string;
|
|
169
|
-
/**
|
|
170
|
-
* Downloads the replay of this score.
|
|
171
|
-
*/
|
|
172
|
-
downloadReplay(): Promise<void>;
|
|
173
|
-
/**
|
|
174
|
-
* Returns a string representative of the class.
|
|
175
|
-
*/
|
|
176
|
-
toString(): string;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
//#endregion
|
|
180
|
-
|
|
181
|
-
//#region Interfaces
|
|
182
|
-
|
|
183
|
-
export interface ScoreInformation {
|
|
184
|
-
/**
|
|
185
|
-
* The uid of the player.
|
|
186
|
-
*/
|
|
187
|
-
uid?: number;
|
|
188
|
-
/**
|
|
189
|
-
* The ID of the score.
|
|
190
|
-
*/
|
|
191
|
-
scoreID?: number;
|
|
192
|
-
/**
|
|
193
|
-
* The player's name.
|
|
194
|
-
*/
|
|
195
|
-
username: string;
|
|
196
|
-
/**
|
|
197
|
-
* The title of the beatmap.
|
|
198
|
-
*/
|
|
199
|
-
title: string;
|
|
200
|
-
/**
|
|
201
|
-
* The maximum combo achieved in the play.
|
|
202
|
-
*/
|
|
203
|
-
combo: number;
|
|
204
|
-
/**
|
|
205
|
-
* The score achieved in the play.
|
|
206
|
-
*/
|
|
207
|
-
score: number;
|
|
208
|
-
/**
|
|
209
|
-
* The rank achieved in the play.
|
|
210
|
-
*/
|
|
211
|
-
rank: string;
|
|
212
|
-
/**
|
|
213
|
-
* The date of which the play was set.
|
|
214
|
-
*/
|
|
215
|
-
date: Date | number;
|
|
216
|
-
/**
|
|
217
|
-
* The accuracy achieved in the play.
|
|
218
|
-
*/
|
|
219
|
-
accuracy: Accuracy;
|
|
220
|
-
/**
|
|
221
|
-
* Enabled modifications in the play.
|
|
222
|
-
*/
|
|
223
|
-
mods: Mod[];
|
|
224
|
-
/**
|
|
225
|
-
* MD5 hash of the play.
|
|
226
|
-
*/
|
|
227
|
-
hash: string;
|
|
228
|
-
}
|
|
1
|
+
import { Accuracy, Mod } from '@rian8337/osu-base';
|
|
2
|
+
import { ReplayAnalyzer } from '@rian8337/osu-droid-replay-analyzer';
|
|
3
|
+
|
|
4
|
+
interface ScoreInformation {
|
|
5
|
+
/**
|
|
6
|
+
* The uid of the player.
|
|
7
|
+
*/
|
|
8
|
+
uid?: number;
|
|
9
|
+
/**
|
|
10
|
+
* The ID of the score.
|
|
11
|
+
*/
|
|
12
|
+
scoreID?: number;
|
|
13
|
+
/**
|
|
14
|
+
* The player's name.
|
|
15
|
+
*/
|
|
16
|
+
username: string;
|
|
17
|
+
/**
|
|
18
|
+
* The title of the beatmap.
|
|
19
|
+
*/
|
|
20
|
+
title: string;
|
|
21
|
+
/**
|
|
22
|
+
* The maximum combo achieved in the play.
|
|
23
|
+
*/
|
|
24
|
+
combo: number;
|
|
25
|
+
/**
|
|
26
|
+
* The score achieved in the play.
|
|
27
|
+
*/
|
|
28
|
+
score: number;
|
|
29
|
+
/**
|
|
30
|
+
* The rank achieved in the play.
|
|
31
|
+
*/
|
|
32
|
+
rank: string;
|
|
33
|
+
/**
|
|
34
|
+
* The date of which the play was set.
|
|
35
|
+
*/
|
|
36
|
+
date: Date | number;
|
|
37
|
+
/**
|
|
38
|
+
* The accuracy achieved in the play.
|
|
39
|
+
*/
|
|
40
|
+
accuracy: Accuracy;
|
|
41
|
+
/**
|
|
42
|
+
* Enabled modifications in the score, including force AR and custom speed multiplier.
|
|
43
|
+
*/
|
|
44
|
+
mods: string;
|
|
45
|
+
/**
|
|
46
|
+
* MD5 hash of the play.
|
|
47
|
+
*/
|
|
48
|
+
hash: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Represents an osu!droid score.
|
|
52
|
+
*/
|
|
53
|
+
declare class Score {
|
|
54
|
+
/**
|
|
55
|
+
* The uid of the player.
|
|
56
|
+
*/
|
|
57
|
+
uid: number;
|
|
58
|
+
/**
|
|
59
|
+
* The ID of the score.
|
|
60
|
+
*/
|
|
61
|
+
scoreID: number;
|
|
62
|
+
/**
|
|
63
|
+
* The player's name.
|
|
64
|
+
*/
|
|
65
|
+
username: string;
|
|
66
|
+
/**
|
|
67
|
+
* The title of the beatmap.
|
|
68
|
+
*/
|
|
69
|
+
title: string;
|
|
70
|
+
/**
|
|
71
|
+
* The maximum combo achieved in the play.
|
|
72
|
+
*/
|
|
73
|
+
combo: number;
|
|
74
|
+
/**
|
|
75
|
+
* The score achieved in the play.
|
|
76
|
+
*/
|
|
77
|
+
score: number;
|
|
78
|
+
/**
|
|
79
|
+
* The rank achieved in the play.
|
|
80
|
+
*/
|
|
81
|
+
rank: string;
|
|
82
|
+
/**
|
|
83
|
+
* The date of which the play was set.
|
|
84
|
+
*/
|
|
85
|
+
date: Date;
|
|
86
|
+
/**
|
|
87
|
+
* The accuracy achieved in the play.
|
|
88
|
+
*/
|
|
89
|
+
accuracy: Accuracy;
|
|
90
|
+
/**
|
|
91
|
+
* Enabled modifications in the score.
|
|
92
|
+
*/
|
|
93
|
+
mods: Mod[];
|
|
94
|
+
/**
|
|
95
|
+
* MD5 hash of the play.
|
|
96
|
+
*/
|
|
97
|
+
hash: string;
|
|
98
|
+
/**
|
|
99
|
+
* The speed multiplier of the play.
|
|
100
|
+
*/
|
|
101
|
+
speedMultiplier: number;
|
|
102
|
+
/**
|
|
103
|
+
* The forced AR of the play.
|
|
104
|
+
*/
|
|
105
|
+
forcedAR?: number;
|
|
106
|
+
/**
|
|
107
|
+
* The replay of the score.
|
|
108
|
+
*/
|
|
109
|
+
replay?: ReplayAnalyzer;
|
|
110
|
+
constructor(values?: ScoreInformation);
|
|
111
|
+
/**
|
|
112
|
+
* Retrieves play information.
|
|
113
|
+
*
|
|
114
|
+
* @param params Function parameters.
|
|
115
|
+
*/
|
|
116
|
+
static getFromHash(params: {
|
|
117
|
+
/**
|
|
118
|
+
* The uid of the player.
|
|
119
|
+
*/
|
|
120
|
+
uid: number;
|
|
121
|
+
/**
|
|
122
|
+
* The MD5 hash to retrieve.
|
|
123
|
+
*/
|
|
124
|
+
hash: string;
|
|
125
|
+
}): Promise<Score>;
|
|
126
|
+
/**
|
|
127
|
+
* Fills this instance with score information.
|
|
128
|
+
*
|
|
129
|
+
* @param info The score information from API response to fill with.
|
|
130
|
+
*/
|
|
131
|
+
fillInformation(info: string): Score;
|
|
132
|
+
/**
|
|
133
|
+
* Returns the complete mod string of this score (mods, speed multiplier, and force AR combined).
|
|
134
|
+
*/
|
|
135
|
+
getCompleteModString(): string;
|
|
136
|
+
/**
|
|
137
|
+
* Downloads the replay of this score.
|
|
138
|
+
*/
|
|
139
|
+
downloadReplay(): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Returns a string representative of the class.
|
|
142
|
+
*/
|
|
143
|
+
toString(): string;
|
|
144
|
+
}
|
|
229
145
|
|
|
230
|
-
|
|
146
|
+
/**
|
|
147
|
+
* Represents an osu!droid player.
|
|
148
|
+
*/
|
|
149
|
+
declare class Player {
|
|
150
|
+
/**
|
|
151
|
+
* The uid of the player.
|
|
152
|
+
*/
|
|
153
|
+
uid: number;
|
|
154
|
+
/**
|
|
155
|
+
* The username of the player.
|
|
156
|
+
*/
|
|
157
|
+
username: string;
|
|
158
|
+
/**
|
|
159
|
+
* The avatar URL of the player.
|
|
160
|
+
*/
|
|
161
|
+
avatarURL: string;
|
|
162
|
+
/**
|
|
163
|
+
* The location of the player based on ISO 3166-1 country codes. See {@link https://en.wikipedia.org/wiki/ISO_3166-1 this} Wikipedia page for more information.
|
|
164
|
+
*/
|
|
165
|
+
location: string;
|
|
166
|
+
/**
|
|
167
|
+
* The email that is attached to the player's account.
|
|
168
|
+
*/
|
|
169
|
+
email: string;
|
|
170
|
+
/**
|
|
171
|
+
* The overall rank of the player.
|
|
172
|
+
*/
|
|
173
|
+
rank: number;
|
|
174
|
+
/**
|
|
175
|
+
* The total score of the player.
|
|
176
|
+
*/
|
|
177
|
+
score: number;
|
|
178
|
+
/**
|
|
179
|
+
* The overall accuracy of the player.
|
|
180
|
+
*/
|
|
181
|
+
accuracy: number;
|
|
182
|
+
/**
|
|
183
|
+
* The amount of times the player has played.
|
|
184
|
+
*/
|
|
185
|
+
playCount: number;
|
|
186
|
+
/**
|
|
187
|
+
* Recent plays of the player.
|
|
188
|
+
*/
|
|
189
|
+
readonly recentPlays: Score[];
|
|
190
|
+
/**
|
|
191
|
+
* Retrieves a player's info based on uid or username.
|
|
192
|
+
*
|
|
193
|
+
* Either uid or username must be specified.
|
|
194
|
+
*/
|
|
195
|
+
static getInformation(params: {
|
|
196
|
+
uid?: number;
|
|
197
|
+
username?: string;
|
|
198
|
+
}): Promise<Player>;
|
|
199
|
+
/**
|
|
200
|
+
* Fills this instance with player information.
|
|
201
|
+
*
|
|
202
|
+
* @param info The player information from API response to fill with.
|
|
203
|
+
*/
|
|
204
|
+
fillInformation(info: string): Player;
|
|
205
|
+
/**
|
|
206
|
+
* Returns a string representative of the class.
|
|
207
|
+
*/
|
|
208
|
+
toString(): string;
|
|
231
209
|
}
|
|
210
|
+
|
|
211
|
+
export { Player, Score };
|
package/dist/Player.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Player = void 0;
|
|
4
|
-
const osu_base_1 = require("@rian8337/osu-base");
|
|
5
|
-
const Score_1 = require("./Score");
|
|
6
|
-
const crypto_js_1 = require("crypto-js");
|
|
7
|
-
/**
|
|
8
|
-
* Represents an osu!droid player.
|
|
9
|
-
*/
|
|
10
|
-
class Player {
|
|
11
|
-
constructor() {
|
|
12
|
-
/**
|
|
13
|
-
* The uid of the player.
|
|
14
|
-
*/
|
|
15
|
-
this.uid = 0;
|
|
16
|
-
/**
|
|
17
|
-
* The username of the player.
|
|
18
|
-
*/
|
|
19
|
-
this.username = "";
|
|
20
|
-
/**
|
|
21
|
-
* The avatar URL of the player.
|
|
22
|
-
*/
|
|
23
|
-
this.avatarURL = "";
|
|
24
|
-
/**
|
|
25
|
-
* The location of the player based on ISO 3166-1 country codes. See {@link https://en.wikipedia.org/wiki/ISO_3166-1 this} Wikipedia page for more information.
|
|
26
|
-
*/
|
|
27
|
-
this.location = "";
|
|
28
|
-
/**
|
|
29
|
-
* The email that is attached to the player's account.
|
|
30
|
-
*/
|
|
31
|
-
this.email = "";
|
|
32
|
-
/**
|
|
33
|
-
* The overall rank of the player.
|
|
34
|
-
*/
|
|
35
|
-
this.rank = 0;
|
|
36
|
-
/**
|
|
37
|
-
* The total score of the player.
|
|
38
|
-
*/
|
|
39
|
-
this.score = 0;
|
|
40
|
-
/**
|
|
41
|
-
* The overall accuracy of the player.
|
|
42
|
-
*/
|
|
43
|
-
this.accuracy = 0;
|
|
44
|
-
/**
|
|
45
|
-
* The amount of times the player has played.
|
|
46
|
-
*/
|
|
47
|
-
this.playCount = 0;
|
|
48
|
-
/**
|
|
49
|
-
* Recent plays of the player.
|
|
50
|
-
*/
|
|
51
|
-
this.recentPlays = [];
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Retrieves a player's info based on uid or username.
|
|
55
|
-
*
|
|
56
|
-
* Either uid or username must be specified.
|
|
57
|
-
*/
|
|
58
|
-
static async getInformation(params) {
|
|
59
|
-
const player = new Player();
|
|
60
|
-
const uid = params.uid;
|
|
61
|
-
const username = params.username;
|
|
62
|
-
if (!uid && !username) {
|
|
63
|
-
throw new Error("Uid must be integer or enter username");
|
|
64
|
-
}
|
|
65
|
-
const apiRequestBuilder = new osu_base_1.DroidAPIRequestBuilder().setEndpoint("getuserinfo.php");
|
|
66
|
-
if (uid) {
|
|
67
|
-
apiRequestBuilder.addParameter("uid", uid);
|
|
68
|
-
}
|
|
69
|
-
else if (username) {
|
|
70
|
-
apiRequestBuilder.addParameter("username", username);
|
|
71
|
-
}
|
|
72
|
-
const result = await apiRequestBuilder.sendRequest();
|
|
73
|
-
if (result.statusCode !== 200) {
|
|
74
|
-
throw new Error("Error retrieving player data");
|
|
75
|
-
}
|
|
76
|
-
const data = result.data.toString("utf-8");
|
|
77
|
-
const resArr = data.split("<br>");
|
|
78
|
-
const headerRes = resArr[0].split(" ");
|
|
79
|
-
if (headerRes[0] === "FAILED") {
|
|
80
|
-
return player;
|
|
81
|
-
}
|
|
82
|
-
player.fillInformation(data);
|
|
83
|
-
return player;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Fills this instance with player information.
|
|
87
|
-
*
|
|
88
|
-
* @param info The player information from API response to fill with.
|
|
89
|
-
*/
|
|
90
|
-
fillInformation(info) {
|
|
91
|
-
const resArr = info.split("<br>");
|
|
92
|
-
const headerRes = resArr[0].split(" ");
|
|
93
|
-
if (headerRes[0] === "FAILED") {
|
|
94
|
-
return this;
|
|
95
|
-
}
|
|
96
|
-
const obj = JSON.parse(resArr[1]);
|
|
97
|
-
this.uid = parseInt(headerRes[1]);
|
|
98
|
-
this.username = headerRes[2];
|
|
99
|
-
this.score = parseInt(headerRes[3]);
|
|
100
|
-
this.playCount = parseInt(headerRes[4]);
|
|
101
|
-
this.accuracy = parseFloat((parseFloat(headerRes[5]) * 100).toFixed(2));
|
|
102
|
-
this.email = headerRes[6];
|
|
103
|
-
this.location = headerRes[7];
|
|
104
|
-
this.avatarURL = `https://osudroid.moe/user/avatar?id=${(0, crypto_js_1.MD5)(this.email.trim().toLowerCase()).toString()}&s=200`;
|
|
105
|
-
this.rank = obj.rank;
|
|
106
|
-
const recent = obj.recent;
|
|
107
|
-
for (const play of recent) {
|
|
108
|
-
this.recentPlays.push(new Score_1.Score({
|
|
109
|
-
uid: this.uid,
|
|
110
|
-
username: this.username,
|
|
111
|
-
scoreID: play.scoreid,
|
|
112
|
-
score: play.score,
|
|
113
|
-
accuracy: new osu_base_1.Accuracy({
|
|
114
|
-
n300: play.perfect,
|
|
115
|
-
n100: play.good,
|
|
116
|
-
n50: play.bad,
|
|
117
|
-
nmiss: play.miss,
|
|
118
|
-
}),
|
|
119
|
-
rank: play.mark,
|
|
120
|
-
combo: play.combo,
|
|
121
|
-
title: play.filename,
|
|
122
|
-
date: (play.date + 3600 * 6) * 1000,
|
|
123
|
-
mods: play.mode,
|
|
124
|
-
hash: play.hash,
|
|
125
|
-
}));
|
|
126
|
-
}
|
|
127
|
-
return this;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Returns a string representative of the class.
|
|
131
|
-
*/
|
|
132
|
-
toString() {
|
|
133
|
-
return `Username: ${this.username}\nUID: ${this.uid}\nRank: ${this.rank}\nScore: ${this.score}\nPlay count: ${this.playCount}`;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
exports.Player = Player;
|
|
137
|
-
//# sourceMappingURL=Player.js.map
|
package/dist/Player.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Player.js","sourceRoot":"","sources":["../src/Player.ts"],"names":[],"mappings":";;;AAAA,iDAI4B;AAC5B,mCAAgC;AAChC,yCAAgC;AAqBhC;;GAEG;AACH,MAAa,MAAM;IAAnB;QACI;;WAEG;QACH,QAAG,GAAW,CAAC,CAAC;QAEhB;;WAEG;QACH,aAAQ,GAAW,EAAE,CAAC;QAEtB;;WAEG;QACH,cAAS,GAAW,EAAE,CAAC;QAEvB;;WAEG;QACH,aAAQ,GAAW,EAAE,CAAC;QAEtB;;WAEG;QACH,UAAK,GAAW,EAAE,CAAC;QAEnB;;WAEG;QACH,SAAI,GAAW,CAAC,CAAC;QAEjB;;WAEG;QACH,UAAK,GAAW,CAAC,CAAC;QAElB;;WAEG;QACH,aAAQ,GAAW,CAAC,CAAC;QAErB;;WAEG;QACH,cAAS,GAAW,CAAC,CAAC;QAEtB;;WAEG;QACM,gBAAW,GAAY,EAAE,CAAC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AAC;gBACN,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,QAAQ,EAAE,IAAI,mBAAQ,CAAC;oBACnB,IAAI,EAAE,IAAI,CAAC,OAAO;oBAClB,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,GAAG,EAAE,IAAI,CAAC,GAAG;oBACb,KAAK,EAAE,IAAI,CAAC,IAAI;iBACnB,CAAC;gBACF,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,KAAK,EAAE,IAAI,CAAC,QAAQ;gBACpB,IAAI,EAAE,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI;gBACnC,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,IAAI,EAAE,IAAI,CAAC,IAAI;aAClB,CAAC,CACL,CAAC;SACL;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,QAAQ;QACJ,OAAO,aAAa,IAAI,CAAC,QAAQ,UAAU,IAAI,CAAC,GAAG,WAAW,IAAI,CAAC,IAAI,YAAY,IAAI,CAAC,KAAK,iBAAiB,IAAI,CAAC,SAAS,EAAE,CAAC;IACnI,CAAC;CACJ;AA1JD,wBA0JC"}
|
package/dist/Score.js
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Score = void 0;
|
|
4
|
-
const osu_base_1 = require("@rian8337/osu-base");
|
|
5
|
-
const osu_droid_replay_analyzer_1 = require("@rian8337/osu-droid-replay-analyzer");
|
|
6
|
-
/**
|
|
7
|
-
* Represents an osu!droid score.
|
|
8
|
-
*/
|
|
9
|
-
class Score {
|
|
10
|
-
constructor(values) {
|
|
11
|
-
/**
|
|
12
|
-
* The speed multiplier of the play.
|
|
13
|
-
*/
|
|
14
|
-
this.speedMultiplier = 1;
|
|
15
|
-
this.uid = values?.uid ?? 0;
|
|
16
|
-
this.scoreID = values?.scoreID ?? 0;
|
|
17
|
-
this.username = values?.username ?? "";
|
|
18
|
-
this.title = values?.title ?? "";
|
|
19
|
-
this.combo = values?.combo ?? 0;
|
|
20
|
-
this.score = values?.score ?? 0;
|
|
21
|
-
this.rank = values?.rank ?? "";
|
|
22
|
-
this.date = new Date(values?.date ?? 0);
|
|
23
|
-
this.accuracy = values?.accuracy ?? new osu_base_1.Accuracy({});
|
|
24
|
-
this.hash = values?.hash ?? "";
|
|
25
|
-
const modstrings = (values?.mods ?? "").split("|");
|
|
26
|
-
let actualMods = "";
|
|
27
|
-
for (let i = 0; i < modstrings.length; ++i) {
|
|
28
|
-
if (!modstrings[i]) {
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
if (modstrings[i].startsWith("AR")) {
|
|
32
|
-
this.forcedAR = parseFloat(modstrings[i].replace("AR", ""));
|
|
33
|
-
}
|
|
34
|
-
else if (modstrings[i].startsWith("x")) {
|
|
35
|
-
this.speedMultiplier = parseFloat(modstrings[i].replace("x", ""));
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
actualMods += modstrings[i];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
this.mods = osu_base_1.ModUtil.droidStringToMods(actualMods);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Retrieves play information.
|
|
45
|
-
*
|
|
46
|
-
* @param params Function parameters.
|
|
47
|
-
*/
|
|
48
|
-
static async getFromHash(params) {
|
|
49
|
-
const score = new Score();
|
|
50
|
-
const uid = (score.uid = params.uid);
|
|
51
|
-
const hash = (score.hash = params.hash);
|
|
52
|
-
if (!uid || !hash) {
|
|
53
|
-
throw new Error("Uid and hash must be specified");
|
|
54
|
-
}
|
|
55
|
-
const apiRequestBuilder = new osu_base_1.DroidAPIRequestBuilder()
|
|
56
|
-
.setEndpoint("scoresearchv2.php")
|
|
57
|
-
.addParameter("uid", uid)
|
|
58
|
-
.addParameter("hash", hash);
|
|
59
|
-
const result = await apiRequestBuilder.sendRequest();
|
|
60
|
-
if (result.statusCode !== 200) {
|
|
61
|
-
throw new Error("Error retrieving score data");
|
|
62
|
-
}
|
|
63
|
-
const entry = result.data.toString("utf-8").split("<br>");
|
|
64
|
-
entry.shift();
|
|
65
|
-
if (entry.length === 0) {
|
|
66
|
-
return score;
|
|
67
|
-
}
|
|
68
|
-
score.fillInformation(entry[0]);
|
|
69
|
-
return score;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Fills this instance with score information.
|
|
73
|
-
*
|
|
74
|
-
* @param info The score information from API response to fill with.
|
|
75
|
-
*/
|
|
76
|
-
fillInformation(info) {
|
|
77
|
-
const play = info.split(" ");
|
|
78
|
-
this.scoreID = parseInt(play[0]);
|
|
79
|
-
this.uid = parseInt(play[1]);
|
|
80
|
-
this.username = play[2];
|
|
81
|
-
this.score = parseInt(play[3]);
|
|
82
|
-
this.combo = parseInt(play[4]);
|
|
83
|
-
this.rank = play[5];
|
|
84
|
-
const modstrings = play[6].split("|");
|
|
85
|
-
let actualMods = "";
|
|
86
|
-
for (let i = 0; i < modstrings.length; ++i) {
|
|
87
|
-
if (!modstrings[i]) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (modstrings[i].startsWith("AR")) {
|
|
91
|
-
this.forcedAR = parseFloat(modstrings[i].replace("AR", ""));
|
|
92
|
-
}
|
|
93
|
-
else if (modstrings[i].startsWith("x")) {
|
|
94
|
-
this.speedMultiplier = parseFloat(modstrings[i].replace("x", ""));
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
actualMods += modstrings[i];
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
this.mods = osu_base_1.ModUtil.droidStringToMods(actualMods);
|
|
101
|
-
this.accuracy = new osu_base_1.Accuracy({
|
|
102
|
-
n300: parseInt(play[8]),
|
|
103
|
-
n100: parseInt(play[9]),
|
|
104
|
-
n50: parseInt(play[10]),
|
|
105
|
-
nmiss: parseInt(play[11]),
|
|
106
|
-
});
|
|
107
|
-
const date = new Date(parseInt(play[12]) * 1000);
|
|
108
|
-
date.setUTCHours(date.getUTCHours() + 6);
|
|
109
|
-
this.date = date;
|
|
110
|
-
this.title = play[13]
|
|
111
|
-
.substring(0, play[13].length - 4)
|
|
112
|
-
.replace(/_/g, " ");
|
|
113
|
-
this.hash = play[14];
|
|
114
|
-
return this;
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Returns the complete mod string of this score (mods, speed multiplier, and force AR combined).
|
|
118
|
-
*/
|
|
119
|
-
getCompleteModString() {
|
|
120
|
-
let finalString = `+${this.mods.length > 0 ? this.mods.map((v) => v.acronym) : "No Mod"}`;
|
|
121
|
-
if (this.forcedAR !== undefined || this.speedMultiplier !== 1) {
|
|
122
|
-
finalString += " (";
|
|
123
|
-
if (this.forcedAR !== undefined) {
|
|
124
|
-
finalString += `AR${this.forcedAR}`;
|
|
125
|
-
}
|
|
126
|
-
if (this.speedMultiplier !== 1) {
|
|
127
|
-
if (this.forcedAR !== undefined) {
|
|
128
|
-
finalString += ", ";
|
|
129
|
-
}
|
|
130
|
-
finalString += `${this.speedMultiplier}x`;
|
|
131
|
-
}
|
|
132
|
-
finalString += ")";
|
|
133
|
-
}
|
|
134
|
-
return finalString;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Downloads the replay of this score.
|
|
138
|
-
*/
|
|
139
|
-
async downloadReplay() {
|
|
140
|
-
if (!this.scoreID || this.replay) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
this.replay = await new osu_droid_replay_analyzer_1.ReplayAnalyzer({
|
|
144
|
-
scoreID: this.scoreID,
|
|
145
|
-
}).analyze();
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Returns a string representative of the class.
|
|
149
|
-
*/
|
|
150
|
-
toString() {
|
|
151
|
-
return `Player: ${this.username}, uid: ${this.uid}, title: ${this.title}, score: ${this.score}, combo: ${this.combo}, rank: ${this.rank}, acc: ${this.accuracy}%, date: ${this.date}, mods: ${this.mods}, hash: ${this.hash}`;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
exports.Score = Score;
|
|
155
|
-
//# sourceMappingURL=Score.js.map
|
package/dist/Score.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Score.js","sourceRoot":"","sources":["../src/Score.ts"],"names":[],"mappings":";;;AAAA,iDAM4B;AAC5B,mFAAqE;AA2DrE;;GAEG;AACH,MAAa,KAAK;IAuEd,YAAY,MAAyB;QAfrC;;WAEG;QACH,oBAAe,GAAW,CAAC,CAAC;QAaxB,IAAI,CAAC,GAAG,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,EAAE,OAAO,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,QAAQ,GAAG,MAAM,EAAE,QAAQ,IAAI,EAAE,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,MAAM,EAAE,QAAQ,IAAI,IAAI,mBAAQ,CAAC,EAAE,CAAC,CAAC;QACrD,IAAI,CAAC,IAAI,GAAG,MAAM,EAAE,IAAI,IAAI,EAAE,CAA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