@rian8337/osu-base 1.0.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/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/beatmap/Beatmap.js +223 -0
- package/dist/beatmap/Parser.js +620 -0
- package/dist/beatmap/hitobjects/Circle.js +20 -0
- package/dist/beatmap/hitobjects/HitObject.js +74 -0
- package/dist/beatmap/hitobjects/Slider.js +143 -0
- package/dist/beatmap/hitobjects/Spinner.js +26 -0
- package/dist/beatmap/hitobjects/sliderObjects/HeadCircle.js +10 -0
- package/dist/beatmap/hitobjects/sliderObjects/RepeatPoint.js +21 -0
- package/dist/beatmap/hitobjects/sliderObjects/SliderTick.js +21 -0
- package/dist/beatmap/hitobjects/sliderObjects/TailCircle.js +10 -0
- package/dist/beatmap/timings/BreakPoint.js +34 -0
- package/dist/beatmap/timings/DifficultyControlPoint.js +22 -0
- package/dist/beatmap/timings/TimingControlPoint.js +22 -0
- package/dist/beatmap/timings/TimingPoint.js +12 -0
- package/dist/constants/ParserConstants.js +19 -0
- package/dist/constants/PathType.js +13 -0
- package/dist/constants/modes.js +11 -0
- package/dist/constants/objectTypes.js +12 -0
- package/dist/constants/rankedStatus.js +16 -0
- package/dist/index.js +64 -0
- package/dist/mathutil/Interpolation.js +9 -0
- package/dist/mathutil/MathUtils.js +41 -0
- package/dist/mathutil/Vector2.js +79 -0
- package/dist/mods/Mod.js +9 -0
- package/dist/mods/ModAuto.js +21 -0
- package/dist/mods/ModAutopilot.js +21 -0
- package/dist/mods/ModDoubleTime.js +21 -0
- package/dist/mods/ModEasy.js +21 -0
- package/dist/mods/ModFlashlight.js +21 -0
- package/dist/mods/ModHalfTime.js +21 -0
- package/dist/mods/ModHardRock.js +21 -0
- package/dist/mods/ModHidden.js +21 -0
- package/dist/mods/ModNightCore.js +21 -0
- package/dist/mods/ModNoFail.js +21 -0
- package/dist/mods/ModPerfect.js +21 -0
- package/dist/mods/ModPrecise.js +21 -0
- package/dist/mods/ModReallyEasy.js +21 -0
- package/dist/mods/ModRelax.js +21 -0
- package/dist/mods/ModScoreV2.js +21 -0
- package/dist/mods/ModSmallCircle.js +21 -0
- package/dist/mods/ModSpunOut.js +21 -0
- package/dist/mods/ModSuddenDeath.js +21 -0
- package/dist/mods/ModTouchDevice.js +21 -0
- package/dist/tools/MapInfo.js +559 -0
- package/dist/utils/APIRequestBuilder.js +144 -0
- package/dist/utils/Accuracy.js +96 -0
- package/dist/utils/HitWindow.js +56 -0
- package/dist/utils/MapStats.js +212 -0
- package/dist/utils/ModUtil.js +137 -0
- package/dist/utils/PathApproximator.js +269 -0
- package/dist/utils/Precision.js +31 -0
- package/dist/utils/SliderPath.js +187 -0
- package/dist/utils/Utils.js +53 -0
- package/package.json +43 -0
- package/typings/index.d.ts +1951 -0
|
@@ -0,0 +1,1951 @@
|
|
|
1
|
+
declare module "@rian8337/osu-base" {
|
|
2
|
+
//#region Classes
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An accuracy calculator that calculates accuracy based on given parameters.
|
|
6
|
+
*/
|
|
7
|
+
export class Accuracy implements AccuracyInformation {
|
|
8
|
+
n300: number;
|
|
9
|
+
n100: number;
|
|
10
|
+
n50: number;
|
|
11
|
+
nmiss: number;
|
|
12
|
+
/**
|
|
13
|
+
* Calculates accuracy based on given parameters.
|
|
14
|
+
*
|
|
15
|
+
* If `percent` and `nobjects` are specified, `n300`, `n100`, and `n50` will
|
|
16
|
+
* be automatically calculated to be the closest to the given
|
|
17
|
+
* acc percent.
|
|
18
|
+
*
|
|
19
|
+
* @param values Function parameters.
|
|
20
|
+
*/
|
|
21
|
+
constructor(values: AccuracyInformation);
|
|
22
|
+
/**
|
|
23
|
+
* Calculates the accuracy value (0.0 - 1.0).
|
|
24
|
+
*
|
|
25
|
+
* @param nobjects The amount of objects in the beatmap. If `n300` was not specified in the constructor, this is required.
|
|
26
|
+
*/
|
|
27
|
+
value(nobjects?: number): number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Represents a beatmap with advanced information.
|
|
32
|
+
*/
|
|
33
|
+
export class Beatmap {
|
|
34
|
+
/**
|
|
35
|
+
* The format version of the beatmap.
|
|
36
|
+
*/
|
|
37
|
+
formatVersion: number;
|
|
38
|
+
/**
|
|
39
|
+
* The title of the song of the beatmap.
|
|
40
|
+
*/
|
|
41
|
+
title: string;
|
|
42
|
+
/**
|
|
43
|
+
* The unicode title of the song of the beatmap.
|
|
44
|
+
*/
|
|
45
|
+
titleUnicode: string;
|
|
46
|
+
/**
|
|
47
|
+
* The artist of the song of the beatmap.
|
|
48
|
+
*/
|
|
49
|
+
artist: string;
|
|
50
|
+
/**
|
|
51
|
+
* The unicode artist of the song of the beatmap.
|
|
52
|
+
*/
|
|
53
|
+
artistUnicode: string;
|
|
54
|
+
/**
|
|
55
|
+
* The creator of the beatmap.
|
|
56
|
+
*/
|
|
57
|
+
creator: string;
|
|
58
|
+
/**
|
|
59
|
+
* The difficulty name of the beatmap.
|
|
60
|
+
*/
|
|
61
|
+
version: string;
|
|
62
|
+
/**
|
|
63
|
+
* The ID of the beatmap.
|
|
64
|
+
*/
|
|
65
|
+
beatmapId?: number;
|
|
66
|
+
/**
|
|
67
|
+
* The ID of the beatmapset containing this beatmap.
|
|
68
|
+
*/
|
|
69
|
+
beatmapSetId?: number;
|
|
70
|
+
/**
|
|
71
|
+
* The approach rate of the beatmap.
|
|
72
|
+
*/
|
|
73
|
+
ar?: number;
|
|
74
|
+
/**
|
|
75
|
+
* The circle size of the beatmap.
|
|
76
|
+
*/
|
|
77
|
+
cs: number;
|
|
78
|
+
/**
|
|
79
|
+
* The overall difficulty of the beatmap.
|
|
80
|
+
*/
|
|
81
|
+
od: number;
|
|
82
|
+
/**
|
|
83
|
+
* The health drain rate of the beatmap.
|
|
84
|
+
*/
|
|
85
|
+
hp: number;
|
|
86
|
+
/**
|
|
87
|
+
* The slider velocity of the beatmap.
|
|
88
|
+
*/
|
|
89
|
+
sv: number;
|
|
90
|
+
/**
|
|
91
|
+
* The slider tick rate of the beatmap.
|
|
92
|
+
*/
|
|
93
|
+
tickRate: number;
|
|
94
|
+
/**
|
|
95
|
+
* The amount of circles in the beatmap.
|
|
96
|
+
*/
|
|
97
|
+
circles: number;
|
|
98
|
+
/**
|
|
99
|
+
* The amount of sliders in the beatmap.
|
|
100
|
+
*/
|
|
101
|
+
sliders: number;
|
|
102
|
+
/**
|
|
103
|
+
* The amount of spinners in the beatmap.
|
|
104
|
+
*/
|
|
105
|
+
spinners: number;
|
|
106
|
+
/**
|
|
107
|
+
* The objects of the beatmap.
|
|
108
|
+
*/
|
|
109
|
+
readonly objects: HitObject[];
|
|
110
|
+
/**
|
|
111
|
+
* The timing points of the beatmap.
|
|
112
|
+
*/
|
|
113
|
+
readonly timingPoints: TimingControlPoint[];
|
|
114
|
+
/**
|
|
115
|
+
* The difficulty timing points of the beatmap.
|
|
116
|
+
*/
|
|
117
|
+
readonly difficultyTimingPoints: DifficultyControlPoint[];
|
|
118
|
+
/**
|
|
119
|
+
* The break points of the beatmap.
|
|
120
|
+
*/
|
|
121
|
+
readonly breakPoints: BreakPoint[];
|
|
122
|
+
/**
|
|
123
|
+
* The stack leniency of the beatmap.
|
|
124
|
+
*/
|
|
125
|
+
stackLeniency: number;
|
|
126
|
+
/**
|
|
127
|
+
* The amount of slider ticks in the beatmap.
|
|
128
|
+
*/
|
|
129
|
+
get sliderTicks(): number;
|
|
130
|
+
/**
|
|
131
|
+
* The amount of sliderends in the beatmap.
|
|
132
|
+
*/
|
|
133
|
+
get sliderEnds(): number;
|
|
134
|
+
/**
|
|
135
|
+
* The amount of slider repeat points in the beatmap.
|
|
136
|
+
*/
|
|
137
|
+
get sliderRepeatPoints(): number;
|
|
138
|
+
/**
|
|
139
|
+
* The maximum combo of the beatmap.
|
|
140
|
+
*/
|
|
141
|
+
get maxCombo(): number;
|
|
142
|
+
/**
|
|
143
|
+
* Returns a time combined with beatmap-wide time offset.
|
|
144
|
+
*
|
|
145
|
+
* BeatmapVersion 4 and lower had an incorrect offset. Stable has this set as 24ms off.
|
|
146
|
+
*
|
|
147
|
+
* @param time The time.
|
|
148
|
+
*/
|
|
149
|
+
getOffsetTime(time: number): number;
|
|
150
|
+
/**
|
|
151
|
+
* Gets the timing control point that applies at a given time.
|
|
152
|
+
*
|
|
153
|
+
* @param time The time.
|
|
154
|
+
*/
|
|
155
|
+
timingControlPointAt(time: number): TimingControlPoint;
|
|
156
|
+
/**
|
|
157
|
+
* Gets the difficulty control point that applies at a given time.
|
|
158
|
+
*
|
|
159
|
+
* @param time The time.
|
|
160
|
+
*/
|
|
161
|
+
difficultyControlPointAt(time: number): DifficultyControlPoint;
|
|
162
|
+
/**
|
|
163
|
+
* Gets the timing point that applies at a given time.
|
|
164
|
+
*
|
|
165
|
+
* @param time The time.
|
|
166
|
+
* @param list The timing points to search in.
|
|
167
|
+
*/
|
|
168
|
+
private getTimingPoint<T extends TimingPoint>(time: number, list: T[]): T;
|
|
169
|
+
/**
|
|
170
|
+
* Returns a string representative of the class.
|
|
171
|
+
*/
|
|
172
|
+
toString(): string;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Represents a break period in a beatmap.
|
|
177
|
+
*/
|
|
178
|
+
export class BreakPoint {
|
|
179
|
+
/**
|
|
180
|
+
* The minimum duration required for a break to have any effect.
|
|
181
|
+
*/
|
|
182
|
+
static readonly MIN_BREAK_DURATION: number;
|
|
183
|
+
/**
|
|
184
|
+
* The start time of the break period.
|
|
185
|
+
*/
|
|
186
|
+
readonly startTime: number;
|
|
187
|
+
/**
|
|
188
|
+
* The end time of the break period.
|
|
189
|
+
*/
|
|
190
|
+
readonly endTime: number;
|
|
191
|
+
/**
|
|
192
|
+
* The duration of the break period. This is obtained from `endTime - startTime`.
|
|
193
|
+
*/
|
|
194
|
+
readonly duration: number;
|
|
195
|
+
constructor(values: { startTime: number; endTime: number });
|
|
196
|
+
/**
|
|
197
|
+
* Returns a string representation of the class.
|
|
198
|
+
*/
|
|
199
|
+
toString(): string;
|
|
200
|
+
/**
|
|
201
|
+
* Whether this break period contains a specified time.
|
|
202
|
+
*
|
|
203
|
+
* @param time The time to check in milliseconds.
|
|
204
|
+
* @returns Whether the time falls within this break period.
|
|
205
|
+
*/
|
|
206
|
+
contains(time: number): boolean;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Represents a circle in a beatmap.
|
|
211
|
+
*
|
|
212
|
+
* All we need from circles is their position. All positions
|
|
213
|
+
* stored in the objects are in playfield coordinates (512*384
|
|
214
|
+
* rectangle).
|
|
215
|
+
*/
|
|
216
|
+
export class Circle extends HitObject {
|
|
217
|
+
constructor(values: {
|
|
218
|
+
startTime: number;
|
|
219
|
+
type: number;
|
|
220
|
+
position: Vector2;
|
|
221
|
+
});
|
|
222
|
+
override toString(): string;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Represents a timing point that changes speed multiplier.
|
|
227
|
+
*/
|
|
228
|
+
export class DifficultyControlPoint extends TimingPoint {
|
|
229
|
+
/**
|
|
230
|
+
* The slider speed multiplier of the timing point.
|
|
231
|
+
*/
|
|
232
|
+
readonly speedMultiplier: number;
|
|
233
|
+
constructor(values: { time: number; speedMultiplier: number });
|
|
234
|
+
override toString(): string;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* API request builder for osu!droid.
|
|
239
|
+
*/
|
|
240
|
+
export class DroidAPIRequestBuilder extends APIRequestBuilder {
|
|
241
|
+
protected override readonly host: string;
|
|
242
|
+
protected override readonly APIkey: string;
|
|
243
|
+
protected override readonly APIkeyParam: string;
|
|
244
|
+
override setEndpoint(endpoint: DroidAPIEndpoint): this;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Represents the hit window of osu!droid.
|
|
249
|
+
*/
|
|
250
|
+
export class DroidHitWindow extends HitWindow {
|
|
251
|
+
/**
|
|
252
|
+
* @param isPrecise Whether or not to calculate for Precise mod.
|
|
253
|
+
*/
|
|
254
|
+
override hitWindowFor300(isPrecise?: boolean): number;
|
|
255
|
+
/**
|
|
256
|
+
* @param isPrecise Whether or not to calculate for Precise mod.
|
|
257
|
+
*/
|
|
258
|
+
override hitWindowFor100(isPrecise?: boolean): number;
|
|
259
|
+
/**
|
|
260
|
+
* @param isPrecise Whether or not to calculate for Precise mod.
|
|
261
|
+
*/
|
|
262
|
+
override hitWindowFor50(isPrecise?: boolean): number;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Represents the headcircle of a slider (sliderhead).
|
|
267
|
+
*/
|
|
268
|
+
export class HeadCircle extends Circle { }
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Represents a hitobject in a beatmap.
|
|
272
|
+
*/
|
|
273
|
+
export abstract class HitObject {
|
|
274
|
+
/**
|
|
275
|
+
* The start time of the hitobject in milliseconds.
|
|
276
|
+
*/
|
|
277
|
+
startTime: number;
|
|
278
|
+
/**
|
|
279
|
+
* The bitwise type of the hitobject (circle/slider/spinner).
|
|
280
|
+
*/
|
|
281
|
+
readonly type: objectTypes;
|
|
282
|
+
/**
|
|
283
|
+
* The position of the hitobject in osu!pixels.
|
|
284
|
+
*/
|
|
285
|
+
readonly position: Vector2;
|
|
286
|
+
/**
|
|
287
|
+
* The end position of the hitobject in osu!pixels.
|
|
288
|
+
*/
|
|
289
|
+
readonly endPosition: Vector2;
|
|
290
|
+
/**
|
|
291
|
+
* The end time of the hitobject.
|
|
292
|
+
*/
|
|
293
|
+
endTime: number;
|
|
294
|
+
/**
|
|
295
|
+
* The stacked position of the hitobject.
|
|
296
|
+
*/
|
|
297
|
+
get stackedPosition(): Vector2;
|
|
298
|
+
/**
|
|
299
|
+
* The stacked end position of the hitobject.
|
|
300
|
+
*/
|
|
301
|
+
get stackedEndPosition(): Vector2;
|
|
302
|
+
/**
|
|
303
|
+
* The stack vector to calculate offset for stacked positions.
|
|
304
|
+
*/
|
|
305
|
+
get stackOffset(): Vector2;
|
|
306
|
+
/**
|
|
307
|
+
* Whether or not this hitobject represents a new combo in the beatmap.
|
|
308
|
+
*/
|
|
309
|
+
readonly isNewCombo: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* The stack height of the hitobject.
|
|
312
|
+
*/
|
|
313
|
+
stackHeight: number;
|
|
314
|
+
/**
|
|
315
|
+
* The scale used to calculate stacked position and radius.
|
|
316
|
+
*/
|
|
317
|
+
scale: number;
|
|
318
|
+
/**
|
|
319
|
+
* The radius of the hitobject.
|
|
320
|
+
*/
|
|
321
|
+
get radius(): number;
|
|
322
|
+
constructor(values: {
|
|
323
|
+
startTime: number;
|
|
324
|
+
position: Vector2;
|
|
325
|
+
type: number;
|
|
326
|
+
endTime?: number;
|
|
327
|
+
});
|
|
328
|
+
/**
|
|
329
|
+
* Returns the hitobject type.
|
|
330
|
+
*/
|
|
331
|
+
typeStr(): string;
|
|
332
|
+
/**
|
|
333
|
+
* Calculates the stacked position of the hitobject.
|
|
334
|
+
*/
|
|
335
|
+
calculateStackedPosition(scale: number): void;
|
|
336
|
+
/**
|
|
337
|
+
* Returns the string representative of the class.
|
|
338
|
+
*/
|
|
339
|
+
abstract toString(): string;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export abstract class Interpolation {
|
|
343
|
+
static lerp(start: number, final: number, amount: number): number;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Represents a beatmap with general information.
|
|
348
|
+
*/
|
|
349
|
+
export class MapInfo {
|
|
350
|
+
/**
|
|
351
|
+
* The title of the song of the beatmap.
|
|
352
|
+
*/
|
|
353
|
+
title: string;
|
|
354
|
+
/**
|
|
355
|
+
* The full title of the beatmap, which is `Artist - Title (Creator) [Difficulty Name]`.
|
|
356
|
+
*/
|
|
357
|
+
get fullTitle(): string;
|
|
358
|
+
/**
|
|
359
|
+
* The artist of the song of the beatmap.
|
|
360
|
+
*/
|
|
361
|
+
artist: string;
|
|
362
|
+
/**
|
|
363
|
+
* The creator of the beatmap.
|
|
364
|
+
*/
|
|
365
|
+
creator: string;
|
|
366
|
+
/**
|
|
367
|
+
* The difficulty name of the beatmap.
|
|
368
|
+
*/
|
|
369
|
+
version: string;
|
|
370
|
+
/**
|
|
371
|
+
* The source of the song, if any.
|
|
372
|
+
*/
|
|
373
|
+
source: string;
|
|
374
|
+
/**
|
|
375
|
+
* The ranking status of the beatmap.
|
|
376
|
+
*/
|
|
377
|
+
approved: rankedStatus;
|
|
378
|
+
/**
|
|
379
|
+
* The ID of the beatmap.
|
|
380
|
+
*/
|
|
381
|
+
beatmapID: number;
|
|
382
|
+
/**
|
|
383
|
+
* The ID of the beatmapset containing the beatmap.
|
|
384
|
+
*/
|
|
385
|
+
beatmapsetID: number;
|
|
386
|
+
/**
|
|
387
|
+
* The amount of times the beatmap has been played.
|
|
388
|
+
*/
|
|
389
|
+
plays: number;
|
|
390
|
+
/**
|
|
391
|
+
* The amount of times the beatmap has been favorited.
|
|
392
|
+
*/
|
|
393
|
+
favorites: number;
|
|
394
|
+
/**
|
|
395
|
+
* The date of which the beatmap was submitted.
|
|
396
|
+
*/
|
|
397
|
+
submitDate: Date;
|
|
398
|
+
/**
|
|
399
|
+
* The date of which the beatmap was last updated.
|
|
400
|
+
*/
|
|
401
|
+
lastUpdate: Date;
|
|
402
|
+
/**
|
|
403
|
+
* The duration of the beatmap not including breaks.
|
|
404
|
+
*/
|
|
405
|
+
hitLength: number;
|
|
406
|
+
/**
|
|
407
|
+
* The duration of the beatmap including breaks.
|
|
408
|
+
*/
|
|
409
|
+
totalLength: number;
|
|
410
|
+
/**
|
|
411
|
+
* The BPM of the beatmap.
|
|
412
|
+
*/
|
|
413
|
+
bpm: number;
|
|
414
|
+
/**
|
|
415
|
+
* The amount of circles in the beatmap.
|
|
416
|
+
*/
|
|
417
|
+
circles: number;
|
|
418
|
+
/**
|
|
419
|
+
* The amount of sliders in the beatmap.
|
|
420
|
+
*/
|
|
421
|
+
sliders: number;
|
|
422
|
+
/**
|
|
423
|
+
* The amount of spinners in the beatmap.
|
|
424
|
+
*/
|
|
425
|
+
spinners: number;
|
|
426
|
+
/**
|
|
427
|
+
* The amount of objects in the beatmap.
|
|
428
|
+
*/
|
|
429
|
+
get objects(): number;
|
|
430
|
+
/**
|
|
431
|
+
* The maximum combo of the beatmap.
|
|
432
|
+
*/
|
|
433
|
+
maxCombo: number;
|
|
434
|
+
/**
|
|
435
|
+
* The circle size of the beatmap.
|
|
436
|
+
*/
|
|
437
|
+
cs: number;
|
|
438
|
+
/**
|
|
439
|
+
* The approach rate of the beatmap.
|
|
440
|
+
*/
|
|
441
|
+
ar: number;
|
|
442
|
+
/**
|
|
443
|
+
* The overall difficulty of the beatmap.
|
|
444
|
+
*/
|
|
445
|
+
od: number;
|
|
446
|
+
/**
|
|
447
|
+
* The health drain rate of the beatmap.
|
|
448
|
+
*/
|
|
449
|
+
hp: number;
|
|
450
|
+
/**
|
|
451
|
+
* The beatmap packs that contain this beatmap, represented by their ID.
|
|
452
|
+
*/
|
|
453
|
+
packs: string[];
|
|
454
|
+
/**
|
|
455
|
+
* The aim difficulty rating of the beatmap.
|
|
456
|
+
*/
|
|
457
|
+
aimDifficulty: number;
|
|
458
|
+
/**
|
|
459
|
+
* The speed difficulty rating of the beatmap.
|
|
460
|
+
*/
|
|
461
|
+
speedDifficulty: number;
|
|
462
|
+
/**
|
|
463
|
+
* The generic difficulty rating of the beatmap.
|
|
464
|
+
*/
|
|
465
|
+
totalDifficulty: number;
|
|
466
|
+
/**
|
|
467
|
+
* The MD5 hash of the beatmap.
|
|
468
|
+
*/
|
|
469
|
+
hash: string;
|
|
470
|
+
/**
|
|
471
|
+
* Whether or not this beatmap has a storyboard.
|
|
472
|
+
*/
|
|
473
|
+
storyboardAvailable: boolean;
|
|
474
|
+
/**
|
|
475
|
+
* Whether or not this beatmap has a video.
|
|
476
|
+
*/
|
|
477
|
+
videoAvailable: boolean;
|
|
478
|
+
/**
|
|
479
|
+
* The parsed beatmap from beatmap parser.
|
|
480
|
+
*/
|
|
481
|
+
get map(): Beatmap | undefined;
|
|
482
|
+
private cachedBeatmap?: Beatmap;
|
|
483
|
+
/**
|
|
484
|
+
* Retrieve a beatmap's general information.
|
|
485
|
+
*
|
|
486
|
+
* Either beatmap ID or MD5 hash of the beatmap must be specified. If both are specified, beatmap ID is taken.
|
|
487
|
+
*/
|
|
488
|
+
static getInformation(params: {
|
|
489
|
+
/**
|
|
490
|
+
* The ID of the beatmap.
|
|
491
|
+
*/
|
|
492
|
+
beatmapID?: number;
|
|
493
|
+
/**
|
|
494
|
+
* The MD5 hash of the beatmap.
|
|
495
|
+
*/
|
|
496
|
+
hash?: string;
|
|
497
|
+
/**
|
|
498
|
+
* Whether or not to also retrieve the .osu file of the beatmap (required for some utilities). Defaults to `true`.
|
|
499
|
+
*/
|
|
500
|
+
file?: boolean;
|
|
501
|
+
}): Promise<MapInfo>;
|
|
502
|
+
/**
|
|
503
|
+
* Fills the current instance with map data.
|
|
504
|
+
*
|
|
505
|
+
* @param mapinfo The map data.
|
|
506
|
+
*/
|
|
507
|
+
fillMetadata(mapinfo: OsuAPIResponse): MapInfo;
|
|
508
|
+
/**
|
|
509
|
+
* Retrieves the .osu file of the beatmap.
|
|
510
|
+
*
|
|
511
|
+
* @param forceDownload Whether or not to download the file regardless if it's already available.
|
|
512
|
+
*/
|
|
513
|
+
retrieveBeatmapFile(forceDownload?: boolean): Promise<MapInfo>;
|
|
514
|
+
/**
|
|
515
|
+
* Converts the beatmap's BPM if speed-changing mods are applied.
|
|
516
|
+
*/
|
|
517
|
+
convertBPM(stats: MapStats): number;
|
|
518
|
+
/**
|
|
519
|
+
* Converts the beatmap's status into a string.
|
|
520
|
+
*/
|
|
521
|
+
convertStatus(): string;
|
|
522
|
+
/**
|
|
523
|
+
* Converts the beatmap's length if speed-changing mods are applied.
|
|
524
|
+
*/
|
|
525
|
+
convertTime(stats: MapStats): string;
|
|
526
|
+
/**
|
|
527
|
+
* Time string parsing function for statistics utility.
|
|
528
|
+
*/
|
|
529
|
+
private timeString(second: number): string;
|
|
530
|
+
/**
|
|
531
|
+
* Shows the beatmap's statistics based on applied statistics and option.
|
|
532
|
+
*
|
|
533
|
+
* - Option `0`: return map title and mods used if defined
|
|
534
|
+
* - Option `1`: return song source and map download link to beatmap mirrors
|
|
535
|
+
* - Option `2`: return CS, AR, OD, HP
|
|
536
|
+
* - Option `3`: return BPM, map length, max combo
|
|
537
|
+
* - Option `4`: return last update date and map status
|
|
538
|
+
* - Option `5`: return favorite count and play count
|
|
539
|
+
*
|
|
540
|
+
* @param option The option to pick.
|
|
541
|
+
* @param stats The custom statistics to apply. This will only be used to apply mods, custom speed multiplier, and force AR.
|
|
542
|
+
*/
|
|
543
|
+
showStatistics(option: number, stats?: MapStats): string;
|
|
544
|
+
/**
|
|
545
|
+
* Gets a color integer based on the beatmap's ranking status.
|
|
546
|
+
*
|
|
547
|
+
* Useful to make embed messages.
|
|
548
|
+
*/
|
|
549
|
+
get statusColor(): number;
|
|
550
|
+
/**
|
|
551
|
+
* Calculates the osu!droid maximum score of the beatmap.
|
|
552
|
+
*
|
|
553
|
+
* This requires .osu file to be downloaded.
|
|
554
|
+
*/
|
|
555
|
+
maxScore(stats: MapStats): number;
|
|
556
|
+
/**
|
|
557
|
+
* Returns a string representative of the class.
|
|
558
|
+
*/
|
|
559
|
+
toString(): string;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Holds general beatmap statistics for further modifications.
|
|
564
|
+
*/
|
|
565
|
+
export class MapStats {
|
|
566
|
+
/**
|
|
567
|
+
* The circle size of the beatmap.
|
|
568
|
+
*/
|
|
569
|
+
cs?: number;
|
|
570
|
+
/**
|
|
571
|
+
* The approach rate of the beatmap.
|
|
572
|
+
*/
|
|
573
|
+
ar?: number;
|
|
574
|
+
/**
|
|
575
|
+
* The overall difficulty of the beatmap.
|
|
576
|
+
*/
|
|
577
|
+
od?: number;
|
|
578
|
+
/**
|
|
579
|
+
* The health drain rate of the beatmap.
|
|
580
|
+
*/
|
|
581
|
+
hp?: number;
|
|
582
|
+
/**
|
|
583
|
+
* The enabled modifications.
|
|
584
|
+
*/
|
|
585
|
+
mods: Mod[];
|
|
586
|
+
/**
|
|
587
|
+
* The speed multiplier applied from all modifications.
|
|
588
|
+
*/
|
|
589
|
+
speedMultiplier: number;
|
|
590
|
+
/**
|
|
591
|
+
* Whether or not this map statistics uses forced AR.
|
|
592
|
+
*/
|
|
593
|
+
isForceAR: boolean;
|
|
594
|
+
/**
|
|
595
|
+
* Whether to calculate for old statistics for osu!droid gamemode (1.6.7 and older). Defaults to `false`.
|
|
596
|
+
*/
|
|
597
|
+
oldStatistics: boolean;
|
|
598
|
+
/**
|
|
599
|
+
* Whether this map statistics have been calculated.
|
|
600
|
+
*/
|
|
601
|
+
private calculated: boolean;
|
|
602
|
+
static readonly OD0_MS: number;
|
|
603
|
+
static readonly OD10_MS: number;
|
|
604
|
+
static readonly AR0_MS: number;
|
|
605
|
+
static readonly AR5_MS: number;
|
|
606
|
+
static readonly AR10_MS: number;
|
|
607
|
+
static readonly OD_MS_STEP: number;
|
|
608
|
+
static readonly AR_MS_STEP1: number;
|
|
609
|
+
static readonly AR_MS_STEP2: number;
|
|
610
|
+
constructor(values?: {
|
|
611
|
+
/**
|
|
612
|
+
* The circle size of the beatmap.
|
|
613
|
+
*/
|
|
614
|
+
cs?: number;
|
|
615
|
+
/**
|
|
616
|
+
* The approach rate of the beatmap.
|
|
617
|
+
*/
|
|
618
|
+
ar?: number;
|
|
619
|
+
/**
|
|
620
|
+
* The overall difficulty of the beatmap.
|
|
621
|
+
*/
|
|
622
|
+
od?: number;
|
|
623
|
+
/**
|
|
624
|
+
* The health drain rate of the beatmap.
|
|
625
|
+
*/
|
|
626
|
+
hp?: number;
|
|
627
|
+
/**
|
|
628
|
+
* Applied modifications in osu!standard format.
|
|
629
|
+
*/
|
|
630
|
+
mods?: Mod[];
|
|
631
|
+
/**
|
|
632
|
+
* The speed multiplier to calculate for.
|
|
633
|
+
*/
|
|
634
|
+
speedMultiplier?: number;
|
|
635
|
+
/**
|
|
636
|
+
* Whether or not force AR is turned on.
|
|
637
|
+
*/
|
|
638
|
+
isForceAR?: boolean;
|
|
639
|
+
/**
|
|
640
|
+
* Whether to calculate for old statistics for osu!droid gamemode (1.6.7 or older).
|
|
641
|
+
*/
|
|
642
|
+
oldStatistics?: boolean;
|
|
643
|
+
});
|
|
644
|
+
/**
|
|
645
|
+
* Calculates map statistics.
|
|
646
|
+
*
|
|
647
|
+
* This can only be called once for an instance.
|
|
648
|
+
*/
|
|
649
|
+
calculate(params?: {
|
|
650
|
+
/**
|
|
651
|
+
* The gamemode to calculate for. Defaults to `modes.osu`.
|
|
652
|
+
*/
|
|
653
|
+
mode?: modes;
|
|
654
|
+
/**
|
|
655
|
+
* The applied modifications in osu!standard format.
|
|
656
|
+
*/
|
|
657
|
+
mods?: string;
|
|
658
|
+
/**
|
|
659
|
+
* The speed multiplier to calculate for.
|
|
660
|
+
*/
|
|
661
|
+
speedMultiplier?: number;
|
|
662
|
+
/**
|
|
663
|
+
* Whether or not force AR is turned on.
|
|
664
|
+
*/
|
|
665
|
+
isForceAR?: boolean;
|
|
666
|
+
}): MapStats;
|
|
667
|
+
/**
|
|
668
|
+
* Returns a string representative of the class.
|
|
669
|
+
*/
|
|
670
|
+
toString(): string;
|
|
671
|
+
/**
|
|
672
|
+
* Utility function to apply speed and flat multipliers to stats where speed changes apply for AR.
|
|
673
|
+
*
|
|
674
|
+
* @param baseAR The base AR value.
|
|
675
|
+
* @param speedMultiplier The speed multiplier to calculate.
|
|
676
|
+
* @param statisticsMultiplier The statistics multiplier to calculate from map-changing nonspeed-changing mods.
|
|
677
|
+
*/
|
|
678
|
+
static modifyAR(
|
|
679
|
+
baseAR: number,
|
|
680
|
+
speedMultiplier: number,
|
|
681
|
+
statisticsMultiplier: number
|
|
682
|
+
): number;
|
|
683
|
+
/**
|
|
684
|
+
* Utility function to apply speed and flat multipliers to stats where speed changes apply for OD.
|
|
685
|
+
*
|
|
686
|
+
* @param baseOD The base OD value.
|
|
687
|
+
* @param speedMultiplier The speed multiplier to calculate.
|
|
688
|
+
* @param statisticsMultiplier The statistics multiplier to calculate from map-changing nonspeed-changing mods.
|
|
689
|
+
*/
|
|
690
|
+
static modifyOD(
|
|
691
|
+
baseOD: number,
|
|
692
|
+
speedMultiplier: number,
|
|
693
|
+
statisticsMultiplier: number
|
|
694
|
+
): number;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Some math utility functions.
|
|
699
|
+
*/
|
|
700
|
+
export abstract class MathUtils {
|
|
701
|
+
/**
|
|
702
|
+
* Rounds a specified number with specified amount of fractional digits.
|
|
703
|
+
*
|
|
704
|
+
* @param num The number to round.
|
|
705
|
+
* @param fractionalDigits The amount of fractional digits.
|
|
706
|
+
*/
|
|
707
|
+
static round(num: number, fractionalDigits: number): number;
|
|
708
|
+
/**
|
|
709
|
+
* Limits the specified number on range `[min, max]`.
|
|
710
|
+
*
|
|
711
|
+
* @param num The number to limit.
|
|
712
|
+
* @param min The minimum range.
|
|
713
|
+
* @param max The maximum range.
|
|
714
|
+
*/
|
|
715
|
+
static clamp(num: number, min: number, max: number): number;
|
|
716
|
+
/**
|
|
717
|
+
* Calculates the standard deviation of a given data.
|
|
718
|
+
*
|
|
719
|
+
* @param data The data to calculate.
|
|
720
|
+
*/
|
|
721
|
+
static calculateStandardDeviation(data: number[]): number;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Represents a mod.
|
|
726
|
+
*/
|
|
727
|
+
export abstract class Mod {
|
|
728
|
+
/**
|
|
729
|
+
* The score multiplier of this mod.
|
|
730
|
+
*/
|
|
731
|
+
abstract readonly scoreMultiplier: number;
|
|
732
|
+
/**
|
|
733
|
+
* The acronym of the mod.
|
|
734
|
+
*/
|
|
735
|
+
abstract readonly acronym: string;
|
|
736
|
+
/**
|
|
737
|
+
* The name of the mod.
|
|
738
|
+
*/
|
|
739
|
+
abstract readonly name: string;
|
|
740
|
+
/**
|
|
741
|
+
* Whether the mod is ranked in osu!droid.
|
|
742
|
+
*/
|
|
743
|
+
abstract readonly droidRanked: boolean;
|
|
744
|
+
/**
|
|
745
|
+
* Whether the mod is ranked in osu!standard.
|
|
746
|
+
*/
|
|
747
|
+
abstract readonly pcRanked: boolean;
|
|
748
|
+
/**
|
|
749
|
+
* The bitwise enum of the mod.
|
|
750
|
+
*/
|
|
751
|
+
abstract readonly bitwise: number;
|
|
752
|
+
/**
|
|
753
|
+
* The droid enum of the mod.
|
|
754
|
+
*/
|
|
755
|
+
abstract readonly droidString: string;
|
|
756
|
+
/**
|
|
757
|
+
* Whether this mod only exists for osu!droid gamemode.
|
|
758
|
+
*/
|
|
759
|
+
abstract readonly droidOnly: boolean;
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Represents the Auto mod.
|
|
764
|
+
*/
|
|
765
|
+
export class ModAuto extends Mod {
|
|
766
|
+
override readonly scoreMultiplier: number;
|
|
767
|
+
override readonly acronym: string;
|
|
768
|
+
override readonly name: string;
|
|
769
|
+
override readonly droidRanked: boolean;
|
|
770
|
+
override readonly pcRanked: boolean;
|
|
771
|
+
override readonly bitwise: number;
|
|
772
|
+
override readonly droidString: string;
|
|
773
|
+
override readonly droidOnly: boolean;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* Represents the Autopilot mod.
|
|
778
|
+
*/
|
|
779
|
+
export class ModAutopilot extends Mod {
|
|
780
|
+
override readonly scoreMultiplier: number;
|
|
781
|
+
override readonly acronym: string;
|
|
782
|
+
override readonly name: string;
|
|
783
|
+
override readonly droidRanked: boolean;
|
|
784
|
+
override readonly pcRanked: boolean;
|
|
785
|
+
override readonly bitwise: number;
|
|
786
|
+
override readonly droidString: string;
|
|
787
|
+
override readonly droidOnly: boolean;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Represents the DoubleTime mod.
|
|
792
|
+
*/
|
|
793
|
+
export class ModDoubleTime extends Mod {
|
|
794
|
+
override readonly scoreMultiplier: number;
|
|
795
|
+
override readonly acronym: string;
|
|
796
|
+
override readonly name: string;
|
|
797
|
+
override readonly droidRanked: boolean;
|
|
798
|
+
override readonly pcRanked: boolean;
|
|
799
|
+
override readonly bitwise: number;
|
|
800
|
+
override readonly droidString: string;
|
|
801
|
+
override readonly droidOnly: boolean;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Represents the Easy mod.
|
|
806
|
+
*/
|
|
807
|
+
export class ModEasy extends Mod {
|
|
808
|
+
override readonly scoreMultiplier: number;
|
|
809
|
+
override readonly acronym: string;
|
|
810
|
+
override readonly name: string;
|
|
811
|
+
override readonly droidRanked: boolean;
|
|
812
|
+
override readonly pcRanked: boolean;
|
|
813
|
+
override readonly bitwise: number;
|
|
814
|
+
override readonly droidString: string;
|
|
815
|
+
override readonly droidOnly: boolean;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Represents the Flashlight mod.
|
|
820
|
+
*/
|
|
821
|
+
export class ModFlashlight extends Mod {
|
|
822
|
+
override readonly scoreMultiplier: number;
|
|
823
|
+
override readonly acronym: string;
|
|
824
|
+
override readonly name: string;
|
|
825
|
+
override readonly droidRanked: boolean;
|
|
826
|
+
override readonly pcRanked: boolean;
|
|
827
|
+
override readonly bitwise: number;
|
|
828
|
+
override readonly droidString: string;
|
|
829
|
+
override readonly droidOnly: boolean;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
* Represents the HalfTime mod.
|
|
834
|
+
*/
|
|
835
|
+
export class ModHalfTime extends Mod {
|
|
836
|
+
override readonly scoreMultiplier: number;
|
|
837
|
+
override readonly acronym: string;
|
|
838
|
+
override readonly name: string;
|
|
839
|
+
override readonly droidRanked: boolean;
|
|
840
|
+
override readonly pcRanked: boolean;
|
|
841
|
+
override readonly bitwise: number;
|
|
842
|
+
override readonly droidString: string;
|
|
843
|
+
override readonly droidOnly: boolean;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Represents the HardRock mod.
|
|
848
|
+
*/
|
|
849
|
+
export class ModHardRock extends Mod {
|
|
850
|
+
override readonly scoreMultiplier: number;
|
|
851
|
+
override readonly acronym: string;
|
|
852
|
+
override readonly name: string;
|
|
853
|
+
override readonly droidRanked: boolean;
|
|
854
|
+
override readonly pcRanked: boolean;
|
|
855
|
+
override readonly bitwise: number;
|
|
856
|
+
override readonly droidString: string;
|
|
857
|
+
override readonly droidOnly: boolean;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* Represents the Hidden mod.
|
|
862
|
+
*/
|
|
863
|
+
export class ModHidden extends Mod {
|
|
864
|
+
override readonly scoreMultiplier: number;
|
|
865
|
+
override readonly acronym: string;
|
|
866
|
+
override readonly name: string;
|
|
867
|
+
override readonly droidRanked: boolean;
|
|
868
|
+
override readonly pcRanked: boolean;
|
|
869
|
+
override readonly bitwise: number;
|
|
870
|
+
override readonly droidString: string;
|
|
871
|
+
override readonly droidOnly: boolean;
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Represents the NightCore mod.
|
|
876
|
+
*/
|
|
877
|
+
export class ModNightCore extends Mod {
|
|
878
|
+
override readonly scoreMultiplier: number;
|
|
879
|
+
override readonly acronym: string;
|
|
880
|
+
override readonly name: string;
|
|
881
|
+
override readonly droidRanked: boolean;
|
|
882
|
+
override readonly pcRanked: boolean;
|
|
883
|
+
override readonly bitwise: number;
|
|
884
|
+
override readonly droidString: string;
|
|
885
|
+
override readonly droidOnly: boolean;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Represents the NoFail mod.
|
|
890
|
+
*/
|
|
891
|
+
export class ModNoFail extends Mod {
|
|
892
|
+
override readonly scoreMultiplier: number;
|
|
893
|
+
override readonly acronym: string;
|
|
894
|
+
override readonly name: string;
|
|
895
|
+
override readonly droidRanked: boolean;
|
|
896
|
+
override readonly pcRanked: boolean;
|
|
897
|
+
override readonly bitwise: number;
|
|
898
|
+
override readonly droidString: string;
|
|
899
|
+
override readonly droidOnly: boolean;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Represents the Perfect mod.
|
|
904
|
+
*/
|
|
905
|
+
export class ModPerfect extends Mod {
|
|
906
|
+
override readonly scoreMultiplier: number;
|
|
907
|
+
override readonly acronym: string;
|
|
908
|
+
override readonly name: string;
|
|
909
|
+
override readonly droidRanked: boolean;
|
|
910
|
+
override readonly pcRanked: boolean;
|
|
911
|
+
override readonly bitwise: number;
|
|
912
|
+
override readonly droidString: string;
|
|
913
|
+
override readonly droidOnly: boolean;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Represents the Precise mod.
|
|
918
|
+
*/
|
|
919
|
+
export class ModPrecise extends Mod {
|
|
920
|
+
override readonly scoreMultiplier: number;
|
|
921
|
+
override readonly acronym: string;
|
|
922
|
+
override readonly name: string;
|
|
923
|
+
override readonly droidRanked: boolean;
|
|
924
|
+
override readonly pcRanked: boolean;
|
|
925
|
+
override readonly bitwise: number;
|
|
926
|
+
override readonly droidString: string;
|
|
927
|
+
override readonly droidOnly: boolean;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* Represents the ReallyEasy mod.
|
|
932
|
+
*/
|
|
933
|
+
export class ModReallyEasy extends Mod {
|
|
934
|
+
override readonly scoreMultiplier: number;
|
|
935
|
+
override readonly acronym: string;
|
|
936
|
+
override readonly name: string;
|
|
937
|
+
override readonly droidRanked: boolean;
|
|
938
|
+
override readonly pcRanked: boolean;
|
|
939
|
+
override readonly bitwise: number;
|
|
940
|
+
override readonly droidString: string;
|
|
941
|
+
override readonly droidOnly: boolean;
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Represents the Relax mod.
|
|
946
|
+
*/
|
|
947
|
+
export class ModRelax extends Mod {
|
|
948
|
+
override readonly scoreMultiplier: number;
|
|
949
|
+
override readonly acronym: string;
|
|
950
|
+
override readonly name: string;
|
|
951
|
+
override readonly droidRanked: boolean;
|
|
952
|
+
override readonly pcRanked: boolean;
|
|
953
|
+
override readonly bitwise: number;
|
|
954
|
+
override readonly droidString: string;
|
|
955
|
+
override readonly droidOnly: boolean;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* Represents the ScoreV2 mod.
|
|
960
|
+
*/
|
|
961
|
+
export class ModScoreV2 extends Mod {
|
|
962
|
+
override readonly scoreMultiplier: number;
|
|
963
|
+
override readonly acronym: string;
|
|
964
|
+
override readonly name: string;
|
|
965
|
+
override readonly droidRanked: boolean;
|
|
966
|
+
override readonly pcRanked: boolean;
|
|
967
|
+
override readonly bitwise: number;
|
|
968
|
+
override readonly droidString: string;
|
|
969
|
+
override readonly droidOnly: boolean;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Represents the SmallCircle mod.
|
|
974
|
+
*/
|
|
975
|
+
export class ModSmallCircle extends Mod {
|
|
976
|
+
override readonly scoreMultiplier: number;
|
|
977
|
+
override readonly acronym: string;
|
|
978
|
+
override readonly name: string;
|
|
979
|
+
override readonly droidRanked: boolean;
|
|
980
|
+
override readonly pcRanked: boolean;
|
|
981
|
+
override readonly bitwise: number;
|
|
982
|
+
override readonly droidString: string;
|
|
983
|
+
override readonly droidOnly: boolean;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* Represents the SpunOut mod.
|
|
988
|
+
*/
|
|
989
|
+
export class ModSpunOut extends Mod {
|
|
990
|
+
override readonly scoreMultiplier: number;
|
|
991
|
+
override readonly acronym: string;
|
|
992
|
+
override readonly name: string;
|
|
993
|
+
override readonly droidRanked: boolean;
|
|
994
|
+
override readonly pcRanked: boolean;
|
|
995
|
+
override readonly bitwise: number;
|
|
996
|
+
override readonly droidString: string;
|
|
997
|
+
override readonly droidOnly: boolean;
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* Represents the SuddenDeath mod.
|
|
1002
|
+
*/
|
|
1003
|
+
export class ModSuddenDeath extends Mod {
|
|
1004
|
+
override readonly scoreMultiplier: number;
|
|
1005
|
+
override readonly acronym: string;
|
|
1006
|
+
override readonly name: string;
|
|
1007
|
+
override readonly droidRanked: boolean;
|
|
1008
|
+
override readonly pcRanked: boolean;
|
|
1009
|
+
override readonly bitwise: number;
|
|
1010
|
+
override readonly droidString: string;
|
|
1011
|
+
override readonly droidOnly: boolean;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* Represents the TouchDevice mod.
|
|
1016
|
+
*/
|
|
1017
|
+
export class ModTouchDevice extends Mod {
|
|
1018
|
+
override readonly scoreMultiplier: number;
|
|
1019
|
+
override readonly acronym: string;
|
|
1020
|
+
override readonly name: string;
|
|
1021
|
+
override readonly droidRanked: boolean;
|
|
1022
|
+
override readonly pcRanked: boolean;
|
|
1023
|
+
override readonly bitwise: number;
|
|
1024
|
+
override readonly droidString: string;
|
|
1025
|
+
override readonly droidOnly: boolean;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
/**
|
|
1029
|
+
* Utilities for mods.
|
|
1030
|
+
*/
|
|
1031
|
+
export abstract class ModUtil {
|
|
1032
|
+
/**
|
|
1033
|
+
* Mods that are incompatible with each other.
|
|
1034
|
+
*/
|
|
1035
|
+
static readonly incompatibleMods: Mod[][];
|
|
1036
|
+
/**
|
|
1037
|
+
* All mods that exists.
|
|
1038
|
+
*/
|
|
1039
|
+
static readonly allMods: Mod[];
|
|
1040
|
+
/**
|
|
1041
|
+
* Mods that change the playback speed of a beatmap.
|
|
1042
|
+
*/
|
|
1043
|
+
static readonly speedChangingMods: Mod[];
|
|
1044
|
+
/**
|
|
1045
|
+
* Mods that change the way the map looks.
|
|
1046
|
+
*/
|
|
1047
|
+
static readonly mapChangingMods: Mod[];
|
|
1048
|
+
/**
|
|
1049
|
+
* Gets a list of mods from a droid mod string, such as "hd".
|
|
1050
|
+
*
|
|
1051
|
+
* @param str The string.
|
|
1052
|
+
*/
|
|
1053
|
+
static droidStringToMods(str: string): Mod[];
|
|
1054
|
+
/**
|
|
1055
|
+
* Gets a list of mods from a PC modbits.
|
|
1056
|
+
*
|
|
1057
|
+
* @param modbits The modbits.
|
|
1058
|
+
*/
|
|
1059
|
+
static pcModbitsToMods(modbits: number): Mod[];
|
|
1060
|
+
/**
|
|
1061
|
+
* Gets a list of mods from a PC mod string, such as "HDHR".
|
|
1062
|
+
*
|
|
1063
|
+
* @param str The string.
|
|
1064
|
+
*/
|
|
1065
|
+
static pcStringToMods(str: string): Mod[];
|
|
1066
|
+
/**
|
|
1067
|
+
* Checks for mods that are incompatible with each other.
|
|
1068
|
+
*
|
|
1069
|
+
* @param mods The mods to check for.
|
|
1070
|
+
*/
|
|
1071
|
+
private static checkDuplicateMods(mods: Mod[]): Mod[];
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/**
|
|
1075
|
+
* API request builder for osu!standard.
|
|
1076
|
+
*/
|
|
1077
|
+
export class OsuAPIRequestBuilder extends APIRequestBuilder {
|
|
1078
|
+
protected override readonly host: string;
|
|
1079
|
+
protected override readonly APIkey: string;
|
|
1080
|
+
protected override readonly APIkeyParam: string;
|
|
1081
|
+
override setEndpoint(endpoint: OsuAPIEndpoint): this;
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* Represents the hit window of osu!standard.
|
|
1086
|
+
*/
|
|
1087
|
+
export class OsuHitWindow extends HitWindow {
|
|
1088
|
+
override hitWindowFor300(): number;
|
|
1089
|
+
override hitWindowFor100(): number;
|
|
1090
|
+
override hitWindowFor50(): number;
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/**
|
|
1094
|
+
* A beatmap parser with just enough data for pp calculation.
|
|
1095
|
+
*/
|
|
1096
|
+
export class Parser {
|
|
1097
|
+
/**
|
|
1098
|
+
* The parsed beatmap.
|
|
1099
|
+
*/
|
|
1100
|
+
readonly map: Beatmap;
|
|
1101
|
+
/**
|
|
1102
|
+
* The amount of lines of `.osu` file.
|
|
1103
|
+
*/
|
|
1104
|
+
private line: string;
|
|
1105
|
+
/**
|
|
1106
|
+
* The currently processed line.
|
|
1107
|
+
*/
|
|
1108
|
+
private currentLine: string;
|
|
1109
|
+
/**
|
|
1110
|
+
* The previously processed line.
|
|
1111
|
+
*/
|
|
1112
|
+
private lastPosition: string;
|
|
1113
|
+
/**
|
|
1114
|
+
* The currently processed section.
|
|
1115
|
+
*/
|
|
1116
|
+
private section: string;
|
|
1117
|
+
/**
|
|
1118
|
+
* Parses a beatmap.
|
|
1119
|
+
*
|
|
1120
|
+
* This will process a `.osu` file and returns the current instance of the parser for easy chaining.
|
|
1121
|
+
*
|
|
1122
|
+
* @param str The `.osu` file to parse.
|
|
1123
|
+
* @param mods The mods to parse the beatmap for.
|
|
1124
|
+
*/
|
|
1125
|
+
parse(str: string, mods?: Mod[]): Parser;
|
|
1126
|
+
/**
|
|
1127
|
+
* Logs the line at which an exception occurs.
|
|
1128
|
+
*/
|
|
1129
|
+
private logError(): string;
|
|
1130
|
+
/**
|
|
1131
|
+
* Processes a line of the file.
|
|
1132
|
+
*/
|
|
1133
|
+
private processLine(line: string): Parser;
|
|
1134
|
+
/**
|
|
1135
|
+
* Sets the last position of the current parser state.
|
|
1136
|
+
*
|
|
1137
|
+
* This is useful to debug syntax errors.
|
|
1138
|
+
*/
|
|
1139
|
+
private setPosition(str: string): string;
|
|
1140
|
+
/**
|
|
1141
|
+
* Logs any syntax errors into the console.
|
|
1142
|
+
*/
|
|
1143
|
+
private warn(message: string): void;
|
|
1144
|
+
/**
|
|
1145
|
+
* Processes a property of the beatmap. This takes the current line as parameter.
|
|
1146
|
+
*
|
|
1147
|
+
* For example, `ApproachRate:9` will be split into `[ApproachRate, 9]`.
|
|
1148
|
+
*/
|
|
1149
|
+
private property(): string[];
|
|
1150
|
+
/**
|
|
1151
|
+
* Processes the general section of a beatmap.
|
|
1152
|
+
*/
|
|
1153
|
+
private general(): void;
|
|
1154
|
+
/**
|
|
1155
|
+
* Processes the metadata section of a beatmap.
|
|
1156
|
+
*/
|
|
1157
|
+
private metadata(): void;
|
|
1158
|
+
/**
|
|
1159
|
+
* Processes the events section of a beatmap.
|
|
1160
|
+
*/
|
|
1161
|
+
private events(): void;
|
|
1162
|
+
/**
|
|
1163
|
+
* Processes the difficulty section of a beatmap.
|
|
1164
|
+
*/
|
|
1165
|
+
private difficulty(): void;
|
|
1166
|
+
/**
|
|
1167
|
+
* Processes the timing points section of a beatmap.
|
|
1168
|
+
*/
|
|
1169
|
+
private timingPoints(): void;
|
|
1170
|
+
/**
|
|
1171
|
+
* Processes the objects section of a beatmap.
|
|
1172
|
+
*/
|
|
1173
|
+
private objects(): void;
|
|
1174
|
+
/**
|
|
1175
|
+
* Applies stacking to hitobjects for beatmap version 6 or above.
|
|
1176
|
+
*/
|
|
1177
|
+
private applyStacking(startIndex: number, endIndex: number): void;
|
|
1178
|
+
/**
|
|
1179
|
+
* Applies stacking to hitobjects for beatmap version 5 or below.
|
|
1180
|
+
*/
|
|
1181
|
+
private applyStackingOld(): void;
|
|
1182
|
+
/**
|
|
1183
|
+
* Checks if a number is within a given threshold.
|
|
1184
|
+
*
|
|
1185
|
+
* @param num The number to check.
|
|
1186
|
+
* @param min The minimum threshold. Defaults to `-ParserConstants.MAX_PARSE_VALUE`.
|
|
1187
|
+
* @param max The maximum threshold. Defaults to `ParserConstants.MAX_PARSE_VALUE`.
|
|
1188
|
+
*/
|
|
1189
|
+
private isNumberValid(num: number, min: number, max: number): boolean;
|
|
1190
|
+
/**
|
|
1191
|
+
* Checks if each coordinates of a vector is within a given threshold.
|
|
1192
|
+
*
|
|
1193
|
+
* @param vec The vector to check.
|
|
1194
|
+
* @param limit The threshold. Defaults to `ParserConstants.MAX_COORDINATE_VALUE`.
|
|
1195
|
+
*/
|
|
1196
|
+
private isVectorValid(vec: Vector2, limit: number): boolean;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
/**
|
|
1200
|
+
* Path approximator for sliders.
|
|
1201
|
+
*/
|
|
1202
|
+
export abstract class PathApproximator {
|
|
1203
|
+
private static readonly bezierTolerance: number;
|
|
1204
|
+
/**
|
|
1205
|
+
* The amount of pieces to calculate for each control point quadruplet.
|
|
1206
|
+
*/
|
|
1207
|
+
private static readonly catmullDetail: number;
|
|
1208
|
+
private static readonly circularArcTolerance: number;
|
|
1209
|
+
/**
|
|
1210
|
+
* Approximates a bezier slider's path.
|
|
1211
|
+
*
|
|
1212
|
+
* Creates a piecewise-linear approximation of a bezier curve, by adaptively repeatedly subdividing
|
|
1213
|
+
* the control points until their approximation error vanishes below a given threshold.
|
|
1214
|
+
*
|
|
1215
|
+
* @param controlPoints The anchor points of the slider.
|
|
1216
|
+
*/
|
|
1217
|
+
static approximateBezier(controlPoints: Vector2[]): Vector2[];
|
|
1218
|
+
/**
|
|
1219
|
+
* Approximates a catmull slider's path.
|
|
1220
|
+
*
|
|
1221
|
+
* Creates a piecewise-linear approximation of a Catmull-Rom spline.
|
|
1222
|
+
*
|
|
1223
|
+
* @param controlPoints The anchor points of the slider.
|
|
1224
|
+
*/
|
|
1225
|
+
static approximateCatmull(controlPoints: Vector2[]): Vector2[];
|
|
1226
|
+
/**
|
|
1227
|
+
* Approximates a slider's circular arc.
|
|
1228
|
+
*
|
|
1229
|
+
* Creates a piecewise-linear approximation of a circular arc curve.
|
|
1230
|
+
*
|
|
1231
|
+
* @param controlPoints The anchor points of the slider.
|
|
1232
|
+
*/
|
|
1233
|
+
static approximateCircularArc(controlPoints: Vector2[]): Vector2[];
|
|
1234
|
+
/**
|
|
1235
|
+
* Approximates a linear slider's path.
|
|
1236
|
+
*
|
|
1237
|
+
* Creates a piecewise-linear approximation of a linear curve.
|
|
1238
|
+
* Basically, returns the input.
|
|
1239
|
+
*
|
|
1240
|
+
* @param controlPoints The anchor points of the slider.
|
|
1241
|
+
*/
|
|
1242
|
+
static approximateLinear(controlPoints: Vector2[]): Vector2[];
|
|
1243
|
+
/**
|
|
1244
|
+
* Checks if a bezier slider is flat enough to be approximated.
|
|
1245
|
+
*
|
|
1246
|
+
* Make sure the 2nd order derivative (approximated using finite elements) is within tolerable bounds.
|
|
1247
|
+
*
|
|
1248
|
+
* NOTE: The 2nd order derivative of a 2d curve represents its curvature, so intuitively this function
|
|
1249
|
+
* checks (as the name suggests) whether our approximation is _locally_ "flat". More curvy parts
|
|
1250
|
+
* need to have a denser approximation to be more "flat".
|
|
1251
|
+
*
|
|
1252
|
+
* @param controlPoints The anchor points of the slider.
|
|
1253
|
+
*/
|
|
1254
|
+
private static bezierIsFlatEnough(controlPoints: Vector2[]): void;
|
|
1255
|
+
/**
|
|
1256
|
+
* Approximates a bezier slider's path.
|
|
1257
|
+
*
|
|
1258
|
+
* This uses {@link https://en.wikipedia.org/wiki/De_Casteljau%27s_algorithm De Casteljau's algorithm} to obtain an optimal
|
|
1259
|
+
* piecewise-linear approximation of the bezier curve with the same amount of points as there are control points.
|
|
1260
|
+
*
|
|
1261
|
+
* @param controlPoints The control points describing the bezier curve to be approximated.
|
|
1262
|
+
* @param output The points representing the resulting piecewise-linear approximation.
|
|
1263
|
+
* @param subdivisionBuffer1 The first buffer containing the current subdivision state.
|
|
1264
|
+
* @param subdivisionBuffer2 The second buffer containing the current subdivision state.
|
|
1265
|
+
* @param count The number of control points in the original array.
|
|
1266
|
+
*/
|
|
1267
|
+
private static bezierApproximate(
|
|
1268
|
+
controlPoints: Vector2[],
|
|
1269
|
+
output: Vector2[],
|
|
1270
|
+
subdivisionBuffer1: Vector2[],
|
|
1271
|
+
subdivisionBuffer2: Vector2[],
|
|
1272
|
+
count: number
|
|
1273
|
+
): void;
|
|
1274
|
+
/**
|
|
1275
|
+
* Subdivides `n` control points representing a bezier curve into 2 sets of `n` control points, each
|
|
1276
|
+
* describing a bezier curve equivalent to a half of the original curve. Effectively this splits
|
|
1277
|
+
* the original curve into 2 curves which result in the original curve when pieced back together.
|
|
1278
|
+
*
|
|
1279
|
+
* @param controlPoints The anchor points of the slider.
|
|
1280
|
+
* @param l Parts of the slider for approximation.
|
|
1281
|
+
* @param r Parts of the slider for approximation.
|
|
1282
|
+
* @param subdivisionBuffer Parts of the slider for approximation.
|
|
1283
|
+
* @param count The amount of anchor points in the slider.
|
|
1284
|
+
*/
|
|
1285
|
+
private static bezierSubdivide(
|
|
1286
|
+
controlPoints: Vector2[],
|
|
1287
|
+
l: Vector2[],
|
|
1288
|
+
r: Vector2[],
|
|
1289
|
+
subdivisionBuffer: Vector2[],
|
|
1290
|
+
count: number
|
|
1291
|
+
): void;
|
|
1292
|
+
/**
|
|
1293
|
+
* Finds a point on the spline at the position of a parameter.
|
|
1294
|
+
*
|
|
1295
|
+
* @param vec1 The first vector.
|
|
1296
|
+
* @param vec2 The second vector.
|
|
1297
|
+
* @param vec3 The third vector.
|
|
1298
|
+
* @param vec4 The fourth vector.
|
|
1299
|
+
* @param t The parameter at which to find the point on the spline, in the range [0, 1].
|
|
1300
|
+
*/
|
|
1301
|
+
private static catmullFindPoint(
|
|
1302
|
+
vec1: Vector2,
|
|
1303
|
+
vec2: Vector2,
|
|
1304
|
+
vec3: Vector2,
|
|
1305
|
+
vec4: Vector2,
|
|
1306
|
+
t: number
|
|
1307
|
+
): Vector2;
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* Precision utilities.
|
|
1312
|
+
*/
|
|
1313
|
+
export abstract class Precision {
|
|
1314
|
+
static readonly FLOAT_EPSILON: number;
|
|
1315
|
+
/**
|
|
1316
|
+
* Checks if two numbers are equal with a given tolerance.
|
|
1317
|
+
*
|
|
1318
|
+
* @param value1 The first number.
|
|
1319
|
+
* @param value2 The second number.
|
|
1320
|
+
* @param acceptableDifference The acceptable difference as threshold. Default is `Precision.FLOAT_EPSILON = 1e-3`.
|
|
1321
|
+
*/
|
|
1322
|
+
static almostEqualsNumber(
|
|
1323
|
+
value1: number,
|
|
1324
|
+
value2: number,
|
|
1325
|
+
acceptableDifference?: number
|
|
1326
|
+
): boolean;
|
|
1327
|
+
/**
|
|
1328
|
+
* Checks if two vectors are equal with a given tolerance.
|
|
1329
|
+
*
|
|
1330
|
+
* @param vec1 The first vector.
|
|
1331
|
+
* @param vec2 The second vector.
|
|
1332
|
+
* @param acceptableDifference The acceptable difference as threshold. Default is `Precision.FLOAT_EPSILON = 1e-3`.
|
|
1333
|
+
*/
|
|
1334
|
+
static almostEqualsVector(
|
|
1335
|
+
vec1: Vector2,
|
|
1336
|
+
vec2: Vector2,
|
|
1337
|
+
acceptableDifference?: number
|
|
1338
|
+
): boolean;
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
/**
|
|
1342
|
+
* Represents a repeat point in a slider.
|
|
1343
|
+
*/
|
|
1344
|
+
export class RepeatPoint extends HitObject {
|
|
1345
|
+
/**
|
|
1346
|
+
* The index of the repeat point.
|
|
1347
|
+
*/
|
|
1348
|
+
readonly repeatIndex: number;
|
|
1349
|
+
/**
|
|
1350
|
+
* The duration of the repeat point.
|
|
1351
|
+
*/
|
|
1352
|
+
readonly spanDuration: number;
|
|
1353
|
+
constructor(values: {
|
|
1354
|
+
position: Vector2;
|
|
1355
|
+
startTime: number;
|
|
1356
|
+
repeatIndex: number;
|
|
1357
|
+
spanDuration: number;
|
|
1358
|
+
});
|
|
1359
|
+
override toString(): string;
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
/**
|
|
1363
|
+
* Represents a slider in a beatmap.
|
|
1364
|
+
*/
|
|
1365
|
+
export class Slider extends HitObject {
|
|
1366
|
+
/**
|
|
1367
|
+
* The nested hitobjects of the slider. Consists of headcircle (sliderhead), slider ticks, repeat points, and tailcircle (sliderend).
|
|
1368
|
+
*/
|
|
1369
|
+
readonly nestedHitObjects: HitObject[];
|
|
1370
|
+
/**
|
|
1371
|
+
* The slider's path.
|
|
1372
|
+
*/
|
|
1373
|
+
readonly path: SliderPath;
|
|
1374
|
+
/**
|
|
1375
|
+
* The slider's velocity.
|
|
1376
|
+
*/
|
|
1377
|
+
readonly velocity: number;
|
|
1378
|
+
/**
|
|
1379
|
+
* The spacing between slider ticks of this slider.
|
|
1380
|
+
*/
|
|
1381
|
+
readonly tickDistance: number;
|
|
1382
|
+
/**
|
|
1383
|
+
* The position of the cursor at the point of completion of this slider if it was hit
|
|
1384
|
+
* with as few movements as possible. This is set and used by difficulty calculation.
|
|
1385
|
+
*/
|
|
1386
|
+
lazyEndPosition?: Vector2;
|
|
1387
|
+
/**
|
|
1388
|
+
* The distance travelled by the cursor upon completion of this slider if it was hit
|
|
1389
|
+
* with as few movements as possible. This is set and used by difficulty calculation.
|
|
1390
|
+
*/
|
|
1391
|
+
lazyTravelDistance: number;
|
|
1392
|
+
/**
|
|
1393
|
+
* The time taken by the cursor upon completion of this slider if it was hit with
|
|
1394
|
+
* as few movements as possible. This is set and used by difficulty calculation.
|
|
1395
|
+
*/
|
|
1396
|
+
lazyTravelTime: number;
|
|
1397
|
+
/**
|
|
1398
|
+
* The length of one span of this slider.
|
|
1399
|
+
*/
|
|
1400
|
+
readonly spanDuration: number;
|
|
1401
|
+
/**
|
|
1402
|
+
* The slider's head (sliderhead).
|
|
1403
|
+
*/
|
|
1404
|
+
readonly headCircle: HeadCircle;
|
|
1405
|
+
/**
|
|
1406
|
+
* The slider's tail (sliderend).
|
|
1407
|
+
*/
|
|
1408
|
+
readonly tailCircle: TailCircle;
|
|
1409
|
+
/**
|
|
1410
|
+
* The duration of this slider.
|
|
1411
|
+
*/
|
|
1412
|
+
get duration(): number;
|
|
1413
|
+
/**
|
|
1414
|
+
* The amount of slider ticks in this slider.
|
|
1415
|
+
*/
|
|
1416
|
+
get ticks(): number;
|
|
1417
|
+
/**
|
|
1418
|
+
* The amount of repeat points in this slider.
|
|
1419
|
+
*/
|
|
1420
|
+
get repeatPoints(): number;
|
|
1421
|
+
/**
|
|
1422
|
+
* The repetition amount of the slider. Note that 1 repetition means no repeats (1 loop).
|
|
1423
|
+
*/
|
|
1424
|
+
private readonly repetitions: number;
|
|
1425
|
+
static readonly legacyLastTickOffset: number;
|
|
1426
|
+
constructor(values: {
|
|
1427
|
+
startTime: number;
|
|
1428
|
+
type: number;
|
|
1429
|
+
position: Vector2;
|
|
1430
|
+
repetitions: number;
|
|
1431
|
+
path: SliderPath;
|
|
1432
|
+
speedMultiplier: number;
|
|
1433
|
+
msPerBeat: number;
|
|
1434
|
+
mapSliderVelocity: number;
|
|
1435
|
+
mapTickRate: number;
|
|
1436
|
+
tickDistanceMultiplier: number;
|
|
1437
|
+
});
|
|
1438
|
+
override toString(): string;
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
/**
|
|
1442
|
+
* Represents a slider's path.
|
|
1443
|
+
*/
|
|
1444
|
+
export class SliderPath {
|
|
1445
|
+
/**
|
|
1446
|
+
* The path type of the slider.
|
|
1447
|
+
*/
|
|
1448
|
+
readonly pathType: PathType;
|
|
1449
|
+
/**
|
|
1450
|
+
* The control points (anchor points) of the slider.
|
|
1451
|
+
*/
|
|
1452
|
+
readonly controlPoints: Vector2[];
|
|
1453
|
+
/**
|
|
1454
|
+
* Distance that is expected when calculating slider path.
|
|
1455
|
+
*/
|
|
1456
|
+
readonly expectedDistance: number;
|
|
1457
|
+
/**
|
|
1458
|
+
* Whether or not the instance has been initialized.
|
|
1459
|
+
*/
|
|
1460
|
+
isInitialized: boolean;
|
|
1461
|
+
/**
|
|
1462
|
+
* The calculated path of the slider.
|
|
1463
|
+
*/
|
|
1464
|
+
readonly calculatedPath: Vector2[];
|
|
1465
|
+
/**
|
|
1466
|
+
* The cumulative length of the slider.
|
|
1467
|
+
*/
|
|
1468
|
+
readonly cumulativeLength: number[];
|
|
1469
|
+
/**
|
|
1470
|
+
* The path approximator of the slider.
|
|
1471
|
+
*/
|
|
1472
|
+
readonly pathApproximator: PathApproximator;
|
|
1473
|
+
constructor(values: {
|
|
1474
|
+
/**
|
|
1475
|
+
* The path type of the slider.
|
|
1476
|
+
*/
|
|
1477
|
+
pathType: PathType;
|
|
1478
|
+
/**
|
|
1479
|
+
* The anchor points of the slider.
|
|
1480
|
+
*/
|
|
1481
|
+
controlPoints: Vector2[];
|
|
1482
|
+
/**
|
|
1483
|
+
* The distance that is expected when calculating slider path.
|
|
1484
|
+
*/
|
|
1485
|
+
expectedDistance: number;
|
|
1486
|
+
});
|
|
1487
|
+
/**
|
|
1488
|
+
* Initializes the instance.
|
|
1489
|
+
*/
|
|
1490
|
+
ensureInitialized(): void;
|
|
1491
|
+
/**
|
|
1492
|
+
* Calculates the slider's path.
|
|
1493
|
+
*/
|
|
1494
|
+
calculatePath(): void;
|
|
1495
|
+
/**
|
|
1496
|
+
* Calculates the slider's subpath.
|
|
1497
|
+
*/
|
|
1498
|
+
calculateSubPath(subControlPoints: Vector2[]): Vector2[];
|
|
1499
|
+
/**
|
|
1500
|
+
* Calculates the slider's cumulative length.
|
|
1501
|
+
*/
|
|
1502
|
+
calculateCumulativeLength(): void;
|
|
1503
|
+
/**
|
|
1504
|
+
* Computes the position on the slider at a given progress that ranges from 0 (beginning of the path)
|
|
1505
|
+
* to 1 (end of the path).
|
|
1506
|
+
*
|
|
1507
|
+
* @param progress Ranges from 0 (beginning of the path) to 1 (end of the path).
|
|
1508
|
+
*/
|
|
1509
|
+
positionAt(progress: number): Vector2;
|
|
1510
|
+
/**
|
|
1511
|
+
* Returns the progress of reaching expected distance.
|
|
1512
|
+
*/
|
|
1513
|
+
private progressToDistance(progress: number): number;
|
|
1514
|
+
/**
|
|
1515
|
+
* Interpolates verticles of the slider.
|
|
1516
|
+
*/
|
|
1517
|
+
private interpolateVerticles(i: number, d: number): Vector2;
|
|
1518
|
+
/**
|
|
1519
|
+
* Returns the index of distance.
|
|
1520
|
+
*/
|
|
1521
|
+
private indexOfDistance(d: number): number;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
/**
|
|
1525
|
+
* Represents a slider tick in a slider.
|
|
1526
|
+
*/
|
|
1527
|
+
export class SliderTick extends HitObject {
|
|
1528
|
+
/**
|
|
1529
|
+
* The index of the slider tick.
|
|
1530
|
+
*/
|
|
1531
|
+
readonly spanIndex: number;
|
|
1532
|
+
/**
|
|
1533
|
+
* The start time of the slider tick.
|
|
1534
|
+
*/
|
|
1535
|
+
readonly spanStartTime: number;
|
|
1536
|
+
constructor(values: {
|
|
1537
|
+
position: Vector2;
|
|
1538
|
+
startTime: number;
|
|
1539
|
+
spanIndex: number;
|
|
1540
|
+
spanStartTime: number;
|
|
1541
|
+
});
|
|
1542
|
+
override toString(): string;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
/**
|
|
1546
|
+
* Represents a spinner in a beatmap.
|
|
1547
|
+
*
|
|
1548
|
+
* All we need from spinners is their duration. The
|
|
1549
|
+
* position of a spinner is always at 256x192.
|
|
1550
|
+
*/
|
|
1551
|
+
export class Spinner extends HitObject {
|
|
1552
|
+
/**
|
|
1553
|
+
* The duration of the spinner.
|
|
1554
|
+
*/
|
|
1555
|
+
readonly duration: number;
|
|
1556
|
+
constructor(values: {
|
|
1557
|
+
startTime: number;
|
|
1558
|
+
type: number;
|
|
1559
|
+
duration: number;
|
|
1560
|
+
});
|
|
1561
|
+
override toString(): string;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
/**
|
|
1565
|
+
* Represents the tailcircle of a slider (sliderend).
|
|
1566
|
+
*/
|
|
1567
|
+
export class TailCircle extends Circle { }
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* Represents a timing point that changes the beatmap's BPM.
|
|
1571
|
+
*/
|
|
1572
|
+
export class TimingControlPoint extends TimingPoint {
|
|
1573
|
+
/**
|
|
1574
|
+
* The amount of milliseconds passed for each beat.
|
|
1575
|
+
*/
|
|
1576
|
+
readonly msPerBeat: number;
|
|
1577
|
+
constructor(values: { time: number; msPerBeat: number });
|
|
1578
|
+
override toString(): string;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
/**
|
|
1582
|
+
* Based on `Vector2` class in C#.
|
|
1583
|
+
*/
|
|
1584
|
+
export class Vector2 {
|
|
1585
|
+
/**
|
|
1586
|
+
* The x position of the vector.
|
|
1587
|
+
*/
|
|
1588
|
+
x: number;
|
|
1589
|
+
/**
|
|
1590
|
+
* The y position of the vector.
|
|
1591
|
+
*/
|
|
1592
|
+
y: number;
|
|
1593
|
+
/**
|
|
1594
|
+
* @param x The x position of the vector.
|
|
1595
|
+
* @param y The y position of the vector.
|
|
1596
|
+
*/
|
|
1597
|
+
constructor(x: number, y: number);
|
|
1598
|
+
/**
|
|
1599
|
+
* Multiplies the vector with another vector.
|
|
1600
|
+
*/
|
|
1601
|
+
multiply(vec: Vector2): Vector2;
|
|
1602
|
+
divide(divideFactor: number): Vector2;
|
|
1603
|
+
/**
|
|
1604
|
+
* Adds the vector with another vector.
|
|
1605
|
+
*/
|
|
1606
|
+
add(vec: Vector2): Vector2;
|
|
1607
|
+
/**
|
|
1608
|
+
* Subtracts the vector with another vector.
|
|
1609
|
+
*/
|
|
1610
|
+
subtract(vec: Vector2): Vector2;
|
|
1611
|
+
/**
|
|
1612
|
+
* The length of the vector.
|
|
1613
|
+
*/
|
|
1614
|
+
get length(): number;
|
|
1615
|
+
/**
|
|
1616
|
+
* Performs a dot multiplication with another vector.
|
|
1617
|
+
*/
|
|
1618
|
+
dot(vec: Vector2): number;
|
|
1619
|
+
/**
|
|
1620
|
+
* Scales the vector.
|
|
1621
|
+
*/
|
|
1622
|
+
scale(scaleFactor: number): Vector2;
|
|
1623
|
+
/**
|
|
1624
|
+
* Gets the distance between this vector and another vector.
|
|
1625
|
+
*/
|
|
1626
|
+
getDistance(vec: Vector2): number;
|
|
1627
|
+
/**
|
|
1628
|
+
* Normalizes the vector.
|
|
1629
|
+
*/
|
|
1630
|
+
normalize(): void;
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
/**
|
|
1634
|
+
* Some utilities, no biggie.
|
|
1635
|
+
*/
|
|
1636
|
+
export abstract class Utils {
|
|
1637
|
+
/**
|
|
1638
|
+
* Returns a random element of an array.
|
|
1639
|
+
*
|
|
1640
|
+
* @param array The array to get the element from.
|
|
1641
|
+
*/
|
|
1642
|
+
static getRandomArrayElement<T>(array: T[]): T;
|
|
1643
|
+
/**
|
|
1644
|
+
* Deep copies an instance.
|
|
1645
|
+
*
|
|
1646
|
+
* @param instance The instance to deep copy.
|
|
1647
|
+
*/
|
|
1648
|
+
static deepCopy<T>(instance: T): T;
|
|
1649
|
+
/**
|
|
1650
|
+
* Creates an array with specific length that's prefilled with an initial value.
|
|
1651
|
+
*
|
|
1652
|
+
* @param length The length of the array.
|
|
1653
|
+
* @param initialValue The initial value of each array value.
|
|
1654
|
+
*/
|
|
1655
|
+
static initializeArray<T>(length: number, initialValue?: T): T[];
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
//#endregion
|
|
1659
|
+
|
|
1660
|
+
//#region Enums
|
|
1661
|
+
|
|
1662
|
+
/**
|
|
1663
|
+
* Mode enum to switch things between osu!droid and osu!standard.
|
|
1664
|
+
*/
|
|
1665
|
+
export enum modes {
|
|
1666
|
+
droid = "droid",
|
|
1667
|
+
osu = "osu",
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1670
|
+
/**
|
|
1671
|
+
* Bitmask constant of object types. This is needed as osu! uses bits to determine object types.
|
|
1672
|
+
*/
|
|
1673
|
+
export enum objectTypes {
|
|
1674
|
+
circle = 1 << 0,
|
|
1675
|
+
slider = 1 << 1,
|
|
1676
|
+
spinner = 1 << 3,
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
/**
|
|
1680
|
+
* Constants for beatmap parser.
|
|
1681
|
+
*/
|
|
1682
|
+
export enum ParserConstants {
|
|
1683
|
+
MAX_PARSE_VALUE = 2147483647,
|
|
1684
|
+
MAX_COORDINATE_VALUE = 131072,
|
|
1685
|
+
MIN_REPETITIONS_VALUE = 0,
|
|
1686
|
+
MAX_REPETITIONS_VALUE = 9000,
|
|
1687
|
+
MIN_DISTANCE_VALUE = 0,
|
|
1688
|
+
MAX_DISTANCE_VALUE = 131072,
|
|
1689
|
+
MIN_SPEEDMULTIPLIER_VALUE = 0.1,
|
|
1690
|
+
MAX_SPEEDMULTIPLIER_VALUE = 10,
|
|
1691
|
+
MIN_MSPERBEAT_VALUE = 6,
|
|
1692
|
+
MAX_MSPERBEAT_VALUE = 60000,
|
|
1693
|
+
}
|
|
1694
|
+
|
|
1695
|
+
/**
|
|
1696
|
+
* Types of slider paths.
|
|
1697
|
+
*/
|
|
1698
|
+
export enum PathType {
|
|
1699
|
+
Catmull = 0,
|
|
1700
|
+
Bezier = 1,
|
|
1701
|
+
Linear = 2,
|
|
1702
|
+
PerfectCurve = 3,
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
/**
|
|
1706
|
+
* Ranking status of a beatmap.
|
|
1707
|
+
*/
|
|
1708
|
+
export enum rankedStatus {
|
|
1709
|
+
GRAVEYARD = -2,
|
|
1710
|
+
WIP = -1,
|
|
1711
|
+
PENDING = 0,
|
|
1712
|
+
RANKED = 1,
|
|
1713
|
+
APPROVED = 2,
|
|
1714
|
+
QUALIFIED = 3,
|
|
1715
|
+
LOVED = 4,
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
//#endregion
|
|
1719
|
+
|
|
1720
|
+
//#region Interfaces
|
|
1721
|
+
|
|
1722
|
+
/**
|
|
1723
|
+
* Information about an accuracy value.
|
|
1724
|
+
*/
|
|
1725
|
+
export interface AccuracyInformation {
|
|
1726
|
+
/**
|
|
1727
|
+
* The amount of objects in the beatmap.
|
|
1728
|
+
*/
|
|
1729
|
+
nobjects?: number;
|
|
1730
|
+
/**
|
|
1731
|
+
* The accuracy achieved.
|
|
1732
|
+
*/
|
|
1733
|
+
percent?: number;
|
|
1734
|
+
/**
|
|
1735
|
+
* The amount of 300s achieved.
|
|
1736
|
+
*/
|
|
1737
|
+
n300?: number;
|
|
1738
|
+
/**
|
|
1739
|
+
* The amount of 100s achieved.
|
|
1740
|
+
*/
|
|
1741
|
+
n100?: number;
|
|
1742
|
+
/**
|
|
1743
|
+
* The amount of 50s achieved.
|
|
1744
|
+
*/
|
|
1745
|
+
n50?: number;
|
|
1746
|
+
/**
|
|
1747
|
+
* The amount of misses achieved.
|
|
1748
|
+
*/
|
|
1749
|
+
nmiss?: number;
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1752
|
+
/**
|
|
1753
|
+
* Represents a `get_beatmaps` response from osu! API.
|
|
1754
|
+
*/
|
|
1755
|
+
export interface OsuAPIResponse {
|
|
1756
|
+
readonly approved: string;
|
|
1757
|
+
readonly submit_date: string;
|
|
1758
|
+
readonly approved_date: string;
|
|
1759
|
+
readonly last_update: string;
|
|
1760
|
+
readonly artist: string;
|
|
1761
|
+
readonly beatmap_id: string;
|
|
1762
|
+
readonly beatmapset_id: string;
|
|
1763
|
+
readonly bpm: string;
|
|
1764
|
+
readonly creator: string;
|
|
1765
|
+
readonly creator_id: string;
|
|
1766
|
+
readonly difficultyrating?: string;
|
|
1767
|
+
readonly diff_aim?: string;
|
|
1768
|
+
readonly diff_speed?: string;
|
|
1769
|
+
readonly diff_size: string;
|
|
1770
|
+
readonly diff_overall: string;
|
|
1771
|
+
readonly diff_approach: string;
|
|
1772
|
+
readonly diff_drain: string;
|
|
1773
|
+
readonly hit_length: string;
|
|
1774
|
+
readonly source: string;
|
|
1775
|
+
readonly genre_id: string;
|
|
1776
|
+
readonly language_id: string;
|
|
1777
|
+
readonly title: string;
|
|
1778
|
+
readonly total_length: string;
|
|
1779
|
+
readonly version: string;
|
|
1780
|
+
readonly file_md5: string;
|
|
1781
|
+
readonly mode: string;
|
|
1782
|
+
readonly tags: string;
|
|
1783
|
+
readonly favourite_count: string;
|
|
1784
|
+
readonly rating: string;
|
|
1785
|
+
readonly playcount: string;
|
|
1786
|
+
readonly passcount: string;
|
|
1787
|
+
readonly count_normal: string;
|
|
1788
|
+
readonly count_slider: string;
|
|
1789
|
+
readonly count_spinner: string;
|
|
1790
|
+
readonly max_combo: string;
|
|
1791
|
+
readonly storyboard: string;
|
|
1792
|
+
readonly video: string;
|
|
1793
|
+
readonly download_unavailable: string;
|
|
1794
|
+
readonly audio_unavailable: string;
|
|
1795
|
+
readonly packs?: string;
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1798
|
+
/**
|
|
1799
|
+
* Represents a response from an API request.
|
|
1800
|
+
*/
|
|
1801
|
+
export interface RequestResponse {
|
|
1802
|
+
/**
|
|
1803
|
+
* The result of the API request.
|
|
1804
|
+
*/
|
|
1805
|
+
readonly data: Buffer;
|
|
1806
|
+
/**
|
|
1807
|
+
* The status code of the API request.
|
|
1808
|
+
*/
|
|
1809
|
+
readonly statusCode: number;
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
//#endregion
|
|
1813
|
+
|
|
1814
|
+
//#region Types
|
|
1815
|
+
|
|
1816
|
+
export type DroidAPIEndpoint =
|
|
1817
|
+
| "banscore.php"
|
|
1818
|
+
| "getuserinfo.php"
|
|
1819
|
+
| "scoresearch.php"
|
|
1820
|
+
| "scoresearchv2.php"
|
|
1821
|
+
| "rename.php"
|
|
1822
|
+
| "upload"
|
|
1823
|
+
| "user_list.php"
|
|
1824
|
+
| "usergeneral.php"
|
|
1825
|
+
| "top.php"
|
|
1826
|
+
| "time.php";
|
|
1827
|
+
|
|
1828
|
+
export type OsuAPIEndpoint =
|
|
1829
|
+
| "get_beatmaps"
|
|
1830
|
+
| "get_user"
|
|
1831
|
+
| "get_scores"
|
|
1832
|
+
| "get_user_best"
|
|
1833
|
+
| "get_user_recent"
|
|
1834
|
+
| "get_match"
|
|
1835
|
+
| "get_replay";
|
|
1836
|
+
|
|
1837
|
+
//#endregion
|
|
1838
|
+
|
|
1839
|
+
//#region Unexported classes
|
|
1840
|
+
|
|
1841
|
+
abstract class APIRequestBuilder {
|
|
1842
|
+
/**
|
|
1843
|
+
* The main point of API host.
|
|
1844
|
+
*/
|
|
1845
|
+
protected abstract readonly host: string;
|
|
1846
|
+
/**
|
|
1847
|
+
* The API key for this builder.
|
|
1848
|
+
*/
|
|
1849
|
+
protected abstract readonly APIkey: string;
|
|
1850
|
+
/**
|
|
1851
|
+
* The parameter for API key requests.
|
|
1852
|
+
*/
|
|
1853
|
+
protected abstract readonly APIkeyParam: string;
|
|
1854
|
+
/**
|
|
1855
|
+
* Whether or not to include the API key in the request URL.
|
|
1856
|
+
*/
|
|
1857
|
+
protected requiresAPIkey: boolean;
|
|
1858
|
+
/**
|
|
1859
|
+
* The endpoint of this builder.
|
|
1860
|
+
*/
|
|
1861
|
+
protected endpoint: DroidAPIEndpoint | OsuAPIEndpoint | string;
|
|
1862
|
+
/**
|
|
1863
|
+
* The parameters of this builder.
|
|
1864
|
+
*/
|
|
1865
|
+
protected readonly params: Map<string, string | number>;
|
|
1866
|
+
private fetchAttempts: number;
|
|
1867
|
+
/**
|
|
1868
|
+
* Sets the API endpoint.
|
|
1869
|
+
*
|
|
1870
|
+
* @param endpoint The endpoint to set.
|
|
1871
|
+
*/
|
|
1872
|
+
abstract setEndpoint(endpoint: DroidAPIEndpoint | OsuAPIEndpoint): this;
|
|
1873
|
+
/**
|
|
1874
|
+
* Sets if this builder includes the API key in the request URL.
|
|
1875
|
+
*
|
|
1876
|
+
* @param requireAPIkey Whether or not to include the API key in the request URL.
|
|
1877
|
+
*/
|
|
1878
|
+
setRequireAPIkey(requireAPIkey: boolean): this;
|
|
1879
|
+
/**
|
|
1880
|
+
* Builds the URL to request the API.
|
|
1881
|
+
*/
|
|
1882
|
+
buildURL(): string;
|
|
1883
|
+
/**
|
|
1884
|
+
* Sends a request to the API using built parameters.
|
|
1885
|
+
*
|
|
1886
|
+
* If the request fails, it will be redone 5 times.
|
|
1887
|
+
*/
|
|
1888
|
+
sendRequest(): Promise<RequestResponse>;
|
|
1889
|
+
/**
|
|
1890
|
+
* Adds a parameter to the builder.
|
|
1891
|
+
*
|
|
1892
|
+
* @param param The parameter to add.
|
|
1893
|
+
* @param value The value to add for the parameter.
|
|
1894
|
+
*/
|
|
1895
|
+
addParameter(param: string, value: string | number): this;
|
|
1896
|
+
/**
|
|
1897
|
+
* Removes a parameter from the builder.
|
|
1898
|
+
*
|
|
1899
|
+
* @param param The parameter to remove.
|
|
1900
|
+
*/
|
|
1901
|
+
removeParameter(param: string): this;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
abstract class HitWindow {
|
|
1905
|
+
/**
|
|
1906
|
+
* The overall difficulty of this hit window.
|
|
1907
|
+
*/
|
|
1908
|
+
readonly overallDifficulty: number;
|
|
1909
|
+
/**
|
|
1910
|
+
* Gets the threshold for 300 (great) hit result.
|
|
1911
|
+
*
|
|
1912
|
+
* @param isPrecise Whether or not to calculate for Precise mod. This is only available for `DroidHitWindow`.
|
|
1913
|
+
*/
|
|
1914
|
+
abstract hitWindowFor300(isPrecise?: boolean): number;
|
|
1915
|
+
/**
|
|
1916
|
+
* Gets the threshold for 100 (good) hit result.
|
|
1917
|
+
*
|
|
1918
|
+
* @param isPrecise Whether or not to calculate for Precise mod. This is only available for `DroidHitWindow`.
|
|
1919
|
+
*/
|
|
1920
|
+
abstract hitWindowFor100(isPrecise?: boolean): number;
|
|
1921
|
+
/**
|
|
1922
|
+
* Gets the threshold for 50 (meh) hit result.
|
|
1923
|
+
*
|
|
1924
|
+
* @param isPrecise Whether or not to calculate for Precise mod. This is only available for `DroidHitWindow`.
|
|
1925
|
+
*/
|
|
1926
|
+
abstract hitWindowFor50(isPrecise?: boolean): number;
|
|
1927
|
+
constructor(overallDifficulty: number);
|
|
1928
|
+
}
|
|
1929
|
+
|
|
1930
|
+
/**
|
|
1931
|
+
* Represents a timing point in a beatmap.
|
|
1932
|
+
*/
|
|
1933
|
+
abstract class TimingPoint {
|
|
1934
|
+
/**
|
|
1935
|
+
* The time at which the timing point takes effect in milliseconds.
|
|
1936
|
+
*/
|
|
1937
|
+
readonly time: number;
|
|
1938
|
+
constructor(values: {
|
|
1939
|
+
/**
|
|
1940
|
+
* The time at which the timing point takes effect in milliseconds.
|
|
1941
|
+
*/
|
|
1942
|
+
time: number;
|
|
1943
|
+
});
|
|
1944
|
+
/**
|
|
1945
|
+
* Returns a string representative of the class.
|
|
1946
|
+
*/
|
|
1947
|
+
abstract toString(): string;
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
//#endregion
|
|
1951
|
+
}
|