@rian8337/osu-droid-utilities 4.0.0-beta.103 → 4.0.0-beta.104
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.cjs +299 -0
- package/dist/index.d.cts +255 -0
- package/dist/index.d.mts +255 -0
- package/dist/index.mjs +296 -0
- package/package.json +28 -12
- package/dist/index.js +0 -237
- package/typings/index.d.ts +0 -210
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _rian8337_osu_base = require("@rian8337/osu-base");
|
|
3
|
+
// src/Score.ts
|
|
4
|
+
/**
|
|
5
|
+
* Represents an osu!droid score.
|
|
6
|
+
*/
|
|
7
|
+
var Score = class Score {
|
|
8
|
+
/**
|
|
9
|
+
* The ID of the score.
|
|
10
|
+
*/
|
|
11
|
+
id;
|
|
12
|
+
/**
|
|
13
|
+
* The uid of the player.
|
|
14
|
+
*/
|
|
15
|
+
uid;
|
|
16
|
+
/**
|
|
17
|
+
* The player's name.
|
|
18
|
+
*/
|
|
19
|
+
username;
|
|
20
|
+
/**
|
|
21
|
+
* The title of the beatmap.
|
|
22
|
+
*/
|
|
23
|
+
title;
|
|
24
|
+
/**
|
|
25
|
+
* The maximum combo achieved in the play.
|
|
26
|
+
*/
|
|
27
|
+
combo;
|
|
28
|
+
/**
|
|
29
|
+
* The score achieved in the play.
|
|
30
|
+
*/
|
|
31
|
+
score;
|
|
32
|
+
/**
|
|
33
|
+
* The rank achieved in the play.
|
|
34
|
+
*/
|
|
35
|
+
rank;
|
|
36
|
+
/**
|
|
37
|
+
* The date of which the play was set.
|
|
38
|
+
*/
|
|
39
|
+
date;
|
|
40
|
+
/**
|
|
41
|
+
* The accuracy achieved in the play.
|
|
42
|
+
*/
|
|
43
|
+
accuracy;
|
|
44
|
+
/**
|
|
45
|
+
* The amount of 300s in the play.
|
|
46
|
+
*/
|
|
47
|
+
get perfect() {
|
|
48
|
+
return this.accuracy.n300;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The amount of 100s in the play.
|
|
52
|
+
*/
|
|
53
|
+
get good() {
|
|
54
|
+
return this.accuracy.n100;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The amount of 50s in the play.
|
|
58
|
+
*/
|
|
59
|
+
get bad() {
|
|
60
|
+
return this.accuracy.n50;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The amount of misses in the play.
|
|
64
|
+
*/
|
|
65
|
+
get miss() {
|
|
66
|
+
return this.accuracy.nmiss;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Enabled modifications in the score.
|
|
70
|
+
*/
|
|
71
|
+
mods;
|
|
72
|
+
/**
|
|
73
|
+
* MD5 hash of the play.
|
|
74
|
+
*/
|
|
75
|
+
hash;
|
|
76
|
+
/**
|
|
77
|
+
* The amount of slider heads hit in the play.
|
|
78
|
+
*/
|
|
79
|
+
sliderHeadHits;
|
|
80
|
+
/**
|
|
81
|
+
* The amount of slider ticks hit in the play.
|
|
82
|
+
*/
|
|
83
|
+
sliderTickHits;
|
|
84
|
+
/**
|
|
85
|
+
* The amount of slider repeats hit in the play.
|
|
86
|
+
*/
|
|
87
|
+
sliderRepeatHits;
|
|
88
|
+
/**
|
|
89
|
+
* The amount of slider ends hit in the play.
|
|
90
|
+
*/
|
|
91
|
+
sliderEndHits;
|
|
92
|
+
/**
|
|
93
|
+
* The performance points value of the play.
|
|
94
|
+
*
|
|
95
|
+
* This is the final value, affected by {@link ppMultiplier}. To get the raw pp value, divide by said multiplier.
|
|
96
|
+
*/
|
|
97
|
+
pp;
|
|
98
|
+
/**
|
|
99
|
+
* The pp multiplier of the play.
|
|
100
|
+
*
|
|
101
|
+
* This is applied directly to {@link pp} during calculation.
|
|
102
|
+
*/
|
|
103
|
+
ppMultiplier;
|
|
104
|
+
/**
|
|
105
|
+
* The complete mod string of this score.
|
|
106
|
+
*/
|
|
107
|
+
get completeModString() {
|
|
108
|
+
if (this.mods.isEmpty) return `+No Mod`;
|
|
109
|
+
return `+${_rian8337_osu_base.ModUtil.modsToOrderedString(this.mods)}`;
|
|
110
|
+
}
|
|
111
|
+
constructor(apiScore) {
|
|
112
|
+
this.id = apiScore.id;
|
|
113
|
+
this.uid = apiScore.uid;
|
|
114
|
+
this.username = apiScore.username;
|
|
115
|
+
this.title = apiScore.filename;
|
|
116
|
+
this.combo = apiScore.combo;
|
|
117
|
+
this.score = apiScore.score;
|
|
118
|
+
this.rank = apiScore.mark;
|
|
119
|
+
this.date = /* @__PURE__ */ new Date(apiScore.date * 1e3);
|
|
120
|
+
this.mods = _rian8337_osu_base.ModUtil.deserializeMods(apiScore.mods);
|
|
121
|
+
this.accuracy = new _rian8337_osu_base.Accuracy({
|
|
122
|
+
n300: apiScore.perfect,
|
|
123
|
+
n100: apiScore.good,
|
|
124
|
+
n50: apiScore.bad,
|
|
125
|
+
nmiss: apiScore.miss
|
|
126
|
+
});
|
|
127
|
+
this.sliderHeadHits = apiScore.sliderHeadHit;
|
|
128
|
+
this.sliderTickHits = apiScore.sliderTickHit;
|
|
129
|
+
this.sliderRepeatHits = apiScore.sliderRepeatHit;
|
|
130
|
+
this.sliderEndHits = apiScore.sliderEndHit;
|
|
131
|
+
this.hash = apiScore.hash;
|
|
132
|
+
this.pp = apiScore.pp;
|
|
133
|
+
this.ppMultiplier = apiScore.ppMultiplier;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Retrieves score information on a beatmap from a player.
|
|
137
|
+
*
|
|
138
|
+
* @param uid The uid of the player.
|
|
139
|
+
* @param hash The MD5 hash of the beatmap.
|
|
140
|
+
* @param fetchBestPP Whether to retrieve the score in terms of the best performance points rather than best score. Defaults to `false`.
|
|
141
|
+
* @returns The score, `null` if the score is not found.
|
|
142
|
+
*/
|
|
143
|
+
static async getFromHash(uid, hash, fetchBestPP = false) {
|
|
144
|
+
const apiRequestBuilder = new _rian8337_osu_base.DroidAPIRequestBuilder().setEndpoint("scoresearchv2.php").addParameter("uid", uid).addParameter("hash", hash);
|
|
145
|
+
if (fetchBestPP) apiRequestBuilder.addParameter("order", "pp");
|
|
146
|
+
const result = await apiRequestBuilder.sendRequest();
|
|
147
|
+
if (result.statusCode !== 200) throw new Error(`Error retrieving score data: ${result.describeFailure()}`);
|
|
148
|
+
let response;
|
|
149
|
+
try {
|
|
150
|
+
response = JSON.parse(result.data.toString("utf-8"));
|
|
151
|
+
} catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
if (response.length === 0) return null;
|
|
155
|
+
return new Score(response[0]);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Returns a string representative of the class.
|
|
159
|
+
*/
|
|
160
|
+
toString() {
|
|
161
|
+
return `Player: ${this.username}, uid: ${this.uid.toString()}, title: ${this.title}, score: ${this.score.toString()}, combo: ${this.combo.toString()}, rank: ${this.rank}, acc: ${(this.accuracy.value * 100).toFixed(2)}%, date: ${this.date.toString()}, mods: ${_rian8337_osu_base.ModUtil.modsToOrderedString(this.mods)}, hash: ${this.hash}`;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
// src/Player.ts
|
|
165
|
+
/**
|
|
166
|
+
* Represents an osu!droid player.
|
|
167
|
+
*/
|
|
168
|
+
var Player = class Player {
|
|
169
|
+
/**
|
|
170
|
+
* The user ID of the player.
|
|
171
|
+
*/
|
|
172
|
+
id = 0;
|
|
173
|
+
/**
|
|
174
|
+
* The username of the player.
|
|
175
|
+
*/
|
|
176
|
+
username = "";
|
|
177
|
+
/**
|
|
178
|
+
* The avatar URL of the player.
|
|
179
|
+
*/
|
|
180
|
+
get avatarUrl() {
|
|
181
|
+
return `https://osudroid.moe/user/avatar?id=${this.id.toString()}`;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* 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.
|
|
185
|
+
*/
|
|
186
|
+
location = "";
|
|
187
|
+
/**
|
|
188
|
+
* The overall rank of the player.
|
|
189
|
+
*/
|
|
190
|
+
rank = 0;
|
|
191
|
+
/**
|
|
192
|
+
* The total score of the player.
|
|
193
|
+
*/
|
|
194
|
+
score = 0;
|
|
195
|
+
/**
|
|
196
|
+
* The total performance points of the player.
|
|
197
|
+
*/
|
|
198
|
+
pp = 0;
|
|
199
|
+
/**
|
|
200
|
+
* The overall accuracy of the player.
|
|
201
|
+
*/
|
|
202
|
+
accuracy = 0;
|
|
203
|
+
/**
|
|
204
|
+
* The amount of times the player has played.
|
|
205
|
+
*/
|
|
206
|
+
playCount = 0;
|
|
207
|
+
/**
|
|
208
|
+
* Recent plays of the player.
|
|
209
|
+
*/
|
|
210
|
+
recentPlays = [];
|
|
211
|
+
constructor(apiPlayer) {
|
|
212
|
+
this.id = apiPlayer.id;
|
|
213
|
+
this.username = apiPlayer.username;
|
|
214
|
+
this.score = apiPlayer.score;
|
|
215
|
+
this.playCount = apiPlayer.playcount;
|
|
216
|
+
this.accuracy = apiPlayer.accuracy * 100;
|
|
217
|
+
this.location = apiPlayer.region;
|
|
218
|
+
this.rank = apiPlayer.rank;
|
|
219
|
+
this.pp = apiPlayer.pp;
|
|
220
|
+
for (const score of apiPlayer.recent) this.recentPlays.push(new Score({
|
|
221
|
+
...score,
|
|
222
|
+
uid: this.id,
|
|
223
|
+
username: this.username
|
|
224
|
+
}));
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Retrieves a player's info based on their username.
|
|
228
|
+
*
|
|
229
|
+
* @param uidOrUsername The uid or username of the player.
|
|
230
|
+
* @returns The player, `null` if the player is not found.
|
|
231
|
+
*/
|
|
232
|
+
static async getInformation(uidOrUsername) {
|
|
233
|
+
const result = await new _rian8337_osu_base.DroidAPIRequestBuilder().setEndpoint("getuserinfo.php").addParameter(typeof uidOrUsername === "number" ? "uid" : "username", uidOrUsername).sendRequest();
|
|
234
|
+
if (result.statusCode !== 200) throw new Error(`Error retrieving player data: ${result.describeFailure()}`);
|
|
235
|
+
let response;
|
|
236
|
+
try {
|
|
237
|
+
response = JSON.parse(result.data.toString("utf-8"));
|
|
238
|
+
} catch {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
if (!response.id) return null;
|
|
242
|
+
return new Player(response);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Returns a string representative of the class.
|
|
246
|
+
*/
|
|
247
|
+
toString() {
|
|
248
|
+
return `Username: ${this.username}\nUID: ${this.id.toString()}\nRank: ${this.rank.toString()}\nScore: ${this.score.toString()}\nPlay count: ${this.playCount.toString()}`;
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
// src/PlayerTotalsCalculator.ts
|
|
252
|
+
/**
|
|
253
|
+
* Calculates a player's total performance points and overall accuracy from their best scores.
|
|
254
|
+
*
|
|
255
|
+
* Only the {@link PlayerTotalsCalculator.countedScores} best scores by performance points count. The score at
|
|
256
|
+
* position `i` (from 0) is weighted by `0.95^i`.
|
|
257
|
+
*/
|
|
258
|
+
var PlayerTotalsCalculator = class {
|
|
259
|
+
/**
|
|
260
|
+
* The amount of best scores that count toward a player's totals.
|
|
261
|
+
*/
|
|
262
|
+
static countedScores = 100;
|
|
263
|
+
/**
|
|
264
|
+
* Gets the weight of a score at a position among a player's best scores.
|
|
265
|
+
*
|
|
266
|
+
* @param index The position of the score, from 0, when sorted by performance points in descending order.
|
|
267
|
+
* @returns The weight of the score, or 0 if the score does not count.
|
|
268
|
+
*/
|
|
269
|
+
static getWeight(index) {
|
|
270
|
+
return index < this.countedScores ? .95 ** index : 0;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Calculates a player's totals from their scores.
|
|
274
|
+
*
|
|
275
|
+
* @param scores The player's scores, in any order. Scores with equal performance points keep their given order.
|
|
276
|
+
* @returns The player's totals. The accuracy is 1 when there are no scores.
|
|
277
|
+
*/
|
|
278
|
+
static calculate(scores) {
|
|
279
|
+
const best = [...scores].sort((a, b) => b.pp - a.pp).slice(0, this.countedScores);
|
|
280
|
+
let pp = 0;
|
|
281
|
+
let accuracy = 0;
|
|
282
|
+
let weight = 0;
|
|
283
|
+
for (const [i, score] of best.entries()) {
|
|
284
|
+
const scoreWeight = this.getWeight(i);
|
|
285
|
+
pp += score.pp * scoreWeight;
|
|
286
|
+
accuracy += score.accuracy * scoreWeight;
|
|
287
|
+
weight += scoreWeight;
|
|
288
|
+
}
|
|
289
|
+
return {
|
|
290
|
+
pp,
|
|
291
|
+
accuracy: weight > 0 ? accuracy / weight : 1
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
exports.Player = Player;
|
|
296
|
+
exports.PlayerTotalsCalculator = PlayerTotalsCalculator;
|
|
297
|
+
exports.Score = Score;
|
|
298
|
+
|
|
299
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { Accuracy, ModMap, ScoreRank, SerializedMod } from "@rian8337/osu-base";
|
|
2
|
+
export interface APIScore {
|
|
3
|
+
readonly id: number;
|
|
4
|
+
readonly uid: number;
|
|
5
|
+
readonly username: string;
|
|
6
|
+
readonly filename: string;
|
|
7
|
+
readonly score: number;
|
|
8
|
+
readonly combo: number;
|
|
9
|
+
readonly mark: ScoreRank;
|
|
10
|
+
readonly mods: SerializedMod[];
|
|
11
|
+
readonly accuracy: number;
|
|
12
|
+
readonly perfect: number;
|
|
13
|
+
readonly good: number;
|
|
14
|
+
readonly bad: number;
|
|
15
|
+
readonly miss: number;
|
|
16
|
+
readonly sliderHeadHit: number | null;
|
|
17
|
+
readonly sliderTickHit: number | null;
|
|
18
|
+
readonly sliderRepeatHit: number | null;
|
|
19
|
+
readonly sliderEndHit: number | null;
|
|
20
|
+
readonly date: number;
|
|
21
|
+
readonly hash: string;
|
|
22
|
+
readonly pp: number | null;
|
|
23
|
+
readonly ppMultiplier: number | null;
|
|
24
|
+
}
|
|
25
|
+
export interface APIPlayer {
|
|
26
|
+
readonly id: number;
|
|
27
|
+
readonly username: string;
|
|
28
|
+
readonly score: number;
|
|
29
|
+
readonly playcount: number;
|
|
30
|
+
readonly accuracy: number;
|
|
31
|
+
readonly region: string;
|
|
32
|
+
readonly rank: number;
|
|
33
|
+
readonly pp: number;
|
|
34
|
+
readonly recent: Omit<APIScore, "uid" | "username">[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Represents an osu!droid score.
|
|
38
|
+
*/
|
|
39
|
+
export declare class Score {
|
|
40
|
+
/**
|
|
41
|
+
* The ID of the score.
|
|
42
|
+
*/
|
|
43
|
+
id: number;
|
|
44
|
+
/**
|
|
45
|
+
* The uid of the player.
|
|
46
|
+
*/
|
|
47
|
+
uid: number;
|
|
48
|
+
/**
|
|
49
|
+
* The player's name.
|
|
50
|
+
*/
|
|
51
|
+
username: string;
|
|
52
|
+
/**
|
|
53
|
+
* The title of the beatmap.
|
|
54
|
+
*/
|
|
55
|
+
title: string;
|
|
56
|
+
/**
|
|
57
|
+
* The maximum combo achieved in the play.
|
|
58
|
+
*/
|
|
59
|
+
combo: number;
|
|
60
|
+
/**
|
|
61
|
+
* The score achieved in the play.
|
|
62
|
+
*/
|
|
63
|
+
score: number;
|
|
64
|
+
/**
|
|
65
|
+
* The rank achieved in the play.
|
|
66
|
+
*/
|
|
67
|
+
rank: ScoreRank;
|
|
68
|
+
/**
|
|
69
|
+
* The date of which the play was set.
|
|
70
|
+
*/
|
|
71
|
+
date: Date;
|
|
72
|
+
/**
|
|
73
|
+
* The accuracy achieved in the play.
|
|
74
|
+
*/
|
|
75
|
+
accuracy: Accuracy;
|
|
76
|
+
/**
|
|
77
|
+
* The amount of 300s in the play.
|
|
78
|
+
*/
|
|
79
|
+
get perfect(): number;
|
|
80
|
+
/**
|
|
81
|
+
* The amount of 100s in the play.
|
|
82
|
+
*/
|
|
83
|
+
get good(): number;
|
|
84
|
+
/**
|
|
85
|
+
* The amount of 50s in the play.
|
|
86
|
+
*/
|
|
87
|
+
get bad(): number;
|
|
88
|
+
/**
|
|
89
|
+
* The amount of misses in the play.
|
|
90
|
+
*/
|
|
91
|
+
get miss(): number;
|
|
92
|
+
/**
|
|
93
|
+
* Enabled modifications in the score.
|
|
94
|
+
*/
|
|
95
|
+
mods: ModMap;
|
|
96
|
+
/**
|
|
97
|
+
* MD5 hash of the play.
|
|
98
|
+
*/
|
|
99
|
+
hash: string;
|
|
100
|
+
/**
|
|
101
|
+
* The amount of slider heads hit in the play.
|
|
102
|
+
*/
|
|
103
|
+
sliderHeadHits: number | null;
|
|
104
|
+
/**
|
|
105
|
+
* The amount of slider ticks hit in the play.
|
|
106
|
+
*/
|
|
107
|
+
sliderTickHits: number | null;
|
|
108
|
+
/**
|
|
109
|
+
* The amount of slider repeats hit in the play.
|
|
110
|
+
*/
|
|
111
|
+
sliderRepeatHits: number | null;
|
|
112
|
+
/**
|
|
113
|
+
* The amount of slider ends hit in the play.
|
|
114
|
+
*/
|
|
115
|
+
sliderEndHits: number | null;
|
|
116
|
+
/**
|
|
117
|
+
* The performance points value of the play.
|
|
118
|
+
*
|
|
119
|
+
* This is the final value, affected by {@link ppMultiplier}. To get the raw pp value, divide by said multiplier.
|
|
120
|
+
*/
|
|
121
|
+
pp: number | null;
|
|
122
|
+
/**
|
|
123
|
+
* The pp multiplier of the play.
|
|
124
|
+
*
|
|
125
|
+
* This is applied directly to {@link pp} during calculation.
|
|
126
|
+
*/
|
|
127
|
+
ppMultiplier: number | null;
|
|
128
|
+
/**
|
|
129
|
+
* The complete mod string of this score.
|
|
130
|
+
*/
|
|
131
|
+
get completeModString(): string;
|
|
132
|
+
constructor(apiScore: APIScore);
|
|
133
|
+
/**
|
|
134
|
+
* Retrieves score information on a beatmap from a player.
|
|
135
|
+
*
|
|
136
|
+
* @param uid The uid of the player.
|
|
137
|
+
* @param hash The MD5 hash of the beatmap.
|
|
138
|
+
* @param fetchBestPP Whether to retrieve the score in terms of the best performance points rather than best score. Defaults to `false`.
|
|
139
|
+
* @returns The score, `null` if the score is not found.
|
|
140
|
+
*/
|
|
141
|
+
static getFromHash(uid: number, hash: string, fetchBestPP?: boolean): Promise<Score | null>;
|
|
142
|
+
/**
|
|
143
|
+
* Returns a string representative of the class.
|
|
144
|
+
*/
|
|
145
|
+
toString(): string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Represents an osu!droid player.
|
|
149
|
+
*/
|
|
150
|
+
export declare class Player {
|
|
151
|
+
/**
|
|
152
|
+
* The user ID of the player.
|
|
153
|
+
*/
|
|
154
|
+
id: number;
|
|
155
|
+
/**
|
|
156
|
+
* The username of the player.
|
|
157
|
+
*/
|
|
158
|
+
username: string;
|
|
159
|
+
/**
|
|
160
|
+
* The avatar URL of the player.
|
|
161
|
+
*/
|
|
162
|
+
get avatarUrl(): string;
|
|
163
|
+
/**
|
|
164
|
+
* 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.
|
|
165
|
+
*/
|
|
166
|
+
location: string;
|
|
167
|
+
/**
|
|
168
|
+
* The overall rank of the player.
|
|
169
|
+
*/
|
|
170
|
+
rank: number;
|
|
171
|
+
/**
|
|
172
|
+
* The total score of the player.
|
|
173
|
+
*/
|
|
174
|
+
score: number;
|
|
175
|
+
/**
|
|
176
|
+
* The total performance points of the player.
|
|
177
|
+
*/
|
|
178
|
+
pp: number;
|
|
179
|
+
/**
|
|
180
|
+
* The overall accuracy of the player.
|
|
181
|
+
*/
|
|
182
|
+
accuracy: number;
|
|
183
|
+
/**
|
|
184
|
+
* The amount of times the player has played.
|
|
185
|
+
*/
|
|
186
|
+
playCount: number;
|
|
187
|
+
/**
|
|
188
|
+
* Recent plays of the player.
|
|
189
|
+
*/
|
|
190
|
+
readonly recentPlays: Score[];
|
|
191
|
+
constructor(apiPlayer: APIPlayer);
|
|
192
|
+
/**
|
|
193
|
+
* Retrieves a player's info based on their username.
|
|
194
|
+
*
|
|
195
|
+
* @param uidOrUsername The uid or username of the player.
|
|
196
|
+
* @returns The player, `null` if the player is not found.
|
|
197
|
+
*/
|
|
198
|
+
static getInformation(uidOrUsername: string | number): Promise<Player | null>;
|
|
199
|
+
/**
|
|
200
|
+
* Returns a string representative of the class.
|
|
201
|
+
*/
|
|
202
|
+
toString(): string;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* A score that counts toward a player's totals.
|
|
206
|
+
*/
|
|
207
|
+
export interface PlayerTotalsScore {
|
|
208
|
+
/**
|
|
209
|
+
* The performance points of the score.
|
|
210
|
+
*/
|
|
211
|
+
readonly pp: number;
|
|
212
|
+
/**
|
|
213
|
+
* The accuracy of the score, from 0 to 1.
|
|
214
|
+
*/
|
|
215
|
+
readonly accuracy: number;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* A player's total performance points and overall accuracy.
|
|
219
|
+
*/
|
|
220
|
+
export interface PlayerTotals {
|
|
221
|
+
/**
|
|
222
|
+
* The total performance points.
|
|
223
|
+
*/
|
|
224
|
+
readonly pp: number;
|
|
225
|
+
/**
|
|
226
|
+
* The overall accuracy, from 0 to 1.
|
|
227
|
+
*/
|
|
228
|
+
readonly accuracy: number;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Calculates a player's total performance points and overall accuracy from their best scores.
|
|
232
|
+
*
|
|
233
|
+
* Only the {@link PlayerTotalsCalculator.countedScores} best scores by performance points count. The score at
|
|
234
|
+
* position `i` (from 0) is weighted by `0.95^i`.
|
|
235
|
+
*/
|
|
236
|
+
export declare abstract class PlayerTotalsCalculator {
|
|
237
|
+
/**
|
|
238
|
+
* The amount of best scores that count toward a player's totals.
|
|
239
|
+
*/
|
|
240
|
+
static readonly countedScores = 100;
|
|
241
|
+
/**
|
|
242
|
+
* Gets the weight of a score at a position among a player's best scores.
|
|
243
|
+
*
|
|
244
|
+
* @param index The position of the score, from 0, when sorted by performance points in descending order.
|
|
245
|
+
* @returns The weight of the score, or 0 if the score does not count.
|
|
246
|
+
*/
|
|
247
|
+
static getWeight(index: number): number;
|
|
248
|
+
/**
|
|
249
|
+
* Calculates a player's totals from their scores.
|
|
250
|
+
*
|
|
251
|
+
* @param scores The player's scores, in any order. Scores with equal performance points keep their given order.
|
|
252
|
+
* @returns The player's totals. The accuracy is 1 when there are no scores.
|
|
253
|
+
*/
|
|
254
|
+
static calculate(scores: Iterable<PlayerTotalsScore>): PlayerTotals;
|
|
255
|
+
}
|