@rian8337/osu-base 4.0.0-beta.86 → 4.0.0-beta.88
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1714 -1005
- package/package.json +2 -2
- package/typings/index.d.ts +2557 -2221
package/dist/index.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Mode enum to switch things between osu!droid and osu!standard.
|
|
5
|
+
*/
|
|
6
|
+
exports.Modes = void 0;
|
|
7
|
+
(function (Modes) {
|
|
8
|
+
Modes["droid"] = "droid";
|
|
9
|
+
Modes["osu"] = "osu";
|
|
10
|
+
})(exports.Modes || (exports.Modes = {}));
|
|
11
|
+
|
|
3
12
|
/**
|
|
4
13
|
* Some math utility functions.
|
|
5
14
|
*/
|
|
@@ -216,230 +225,29 @@ class MathUtils {
|
|
|
216
225
|
}
|
|
217
226
|
|
|
218
227
|
/**
|
|
219
|
-
*
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Calculates accuracy based on given parameters.
|
|
224
|
-
*
|
|
225
|
-
* If `percent` and `nobjects` are specified, `n300`, `n100`, and `n50` will
|
|
226
|
-
* be automatically calculated to be the closest to the given
|
|
227
|
-
* acc percent.
|
|
228
|
-
*
|
|
229
|
-
* @param values Function parameters.
|
|
230
|
-
*/
|
|
231
|
-
constructor(values) {
|
|
232
|
-
var _a, _b, _c, _d;
|
|
233
|
-
this.nmiss = (_a = values.nmiss) !== null && _a !== void 0 ? _a : 0;
|
|
234
|
-
this.n300 = (_b = values.n300) !== null && _b !== void 0 ? _b : -1;
|
|
235
|
-
this.n100 = (_c = values.n100) !== null && _c !== void 0 ? _c : 0;
|
|
236
|
-
this.n50 = (_d = values.n50) !== null && _d !== void 0 ? _d : 0;
|
|
237
|
-
let nobjects;
|
|
238
|
-
if (values.nobjects) {
|
|
239
|
-
let n300 = this.n300;
|
|
240
|
-
nobjects = values.nobjects;
|
|
241
|
-
let hitcount;
|
|
242
|
-
if (n300 < 0) {
|
|
243
|
-
n300 = Math.max(0, nobjects - this.n100 - this.n50 - this.nmiss);
|
|
244
|
-
}
|
|
245
|
-
hitcount = n300 + this.n100 + this.n50 + this.nmiss;
|
|
246
|
-
if (hitcount > nobjects) {
|
|
247
|
-
n300 -= Math.min(n300, hitcount - nobjects);
|
|
248
|
-
}
|
|
249
|
-
hitcount = n300 + this.n100 + this.n50 + this.nmiss;
|
|
250
|
-
if (hitcount > nobjects) {
|
|
251
|
-
this.n100 -= Math.min(this.n100, hitcount - nobjects);
|
|
252
|
-
}
|
|
253
|
-
hitcount = n300 + this.n100 + this.n50 + this.nmiss;
|
|
254
|
-
if (hitcount > nobjects) {
|
|
255
|
-
this.n50 -= Math.min(this.n50, hitcount - nobjects);
|
|
256
|
-
}
|
|
257
|
-
hitcount = n300 + this.n100 + this.n50 + this.nmiss;
|
|
258
|
-
if (hitcount > nobjects) {
|
|
259
|
-
this.nmiss -= Math.min(this.nmiss, hitcount - nobjects);
|
|
260
|
-
}
|
|
261
|
-
this.n300 = nobjects - this.n100 - this.n50 - this.nmiss;
|
|
262
|
-
}
|
|
263
|
-
if (values.percent) {
|
|
264
|
-
if (!values.nobjects) {
|
|
265
|
-
throw new TypeError("nobjects is required when specifying percent");
|
|
266
|
-
}
|
|
267
|
-
nobjects = values.nobjects;
|
|
268
|
-
const max300 = nobjects - this.nmiss;
|
|
269
|
-
const maxacc = new Accuracy({
|
|
270
|
-
n300: max300,
|
|
271
|
-
n100: 0,
|
|
272
|
-
n50: 0,
|
|
273
|
-
nmiss: this.nmiss,
|
|
274
|
-
}).value() * 100;
|
|
275
|
-
let acc_percent = values.percent;
|
|
276
|
-
acc_percent = Math.max(0, Math.min(maxacc, acc_percent));
|
|
277
|
-
// just some black magic maths from wolfram alpha
|
|
278
|
-
this.n100 = Math.round(-3 * ((acc_percent * 0.01 - 1) * nobjects + this.nmiss) * 0.5);
|
|
279
|
-
if (this.n100 > max300) {
|
|
280
|
-
// acc lower than all 100s, use 50s
|
|
281
|
-
this.n100 = 0;
|
|
282
|
-
this.n50 = Math.round(-6 *
|
|
283
|
-
((acc_percent * 0.01 - 1) * nobjects + this.nmiss) *
|
|
284
|
-
0.5);
|
|
285
|
-
this.n50 = Math.min(max300, this.n50);
|
|
286
|
-
}
|
|
287
|
-
this.n300 = nobjects - this.n100 - this.n50 - this.nmiss;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Calculates the accuracy value (0.0 - 1.0).
|
|
292
|
-
*
|
|
293
|
-
* @param nobjects The amount of objects in the beatmap. If `n300` was not specified in the constructor, this is required.
|
|
294
|
-
*/
|
|
295
|
-
value(nobjects) {
|
|
296
|
-
let n300 = this.n300;
|
|
297
|
-
if (n300 < 0) {
|
|
298
|
-
if (!nobjects) {
|
|
299
|
-
throw new TypeError("Either n300 or nobjects must be specified");
|
|
300
|
-
}
|
|
301
|
-
n300 = nobjects - this.n100 - this.n50 - this.nmiss;
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
nobjects !== null && nobjects !== void 0 ? nobjects : (nobjects = n300 + this.n100 + this.n50 + this.nmiss);
|
|
305
|
-
}
|
|
306
|
-
const res = (n300 * 6 + this.n100 * 2 + this.n50) / (nobjects * 6);
|
|
307
|
-
return MathUtils.clamp(res, 0, 1);
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Determines whether this accuracy instance is equal to another instance.
|
|
311
|
-
*
|
|
312
|
-
* @param other The other accuracy instance.
|
|
313
|
-
* @returns Whether both instances are equal.
|
|
314
|
-
*/
|
|
315
|
-
equals(other) {
|
|
316
|
-
return (this.n300 === other.n300 &&
|
|
317
|
-
this.n100 === other.n100 &&
|
|
318
|
-
this.n50 === other.n50 &&
|
|
319
|
-
this.nmiss === other.nmiss);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* General enum to specify an "anchor" or "origin" point from the standard 9 points on a rectangle.
|
|
325
|
-
*/
|
|
326
|
-
exports.Anchor = void 0;
|
|
327
|
-
(function (Anchor) {
|
|
328
|
-
Anchor["topLeft"] = "TopLeft";
|
|
329
|
-
Anchor["center"] = "Centre";
|
|
330
|
-
Anchor["centerLeft"] = "CentreLeft";
|
|
331
|
-
Anchor["topRight"] = "TopRight";
|
|
332
|
-
Anchor["bottomCenter"] = "BottomCentre";
|
|
333
|
-
Anchor["topCenter"] = "TopCentre";
|
|
334
|
-
/**
|
|
335
|
-
* The user is manually updating the outcome, so we shouldn't.
|
|
336
|
-
*/
|
|
337
|
-
Anchor["custom"] = "Custom";
|
|
338
|
-
Anchor["centerRight"] = "CentreRight";
|
|
339
|
-
Anchor["bottomLeft"] = "BottomLeft";
|
|
340
|
-
Anchor["bottomRight"] = "BottomRight";
|
|
341
|
-
})(exports.Anchor || (exports.Anchor = {}));
|
|
342
|
-
|
|
343
|
-
/**
|
|
344
|
-
* Defines available axes.
|
|
228
|
+
* The result of a hit.
|
|
229
|
+
*
|
|
230
|
+
* Underlying numbers mirror values in an osu!droid replay.
|
|
345
231
|
*/
|
|
346
|
-
exports.
|
|
347
|
-
(function (
|
|
232
|
+
exports.HitResult = void 0;
|
|
233
|
+
(function (HitResult) {
|
|
348
234
|
/**
|
|
349
|
-
*
|
|
235
|
+
* Miss (0).
|
|
350
236
|
*/
|
|
351
|
-
|
|
237
|
+
HitResult[HitResult["miss"] = 1] = "miss";
|
|
352
238
|
/**
|
|
353
|
-
*
|
|
239
|
+
* Meh (50).
|
|
354
240
|
*/
|
|
355
|
-
|
|
241
|
+
HitResult[HitResult["meh"] = 2] = "meh";
|
|
356
242
|
/**
|
|
357
|
-
*
|
|
243
|
+
* Good (100).
|
|
358
244
|
*/
|
|
359
|
-
|
|
245
|
+
HitResult[HitResult["good"] = 3] = "good";
|
|
360
246
|
/**
|
|
361
|
-
*
|
|
247
|
+
* Great (300).
|
|
362
248
|
*/
|
|
363
|
-
|
|
364
|
-
})(exports.
|
|
365
|
-
|
|
366
|
-
/**
|
|
367
|
-
* The loop type of storyboard animations.
|
|
368
|
-
*/
|
|
369
|
-
exports.AnimationLoopType = void 0;
|
|
370
|
-
(function (AnimationLoopType) {
|
|
371
|
-
AnimationLoopType["loopForever"] = "LoopForever";
|
|
372
|
-
AnimationLoopType["loopOnce"] = "LoopOnce";
|
|
373
|
-
})(exports.AnimationLoopType || (exports.AnimationLoopType = {}));
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Represents available sample banks.
|
|
377
|
-
*/
|
|
378
|
-
exports.SampleBank = void 0;
|
|
379
|
-
(function (SampleBank) {
|
|
380
|
-
SampleBank[SampleBank["none"] = 0] = "none";
|
|
381
|
-
SampleBank[SampleBank["normal"] = 1] = "normal";
|
|
382
|
-
SampleBank[SampleBank["soft"] = 2] = "soft";
|
|
383
|
-
SampleBank[SampleBank["drum"] = 3] = "drum";
|
|
384
|
-
})(exports.SampleBank || (exports.SampleBank = {}));
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* Represents a gameplay hit sample.
|
|
388
|
-
*/
|
|
389
|
-
class HitSampleInfo {
|
|
390
|
-
constructor(volume = 0) {
|
|
391
|
-
this.volume = volume;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Represents a pre-determined gameplay hit sample that can be loaded from banks.
|
|
397
|
-
*/
|
|
398
|
-
class BankHitSampleInfo extends HitSampleInfo {
|
|
399
|
-
get lookupNames() {
|
|
400
|
-
const names = [];
|
|
401
|
-
let prefix;
|
|
402
|
-
switch (this.bank) {
|
|
403
|
-
case exports.SampleBank.none:
|
|
404
|
-
prefix = "";
|
|
405
|
-
break;
|
|
406
|
-
case exports.SampleBank.normal:
|
|
407
|
-
prefix = "normal";
|
|
408
|
-
break;
|
|
409
|
-
case exports.SampleBank.soft:
|
|
410
|
-
prefix = "soft";
|
|
411
|
-
break;
|
|
412
|
-
case exports.SampleBank.drum:
|
|
413
|
-
prefix = "drum";
|
|
414
|
-
break;
|
|
415
|
-
}
|
|
416
|
-
if (this.customSampleBank >= 2) {
|
|
417
|
-
names.push(`${prefix}-${this.name}${this.customSampleBank.toString()}`);
|
|
418
|
-
}
|
|
419
|
-
names.push(`${prefix}-${this.name}`, this.name);
|
|
420
|
-
return names;
|
|
421
|
-
}
|
|
422
|
-
constructor(name, bank = exports.SampleBank.none, customSampleBank = 0, volume = 0, isLayered = false) {
|
|
423
|
-
super(volume);
|
|
424
|
-
this.name = name;
|
|
425
|
-
this.bank = bank;
|
|
426
|
-
this.customSampleBank = customSampleBank;
|
|
427
|
-
this.isLayered = isLayered;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
BankHitSampleInfo.HIT_WHISTLE = "hitwhistle";
|
|
431
|
-
BankHitSampleInfo.HIT_FINISH = "hitfinish";
|
|
432
|
-
BankHitSampleInfo.HIT_NORMAL = "hitnormal";
|
|
433
|
-
BankHitSampleInfo.HIT_CLAP = "hitclap";
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Mode enum to switch things between osu!droid and osu!standard.
|
|
437
|
-
*/
|
|
438
|
-
exports.Modes = void 0;
|
|
439
|
-
(function (Modes) {
|
|
440
|
-
Modes["droid"] = "droid";
|
|
441
|
-
Modes["osu"] = "osu";
|
|
442
|
-
})(exports.Modes || (exports.Modes = {}));
|
|
249
|
+
HitResult[HitResult["great"] = 4] = "great";
|
|
250
|
+
})(exports.HitResult || (exports.HitResult = {}));
|
|
443
251
|
|
|
444
252
|
/**
|
|
445
253
|
* Represents a hit window.
|
|
@@ -451,6 +259,25 @@ class HitWindow {
|
|
|
451
259
|
constructor(overallDifficulty = 5) {
|
|
452
260
|
this.overallDifficulty = overallDifficulty;
|
|
453
261
|
}
|
|
262
|
+
/**
|
|
263
|
+
* Retrieves the hit window for a {@link HitResult}. This is the number of +/- milliseconds
|
|
264
|
+
* allowed for the requested result (so the actual hittable range is double this).
|
|
265
|
+
*
|
|
266
|
+
* @param result The {@link HitResult} to retrieve the hit window for.
|
|
267
|
+
* @returns The hit window for the requested {@link HitResult}.
|
|
268
|
+
*/
|
|
269
|
+
hitWindowFor(result) {
|
|
270
|
+
switch (result) {
|
|
271
|
+
case exports.HitResult.great:
|
|
272
|
+
return this.greatWindow;
|
|
273
|
+
case exports.HitResult.good:
|
|
274
|
+
return this.okWindow;
|
|
275
|
+
case exports.HitResult.meh:
|
|
276
|
+
return this.mehWindow;
|
|
277
|
+
case exports.HitResult.miss:
|
|
278
|
+
return HitWindow.missWindow;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
454
281
|
}
|
|
455
282
|
/**
|
|
456
283
|
* A fixed miss hit window regardless of difficulty settings.
|
|
@@ -503,6 +330,21 @@ class DroidHitWindow extends HitWindow {
|
|
|
503
330
|
* Represents the hit window of osu!standard.
|
|
504
331
|
*/
|
|
505
332
|
class OsuHitWindow extends HitWindow {
|
|
333
|
+
get greatWindow() {
|
|
334
|
+
return Math.floor(80 - 6 * this.overallDifficulty) - 0.5;
|
|
335
|
+
}
|
|
336
|
+
get okWindow() {
|
|
337
|
+
return Math.floor(140 - 8 * this.overallDifficulty) - 0.5;
|
|
338
|
+
}
|
|
339
|
+
get mehWindow() {
|
|
340
|
+
return Math.floor(200 - 10 * this.overallDifficulty) - 0.5;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Represents the hit window of osu!droid _with_ the Precise mod.
|
|
346
|
+
*/
|
|
347
|
+
class PreciseDroidHitWindow extends HitWindow {
|
|
506
348
|
/**
|
|
507
349
|
* Calculates the overall difficulty value of a great (300) hit window.
|
|
508
350
|
*
|
|
@@ -510,7 +352,7 @@ class OsuHitWindow extends HitWindow {
|
|
|
510
352
|
* @returns The overall difficulty value.
|
|
511
353
|
*/
|
|
512
354
|
static greatWindowToOD(value) {
|
|
513
|
-
return (
|
|
355
|
+
return 5 - (value - 55) / 6;
|
|
514
356
|
}
|
|
515
357
|
/**
|
|
516
358
|
* Calculates the overall difficulty value of a good (100) hit window.
|
|
@@ -519,67 +361,25 @@ class OsuHitWindow extends HitWindow {
|
|
|
519
361
|
* @returns The overall difficulty value.
|
|
520
362
|
*/
|
|
521
363
|
static okWindowToOD(value) {
|
|
522
|
-
return (
|
|
364
|
+
return 5 - (value - 120) / 8;
|
|
523
365
|
}
|
|
524
366
|
/**
|
|
525
|
-
* Calculates the overall difficulty value of a meh hit window.
|
|
367
|
+
* Calculates the overall difficulty value of a meh (50) hit window.
|
|
526
368
|
*
|
|
527
369
|
* @param value The value of the hit window, in milliseconds.
|
|
528
370
|
* @returns The overall difficulty value.
|
|
529
371
|
*/
|
|
530
372
|
static mehWindowToOD(value) {
|
|
531
|
-
return (
|
|
373
|
+
return 5 - (value - 180) / 10;
|
|
532
374
|
}
|
|
533
375
|
get greatWindow() {
|
|
534
|
-
return
|
|
376
|
+
return 55 + 6 * (5 - this.overallDifficulty);
|
|
535
377
|
}
|
|
536
378
|
get okWindow() {
|
|
537
|
-
return
|
|
379
|
+
return 120 + 8 * (5 - this.overallDifficulty);
|
|
538
380
|
}
|
|
539
381
|
get mehWindow() {
|
|
540
|
-
return
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* Represents the hit window of osu!droid _with_ the Precise mod.
|
|
546
|
-
*/
|
|
547
|
-
class PreciseDroidHitWindow extends HitWindow {
|
|
548
|
-
/**
|
|
549
|
-
* Calculates the overall difficulty value of a great (300) hit window.
|
|
550
|
-
*
|
|
551
|
-
* @param value The value of the hit window, in milliseconds.
|
|
552
|
-
* @returns The overall difficulty value.
|
|
553
|
-
*/
|
|
554
|
-
static greatWindowToOD(value) {
|
|
555
|
-
return 5 - (value - 55) / 6;
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* Calculates the overall difficulty value of a good (100) hit window.
|
|
559
|
-
*
|
|
560
|
-
* @param value The value of the hit window, in milliseconds.
|
|
561
|
-
* @returns The overall difficulty value.
|
|
562
|
-
*/
|
|
563
|
-
static okWindowToOD(value) {
|
|
564
|
-
return 5 - (value - 120) / 8;
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Calculates the overall difficulty value of a meh (50) hit window.
|
|
568
|
-
*
|
|
569
|
-
* @param value The value of the hit window, in milliseconds.
|
|
570
|
-
* @returns The overall difficulty value.
|
|
571
|
-
*/
|
|
572
|
-
static mehWindowToOD(value) {
|
|
573
|
-
return 5 - (value - 180) / 10;
|
|
574
|
-
}
|
|
575
|
-
get greatWindow() {
|
|
576
|
-
return 55 + 6 * (5 - this.overallDifficulty);
|
|
577
|
-
}
|
|
578
|
-
get okWindow() {
|
|
579
|
-
return 120 + 8 * (5 - this.overallDifficulty);
|
|
580
|
-
}
|
|
581
|
-
get mehWindow() {
|
|
582
|
-
return 180 + 10 * (5 - this.overallDifficulty);
|
|
382
|
+
return 180 + 10 * (5 - this.overallDifficulty);
|
|
583
383
|
}
|
|
584
384
|
}
|
|
585
385
|
|
|
@@ -596,6 +396,17 @@ exports.ObjectTypes = void 0;
|
|
|
596
396
|
ObjectTypes[ObjectTypes["comboOffset"] = 112] = "comboOffset";
|
|
597
397
|
})(exports.ObjectTypes || (exports.ObjectTypes = {}));
|
|
598
398
|
|
|
399
|
+
/**
|
|
400
|
+
* Represents available sample banks.
|
|
401
|
+
*/
|
|
402
|
+
exports.SampleBank = void 0;
|
|
403
|
+
(function (SampleBank) {
|
|
404
|
+
SampleBank[SampleBank["none"] = 0] = "none";
|
|
405
|
+
SampleBank[SampleBank["normal"] = 1] = "normal";
|
|
406
|
+
SampleBank[SampleBank["soft"] = 2] = "soft";
|
|
407
|
+
SampleBank[SampleBank["drum"] = 3] = "drum";
|
|
408
|
+
})(exports.SampleBank || (exports.SampleBank = {}));
|
|
409
|
+
|
|
599
410
|
/**
|
|
600
411
|
* Represents a two-dimensional vector.
|
|
601
412
|
*/
|
|
@@ -1012,6 +823,55 @@ CircleSizeCalculator.brokenGamefieldRoundingAllowance = 1.00041;
|
|
|
1012
823
|
CircleSizeCalculator.oldAssumedDroidHeight = 681;
|
|
1013
824
|
CircleSizeCalculator.oldDroidScaleMultiplier = (0.5 * (11 - 5.2450170716245195)) / 5;
|
|
1014
825
|
|
|
826
|
+
/**
|
|
827
|
+
* Represents a gameplay hit sample.
|
|
828
|
+
*/
|
|
829
|
+
class HitSampleInfo {
|
|
830
|
+
constructor(volume = 0) {
|
|
831
|
+
this.volume = volume;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* Represents a pre-determined gameplay hit sample that can be loaded from banks.
|
|
837
|
+
*/
|
|
838
|
+
class BankHitSampleInfo extends HitSampleInfo {
|
|
839
|
+
get lookupNames() {
|
|
840
|
+
const names = [];
|
|
841
|
+
let prefix;
|
|
842
|
+
switch (this.bank) {
|
|
843
|
+
case exports.SampleBank.none:
|
|
844
|
+
prefix = "";
|
|
845
|
+
break;
|
|
846
|
+
case exports.SampleBank.normal:
|
|
847
|
+
prefix = "normal";
|
|
848
|
+
break;
|
|
849
|
+
case exports.SampleBank.soft:
|
|
850
|
+
prefix = "soft";
|
|
851
|
+
break;
|
|
852
|
+
case exports.SampleBank.drum:
|
|
853
|
+
prefix = "drum";
|
|
854
|
+
break;
|
|
855
|
+
}
|
|
856
|
+
if (this.customSampleBank >= 2) {
|
|
857
|
+
names.push(`${prefix}-${this.name}${this.customSampleBank.toString()}`);
|
|
858
|
+
}
|
|
859
|
+
names.push(`${prefix}-${this.name}`, this.name);
|
|
860
|
+
return names;
|
|
861
|
+
}
|
|
862
|
+
constructor(name, bank = exports.SampleBank.none, customSampleBank = 0, volume = 0, isLayered = false) {
|
|
863
|
+
super(volume);
|
|
864
|
+
this.name = name;
|
|
865
|
+
this.bank = bank;
|
|
866
|
+
this.customSampleBank = customSampleBank;
|
|
867
|
+
this.isLayered = isLayered;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
BankHitSampleInfo.HIT_WHISTLE = "hitwhistle";
|
|
871
|
+
BankHitSampleInfo.HIT_FINISH = "hitfinish";
|
|
872
|
+
BankHitSampleInfo.HIT_NORMAL = "hitnormal";
|
|
873
|
+
BankHitSampleInfo.HIT_CLAP = "hitclap";
|
|
874
|
+
|
|
1015
875
|
/**
|
|
1016
876
|
* Represents a hitobject in a beatmap.
|
|
1017
877
|
*/
|
|
@@ -1391,7 +1251,7 @@ class ModSetting {
|
|
|
1391
1251
|
get isDefault() {
|
|
1392
1252
|
return this._value === this.defaultValue;
|
|
1393
1253
|
}
|
|
1394
|
-
constructor(name, description, defaultValue) {
|
|
1254
|
+
constructor(name, key, description, defaultValue) {
|
|
1395
1255
|
/**
|
|
1396
1256
|
* The formatter to display the value of this `ModSetting`.
|
|
1397
1257
|
*/
|
|
@@ -1399,10 +1259,35 @@ class ModSetting {
|
|
|
1399
1259
|
this.displayFormatter = (v) => `${v}`;
|
|
1400
1260
|
this.valueChangedListeners = new Set();
|
|
1401
1261
|
this.name = name;
|
|
1262
|
+
this.key = key;
|
|
1402
1263
|
this.description = description;
|
|
1403
1264
|
this._defaultValue = defaultValue;
|
|
1404
1265
|
this._value = defaultValue;
|
|
1405
1266
|
}
|
|
1267
|
+
/**
|
|
1268
|
+
* Loads the value of this `ModSetting` from a serialized settings object.
|
|
1269
|
+
*
|
|
1270
|
+
* @param settings The settings object to load from.
|
|
1271
|
+
*/
|
|
1272
|
+
load(settings) {
|
|
1273
|
+
if (this.key === null) {
|
|
1274
|
+
return;
|
|
1275
|
+
}
|
|
1276
|
+
const stored = settings[this.key];
|
|
1277
|
+
if (stored !== undefined && stored !== null) {
|
|
1278
|
+
this.value = stored;
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
/**
|
|
1282
|
+
* Saves the value of this `ModSetting` to a serialized settings object.
|
|
1283
|
+
*
|
|
1284
|
+
* @param settings The settings object to save to.
|
|
1285
|
+
*/
|
|
1286
|
+
save(settings) {
|
|
1287
|
+
if (this.key !== null) {
|
|
1288
|
+
settings[this.key] = this.value;
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1406
1291
|
/**
|
|
1407
1292
|
* Returns a string representation of this `ModSetting`'s value.
|
|
1408
1293
|
*
|
|
@@ -1496,15 +1381,13 @@ class Mod {
|
|
|
1496
1381
|
* Serializes this `Mod` to a `SerializedMod`.
|
|
1497
1382
|
*/
|
|
1498
1383
|
serialize() {
|
|
1499
|
-
|
|
1500
|
-
const
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
if (!serialized.settings) {
|
|
1505
|
-
delete serialized.settings;
|
|
1384
|
+
const settings = {};
|
|
1385
|
+
for (const setting of this.settings) {
|
|
1386
|
+
if (!setting.isDefault) {
|
|
1387
|
+
setting.save(settings);
|
|
1388
|
+
}
|
|
1506
1389
|
}
|
|
1507
|
-
return
|
|
1390
|
+
return Object.assign({ acronym: this.acronym }, (Object.keys(settings).length > 0 && { settings }));
|
|
1508
1391
|
}
|
|
1509
1392
|
/**
|
|
1510
1393
|
* Copies the settings of a `SerializedMod` to this `Mod`.
|
|
@@ -1513,9 +1396,14 @@ class Mod {
|
|
|
1513
1396
|
* @throws {TypeError} If the `SerializedMod` is not the same type as this `Mod`.
|
|
1514
1397
|
*/
|
|
1515
1398
|
copySettings(mod) {
|
|
1399
|
+
var _a;
|
|
1516
1400
|
if (mod.acronym !== this.acronym) {
|
|
1517
1401
|
throw new TypeError(`Cannot copy settings from ${mod.acronym} to ${this.acronym}`);
|
|
1518
1402
|
}
|
|
1403
|
+
const settings = (_a = mod.settings) !== null && _a !== void 0 ? _a : {};
|
|
1404
|
+
for (const setting of this.settings) {
|
|
1405
|
+
setting.load(settings);
|
|
1406
|
+
}
|
|
1519
1407
|
}
|
|
1520
1408
|
/**
|
|
1521
1409
|
* Whether this `Mod` can be applied to osu!droid.
|
|
@@ -1584,18 +1472,10 @@ class Mod {
|
|
|
1584
1472
|
return "facilitateAdjustment" in this;
|
|
1585
1473
|
}
|
|
1586
1474
|
/**
|
|
1587
|
-
* Whether this `Mod` requires the original `
|
|
1475
|
+
* Whether this `Mod` requires the original `BeatmapDifficulty` for conversion and processing.
|
|
1588
1476
|
*/
|
|
1589
|
-
|
|
1590
|
-
return "
|
|
1591
|
-
}
|
|
1592
|
-
/**
|
|
1593
|
-
* Serializes the settings of this `Mod` to an object that can be converted to a JSON.
|
|
1594
|
-
*
|
|
1595
|
-
* @returns The serialized settings of this `Mod`, or `null` if there are no settings.
|
|
1596
|
-
*/
|
|
1597
|
-
serializeSettings() {
|
|
1598
|
-
return null;
|
|
1477
|
+
requiresBeatmapDifficulty() {
|
|
1478
|
+
return "applyFromBeatmapDifficulty" in this;
|
|
1599
1479
|
}
|
|
1600
1480
|
/**
|
|
1601
1481
|
* Compares this `Mod` to another `Mod` for equality.
|
|
@@ -1675,6 +1555,9 @@ class EmptyHitWindow extends HitWindow {
|
|
|
1675
1555
|
get mehWindow() {
|
|
1676
1556
|
return 0;
|
|
1677
1557
|
}
|
|
1558
|
+
hitWindowFor() {
|
|
1559
|
+
return 0;
|
|
1560
|
+
}
|
|
1678
1561
|
}
|
|
1679
1562
|
|
|
1680
1563
|
/**
|
|
@@ -2266,6 +2149,7 @@ class ModTraceable extends Mod {
|
|
|
2266
2149
|
this.droidRanked = false;
|
|
2267
2150
|
this.isDroidRelevant = true;
|
|
2268
2151
|
this.droidScoreMultiplier = 1.06;
|
|
2152
|
+
this.migrationDroidScoreMultiplier = 1.06;
|
|
2269
2153
|
this.osuRanked = true;
|
|
2270
2154
|
this.isOsuRelevant = true;
|
|
2271
2155
|
this.osuScoreMultiplier = 1;
|
|
@@ -2281,6 +2165,15 @@ class BooleanModSetting extends ModSetting {
|
|
|
2281
2165
|
super(...arguments);
|
|
2282
2166
|
this.displayFormatter = (v) => v ? "Enabled" : "Disabled";
|
|
2283
2167
|
}
|
|
2168
|
+
load(settings) {
|
|
2169
|
+
if (this.key === null) {
|
|
2170
|
+
return;
|
|
2171
|
+
}
|
|
2172
|
+
const stored = settings[this.key];
|
|
2173
|
+
if (typeof stored === "boolean") {
|
|
2174
|
+
this.value = stored;
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2284
2177
|
}
|
|
2285
2178
|
|
|
2286
2179
|
/**
|
|
@@ -2305,7 +2198,7 @@ class ModHidden extends Mod {
|
|
|
2305
2198
|
*
|
|
2306
2199
|
* The main object body will not fade when enabled.
|
|
2307
2200
|
*/
|
|
2308
|
-
this.onlyFadeApproachCircles = new BooleanModSetting("Only fade approach circles", "The main object body will not fade when enabled.", false);
|
|
2201
|
+
this.onlyFadeApproachCircles = new BooleanModSetting("Only fade approach circles", "onlyFadeApproachCircles", "The main object body will not fade when enabled.", false);
|
|
2309
2202
|
this.incompatibleMods
|
|
2310
2203
|
.add(ModTraceable)
|
|
2311
2204
|
.add(ModApproachDifferent)
|
|
@@ -2314,15 +2207,12 @@ class ModHidden extends Mod {
|
|
|
2314
2207
|
get droidScoreMultiplier() {
|
|
2315
2208
|
return this.usesDefaultSettings ? 1.06 : 1;
|
|
2316
2209
|
}
|
|
2210
|
+
get migrationDroidScoreMultiplier() {
|
|
2211
|
+
return this.droidScoreMultiplier;
|
|
2212
|
+
}
|
|
2317
2213
|
get osuScoreMultiplier() {
|
|
2318
2214
|
return this.usesDefaultSettings ? 1.06 : 1;
|
|
2319
2215
|
}
|
|
2320
|
-
copySettings(mod) {
|
|
2321
|
-
var _a, _b;
|
|
2322
|
-
super.copySettings(mod);
|
|
2323
|
-
this.onlyFadeApproachCircles.value =
|
|
2324
|
-
(_b = (_a = mod.settings) === null || _a === void 0 ? void 0 : _a.onlyFadeApproachCircles) !== null && _b !== void 0 ? _b : this.onlyFadeApproachCircles.value;
|
|
2325
|
-
}
|
|
2326
2216
|
applyToBeatmap(beatmap) {
|
|
2327
2217
|
const applyFadeInAdjustment = (hitObject) => {
|
|
2328
2218
|
hitObject.timeFadeIn =
|
|
@@ -2333,11 +2223,6 @@ class ModHidden extends Mod {
|
|
|
2333
2223
|
};
|
|
2334
2224
|
beatmap.hitObjects.objects.forEach(applyFadeInAdjustment);
|
|
2335
2225
|
}
|
|
2336
|
-
serializeSettings() {
|
|
2337
|
-
return this.onlyFadeApproachCircles.value
|
|
2338
|
-
? { onlyFadeApproachCircles: this.onlyFadeApproachCircles.value }
|
|
2339
|
-
: null;
|
|
2340
|
-
}
|
|
2341
2226
|
toString() {
|
|
2342
2227
|
if (!this.onlyFadeApproachCircles.value) {
|
|
2343
2228
|
return super.toString();
|
|
@@ -2359,6 +2244,7 @@ class ModFreezeFrame extends Mod {
|
|
|
2359
2244
|
this.droidRanked = false;
|
|
2360
2245
|
this.isDroidRelevant = true;
|
|
2361
2246
|
this.droidScoreMultiplier = 1;
|
|
2247
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
2362
2248
|
this.osuRanked = false;
|
|
2363
2249
|
this.isOsuRelevant = true;
|
|
2364
2250
|
this.osuScoreMultiplier = 1;
|
|
@@ -2425,8 +2311,8 @@ class RangeConstrainedModSetting extends ModSetting {
|
|
|
2425
2311
|
set value(value) {
|
|
2426
2312
|
super.value = this.processValue(value);
|
|
2427
2313
|
}
|
|
2428
|
-
constructor(name, description, defaultValue, min, max, step) {
|
|
2429
|
-
super(name, description, defaultValue);
|
|
2314
|
+
constructor(name, key, description, defaultValue, min, max, step) {
|
|
2315
|
+
super(name, key, description, defaultValue);
|
|
2430
2316
|
this._min = min;
|
|
2431
2317
|
this._max = max;
|
|
2432
2318
|
this._step = step;
|
|
@@ -2437,8 +2323,8 @@ class RangeConstrainedModSetting extends ModSetting {
|
|
|
2437
2323
|
* Represents a `Mod` specific setting that is constrained to a number of values.
|
|
2438
2324
|
*/
|
|
2439
2325
|
class NumberModSetting extends RangeConstrainedModSetting {
|
|
2440
|
-
constructor(name, description, defaultValue, min, max, step) {
|
|
2441
|
-
super(name, description, defaultValue, min, max, step);
|
|
2326
|
+
constructor(name, key, description, defaultValue, min, max, step) {
|
|
2327
|
+
super(name, key, description, defaultValue, min, max, step);
|
|
2442
2328
|
this.displayFormatter = (v) => v.toString();
|
|
2443
2329
|
if (min > max) {
|
|
2444
2330
|
throw new RangeError(`The minimum value (${min.toString()}) must be less than or equal to the maximum value (${max.toString()}).`);
|
|
@@ -2450,8 +2336,20 @@ class NumberModSetting extends RangeConstrainedModSetting {
|
|
|
2450
2336
|
throw new RangeError(`The default value (${defaultValue.toString()}) must be between the minimum (${min.toString()}) and maximum (${max.toString()}) values.`);
|
|
2451
2337
|
}
|
|
2452
2338
|
}
|
|
2339
|
+
load(settings) {
|
|
2340
|
+
if (this.key === null) {
|
|
2341
|
+
return;
|
|
2342
|
+
}
|
|
2343
|
+
const stored = settings[this.key];
|
|
2344
|
+
if (typeof stored === "number") {
|
|
2345
|
+
this.value = stored;
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2453
2348
|
processValue(value) {
|
|
2454
|
-
|
|
2349
|
+
const stepped = this.step > 0
|
|
2350
|
+
? Math.round(value / this.step) * this.step
|
|
2351
|
+
: value;
|
|
2352
|
+
return MathUtils.clamp(stepped, this.min, this.max);
|
|
2455
2353
|
}
|
|
2456
2354
|
}
|
|
2457
2355
|
|
|
@@ -2476,8 +2374,8 @@ class DecimalModSetting extends NumberModSetting {
|
|
|
2476
2374
|
this.value = this.processValue(this.value);
|
|
2477
2375
|
}
|
|
2478
2376
|
}
|
|
2479
|
-
constructor(name, description, defaultValue, min = -Number.MAX_VALUE, max = Number.MAX_VALUE, step = 0, precision = null) {
|
|
2480
|
-
super(name, description, defaultValue, min, max, step);
|
|
2377
|
+
constructor(name, key, description, defaultValue, min = -Number.MAX_VALUE, max = Number.MAX_VALUE, step = 0, precision = null) {
|
|
2378
|
+
super(name, key, description, defaultValue, min, max, step);
|
|
2481
2379
|
this.displayFormatter = (v) => {
|
|
2482
2380
|
if (this.precision !== null) {
|
|
2483
2381
|
return v.toFixed(this.precision);
|
|
@@ -2535,6 +2433,7 @@ class ModApproachDifferent extends Mod {
|
|
|
2535
2433
|
this.acronym = "AD";
|
|
2536
2434
|
this.droidRanked = false;
|
|
2537
2435
|
this.droidScoreMultiplier = 1;
|
|
2436
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
2538
2437
|
this.isDroidRelevant = true;
|
|
2539
2438
|
this.osuRanked = false;
|
|
2540
2439
|
this.isOsuRelevant = true;
|
|
@@ -2542,29 +2441,13 @@ class ModApproachDifferent extends Mod {
|
|
|
2542
2441
|
/**
|
|
2543
2442
|
* The initial size of the approach circle, relative to hit circles.
|
|
2544
2443
|
*/
|
|
2545
|
-
this.scale = new DecimalModSetting("Initial size", "The initial size of the approach circle, relative to hit circles.", 3, 1.5, 10, 0.1, 1);
|
|
2444
|
+
this.scale = new DecimalModSetting("Initial size", "scale", "The initial size of the approach circle, relative to hit circles.", 3, 1.5, 10, 0.1, 1);
|
|
2546
2445
|
/**
|
|
2547
2446
|
* The animation style of the approach circles.
|
|
2548
2447
|
*/
|
|
2549
|
-
this.style = new ModSetting("Style", "The animation style of the approach circles.", exports.AnimationStyle.gravity);
|
|
2448
|
+
this.style = new ModSetting("Style", "style", "The animation style of the approach circles.", exports.AnimationStyle.gravity);
|
|
2550
2449
|
this.incompatibleMods.add(ModHidden).add(ModFreezeFrame);
|
|
2551
2450
|
}
|
|
2552
|
-
copySettings(mod) {
|
|
2553
|
-
super.copySettings(mod);
|
|
2554
|
-
const { settings } = mod;
|
|
2555
|
-
if (typeof (settings === null || settings === void 0 ? void 0 : settings.scale) === "number") {
|
|
2556
|
-
this.scale.value = settings.scale;
|
|
2557
|
-
}
|
|
2558
|
-
if (typeof (settings === null || settings === void 0 ? void 0 : settings.style) === "number") {
|
|
2559
|
-
this.style.value = settings.style;
|
|
2560
|
-
}
|
|
2561
|
-
}
|
|
2562
|
-
serializeSettings() {
|
|
2563
|
-
return {
|
|
2564
|
-
scale: this.scale.value,
|
|
2565
|
-
style: this.style.value,
|
|
2566
|
-
};
|
|
2567
|
-
}
|
|
2568
2451
|
}
|
|
2569
2452
|
exports.AnimationStyle = void 0;
|
|
2570
2453
|
(function (AnimationStyle) {
|
|
@@ -2591,6 +2474,7 @@ class ModRelax extends Mod {
|
|
|
2591
2474
|
this.droidRanked = false;
|
|
2592
2475
|
this.isDroidRelevant = true;
|
|
2593
2476
|
this.droidScoreMultiplier = 0.001;
|
|
2477
|
+
this.migrationDroidScoreMultiplier = 0.001;
|
|
2594
2478
|
this.osuRanked = false;
|
|
2595
2479
|
this.isOsuRelevant = true;
|
|
2596
2480
|
this.osuScoreMultiplier = 0;
|
|
@@ -2610,6 +2494,7 @@ class ModAutopilot extends Mod {
|
|
|
2610
2494
|
this.droidRanked = false;
|
|
2611
2495
|
this.isDroidRelevant = true;
|
|
2612
2496
|
this.droidScoreMultiplier = 0.001;
|
|
2497
|
+
this.migrationDroidScoreMultiplier = 0.001;
|
|
2613
2498
|
this.osuRanked = false;
|
|
2614
2499
|
this.isOsuRelevant = true;
|
|
2615
2500
|
this.osuScoreMultiplier = 0;
|
|
@@ -2629,6 +2514,7 @@ class ModAuto extends Mod {
|
|
|
2629
2514
|
this.droidRanked = false;
|
|
2630
2515
|
this.isDroidRelevant = true;
|
|
2631
2516
|
this.droidScoreMultiplier = 1;
|
|
2517
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
2632
2518
|
this.osuRanked = false;
|
|
2633
2519
|
this.isOsuRelevant = true;
|
|
2634
2520
|
this.osuScoreMultiplier = 1;
|
|
@@ -2644,6 +2530,12 @@ class ModFlashlight extends Mod {
|
|
|
2644
2530
|
get droidRanked() {
|
|
2645
2531
|
return this.usesDefaultSettings;
|
|
2646
2532
|
}
|
|
2533
|
+
get droidScoreMultiplier() {
|
|
2534
|
+
return this.usesDefaultSettings ? 1.12 : 1;
|
|
2535
|
+
}
|
|
2536
|
+
get migrationDroidScoreMultiplier() {
|
|
2537
|
+
return this.droidScoreMultiplier;
|
|
2538
|
+
}
|
|
2647
2539
|
get osuRanked() {
|
|
2648
2540
|
return this.usesDefaultSettings;
|
|
2649
2541
|
}
|
|
@@ -2655,29 +2547,37 @@ class ModFlashlight extends Mod {
|
|
|
2655
2547
|
this.acronym = "FL";
|
|
2656
2548
|
this.name = "Flashlight";
|
|
2657
2549
|
this.isDroidRelevant = true;
|
|
2658
|
-
this.droidScoreMultiplier = 1.12;
|
|
2659
2550
|
this.isOsuRelevant = true;
|
|
2660
2551
|
this.bitwise = 1 << 10;
|
|
2661
2552
|
/**
|
|
2662
2553
|
* The amount of seconds until the Flashlight follow area reaches the cursor.
|
|
2663
2554
|
*/
|
|
2664
|
-
this.followDelay = new DecimalModSetting("Flashlight follow delay", "The amount of seconds until the Flashlight follow area reaches the cursor.", ModFlashlight.defaultFollowDelay, ModFlashlight.defaultFollowDelay, ModFlashlight.defaultFollowDelay * 10, ModFlashlight.defaultFollowDelay, 2);
|
|
2555
|
+
this.followDelay = new DecimalModSetting("Flashlight follow delay", "areaFollowDelay", "The amount of seconds until the Flashlight follow area reaches the cursor.", ModFlashlight.defaultFollowDelay, ModFlashlight.defaultFollowDelay, ModFlashlight.defaultFollowDelay * 10, ModFlashlight.defaultFollowDelay, 2);
|
|
2556
|
+
/**
|
|
2557
|
+
* The multiplier applied to the default Flashlight size.
|
|
2558
|
+
*/
|
|
2559
|
+
this.sizeMultiplier = new DecimalModSetting("Flashlight size", "sizeMultiplier", "The multiplier applied to the default Flashlight size.", 1, 0.5, 2, 0.1, 1);
|
|
2560
|
+
/**
|
|
2561
|
+
* Whether to decrease the Flashlight size as combo increases.
|
|
2562
|
+
*/
|
|
2563
|
+
this.comboBasedSize = new BooleanModSetting("Change size based on combo", "comboBasedSize", "Whether to decrease the Flashlight size as combo increases.", true);
|
|
2665
2564
|
this.incompatibleMods.add(ModBlinds);
|
|
2666
2565
|
}
|
|
2667
|
-
copySettings(mod) {
|
|
2668
|
-
var _a, _b;
|
|
2669
|
-
super.copySettings(mod);
|
|
2670
|
-
this.followDelay.value =
|
|
2671
|
-
(_b = (_a = mod.settings) === null || _a === void 0 ? void 0 : _a.areaFollowDelay) !== null && _b !== void 0 ? _b : this.followDelay.value;
|
|
2672
|
-
}
|
|
2673
|
-
serializeSettings() {
|
|
2674
|
-
return { areaFollowDelay: this.followDelay.value };
|
|
2675
|
-
}
|
|
2676
2566
|
toString() {
|
|
2677
|
-
if (this.
|
|
2567
|
+
if (this.usesDefaultSettings) {
|
|
2678
2568
|
return super.toString();
|
|
2679
2569
|
}
|
|
2680
|
-
|
|
2570
|
+
const parts = [];
|
|
2571
|
+
if (!this.followDelay.isDefault) {
|
|
2572
|
+
parts.push(`${this.followDelay.toDisplayString()}s follow delay`);
|
|
2573
|
+
}
|
|
2574
|
+
if (!this.sizeMultiplier.isDefault) {
|
|
2575
|
+
parts.push(`${this.sizeMultiplier.toDisplayString()}x size`);
|
|
2576
|
+
}
|
|
2577
|
+
if (!this.comboBasedSize.isDefault) {
|
|
2578
|
+
parts.push(`${this.comboBasedSize.value ? "decrease" : "no"} size change with combo`);
|
|
2579
|
+
}
|
|
2580
|
+
return `${super.toString()} (${parts.join(", ")})`;
|
|
2681
2581
|
}
|
|
2682
2582
|
}
|
|
2683
2583
|
/**
|
|
@@ -2712,6 +2612,17 @@ class ModRateAdjustHelper {
|
|
|
2712
2612
|
? 1 + (this.trackRateMultiplier - 1) * 0.24
|
|
2713
2613
|
: Math.pow(0.3, (1 - this.trackRateMultiplier) * 4);
|
|
2714
2614
|
}
|
|
2615
|
+
/**
|
|
2616
|
+
* The score multiplier used when reverse-engineering raw scores from stored total score with
|
|
2617
|
+
* multiplier during database migration for osu!droid. Defaults to {@link droidScoreMultiplier}.
|
|
2618
|
+
*
|
|
2619
|
+
* **If {@link droidScoreMultiplier} is changed in the future, this must be changed in the affected `Mod`
|
|
2620
|
+
* subclass to return the old formula, so scores that need to be migrated on-fly are divided by the correct
|
|
2621
|
+
* historical multiplier**.
|
|
2622
|
+
*/
|
|
2623
|
+
get migrationDroidScoreMultiplier() {
|
|
2624
|
+
return this.droidScoreMultiplier;
|
|
2625
|
+
}
|
|
2715
2626
|
constructor(trackRateMultiplier) {
|
|
2716
2627
|
this.trackRateMultiplier = trackRateMultiplier;
|
|
2717
2628
|
}
|
|
@@ -2728,6 +2639,12 @@ class ModRateAdjust extends Mod {
|
|
|
2728
2639
|
return new ModRateAdjustHelper(this.trackRateMultiplier.value)
|
|
2729
2640
|
.droidScoreMultiplier;
|
|
2730
2641
|
}
|
|
2642
|
+
/**
|
|
2643
|
+
* The generic osu!droid migration score multiplier of this `Mod`.
|
|
2644
|
+
*/
|
|
2645
|
+
get migrationDroidScoreMultiplier() {
|
|
2646
|
+
return this.droidScoreMultiplier;
|
|
2647
|
+
}
|
|
2731
2648
|
/**
|
|
2732
2649
|
* Generic getter to determine if this `ModRateAdjust` is relevant.
|
|
2733
2650
|
*/
|
|
@@ -2736,7 +2653,7 @@ class ModRateAdjust extends Mod {
|
|
|
2736
2653
|
}
|
|
2737
2654
|
constructor(trackRateMultiplier = 1) {
|
|
2738
2655
|
super();
|
|
2739
|
-
this.trackRateMultiplier = new DecimalModSetting("Track rate multiplier", "The multiplier for the track's playback rate after applying this mod.", trackRateMultiplier, 0.5, 2, 0.05, 2);
|
|
2656
|
+
this.trackRateMultiplier = new DecimalModSetting("Track rate multiplier", "rateMultiplier", "The multiplier for the track's playback rate after applying this mod.", trackRateMultiplier, 0.5, 2, 0.05, 2);
|
|
2740
2657
|
}
|
|
2741
2658
|
applyToRate(_, rate) {
|
|
2742
2659
|
return rate * this.trackRateMultiplier.value;
|
|
@@ -2756,18 +2673,15 @@ class ModCustomSpeed extends ModRateAdjust {
|
|
|
2756
2673
|
this.droidRanked = true;
|
|
2757
2674
|
this.osuRanked = false;
|
|
2758
2675
|
}
|
|
2759
|
-
copySettings(mod) {
|
|
2760
|
-
var _a, _b;
|
|
2761
|
-
super.copySettings(mod);
|
|
2762
|
-
this.trackRateMultiplier.value =
|
|
2763
|
-
(_b = (_a = mod.settings) === null || _a === void 0 ? void 0 : _a.rateMultiplier) !== null && _b !== void 0 ? _b : this.trackRateMultiplier.value;
|
|
2764
|
-
}
|
|
2765
2676
|
get isDroidRelevant() {
|
|
2766
2677
|
return this.isRelevant;
|
|
2767
2678
|
}
|
|
2768
2679
|
get droidScoreMultiplier() {
|
|
2769
2680
|
return super.droidScoreMultiplier;
|
|
2770
2681
|
}
|
|
2682
|
+
get migrationDroidScoreMultiplier() {
|
|
2683
|
+
return super.migrationDroidScoreMultiplier;
|
|
2684
|
+
}
|
|
2771
2685
|
get isOsuRelevant() {
|
|
2772
2686
|
return this.isRelevant;
|
|
2773
2687
|
}
|
|
@@ -2780,9 +2694,6 @@ class ModCustomSpeed extends ModRateAdjust {
|
|
|
2780
2694
|
? 1 + value / 5
|
|
2781
2695
|
: 0.6 + value;
|
|
2782
2696
|
}
|
|
2783
|
-
serializeSettings() {
|
|
2784
|
-
return { rateMultiplier: this.trackRateMultiplier.value };
|
|
2785
|
-
}
|
|
2786
2697
|
toString() {
|
|
2787
2698
|
return `${super.toString()} (${this.trackRateMultiplier.toDisplayString()}x)`;
|
|
2788
2699
|
}
|
|
@@ -2800,16 +2711,6 @@ class ModObjectScaleTween extends Mod {
|
|
|
2800
2711
|
this.endScale = 1;
|
|
2801
2712
|
this.incompatibleMods.add(ModObjectScaleTween).add(ModTraceable);
|
|
2802
2713
|
}
|
|
2803
|
-
copySettings(mod) {
|
|
2804
|
-
var _a;
|
|
2805
|
-
super.copySettings(mod);
|
|
2806
|
-
const { settings } = mod;
|
|
2807
|
-
this.startScale.value =
|
|
2808
|
-
(_a = settings === null || settings === void 0 ? void 0 : settings.startScale) !== null && _a !== void 0 ? _a : this.startScale.value;
|
|
2809
|
-
}
|
|
2810
|
-
serializeSettings() {
|
|
2811
|
-
return { startScale: this.startScale.value };
|
|
2812
|
-
}
|
|
2813
2714
|
}
|
|
2814
2715
|
|
|
2815
2716
|
/**
|
|
@@ -2823,10 +2724,11 @@ class ModDeflate extends ModObjectScaleTween {
|
|
|
2823
2724
|
this.droidRanked = false;
|
|
2824
2725
|
this.isDroidRelevant = true;
|
|
2825
2726
|
this.droidScoreMultiplier = 1;
|
|
2727
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
2826
2728
|
this.osuRanked = false;
|
|
2827
2729
|
this.isOsuRelevant = true;
|
|
2828
2730
|
this.osuScoreMultiplier = 1;
|
|
2829
|
-
this.startScale = new DecimalModSetting("Start scale", "The initial size multiplier applied to all hit objects.", 2, 1, 25, 0.1, 1);
|
|
2731
|
+
this.startScale = new DecimalModSetting("Start scale", "startScale", "The initial size multiplier applied to all hit objects.", 2, 1, 25, 0.1, 1);
|
|
2830
2732
|
}
|
|
2831
2733
|
}
|
|
2832
2734
|
|
|
@@ -3020,26 +2922,15 @@ class HitObjectPositionInfo {
|
|
|
3020
2922
|
* Precision utilities.
|
|
3021
2923
|
*/
|
|
3022
2924
|
class Precision {
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
}
|
|
3033
|
-
/**
|
|
3034
|
-
* Checks if two vectors are equal with a given tolerance.
|
|
3035
|
-
*
|
|
3036
|
-
* @param vec1 The first vector.
|
|
3037
|
-
* @param vec2 The second vector.
|
|
3038
|
-
* @param acceptableDifference The acceptable difference as threshold. Default is `Precision.FLOAT_EPSILON = 1e-3`.
|
|
3039
|
-
*/
|
|
3040
|
-
static almostEqualsVector(vec1, vec2, acceptableDifference = this.FLOAT_EPSILON) {
|
|
3041
|
-
return (this.almostEqualsNumber(vec1.x, vec2.x, acceptableDifference) &&
|
|
3042
|
-
this.almostEqualsNumber(vec1.y, vec2.y, acceptableDifference));
|
|
2925
|
+
static almostEquals(value1, value2, acceptableDifference = this.FLOAT_EPSILON) {
|
|
2926
|
+
if (value1 instanceof Vector2 && value2 instanceof Vector2) {
|
|
2927
|
+
return (this.almostEquals(value1.x, value2.x, acceptableDifference) &&
|
|
2928
|
+
this.almostEquals(value1.y, value2.y, acceptableDifference));
|
|
2929
|
+
}
|
|
2930
|
+
else {
|
|
2931
|
+
return (Math.abs(value1 - value2) <=
|
|
2932
|
+
acceptableDifference);
|
|
2933
|
+
}
|
|
3043
2934
|
}
|
|
3044
2935
|
/**
|
|
3045
2936
|
* Checks whether two real numbers are almost equal.
|
|
@@ -3189,7 +3080,7 @@ class PathApproximator {
|
|
|
3189
3080
|
const c = controlPoints[2];
|
|
3190
3081
|
// If we have a degenerate triangle where a side-length is almost zero, then give up and fall
|
|
3191
3082
|
// back to a more numerically stable method.
|
|
3192
|
-
if (Precision.
|
|
3083
|
+
if (Precision.almostEquals(0, (b.y - a.y) * (c.x - a.x) - (b.x - a.x) * (c.y - a.y))) {
|
|
3193
3084
|
return this.approximateBezier(controlPoints);
|
|
3194
3085
|
}
|
|
3195
3086
|
// See: https://en.wikipedia.org/wiki/Circumscribed_circle#Cartesian_coordinates_2
|
|
@@ -3544,7 +3435,7 @@ class SliderPath {
|
|
|
3544
3435
|
const d0 = this.cumulativeLength[i - 1];
|
|
3545
3436
|
const d1 = this.cumulativeLength[i];
|
|
3546
3437
|
// Avoid division by and almost-zero number in case two points are extremely close to each other.
|
|
3547
|
-
if (Precision.
|
|
3438
|
+
if (Precision.almostEquals(d0, d1)) {
|
|
3548
3439
|
return p0;
|
|
3549
3440
|
}
|
|
3550
3441
|
const w = (d - d0) / (d1 - d0);
|
|
@@ -3894,7 +3785,7 @@ class HitObjectGenerationUtils {
|
|
|
3894
3785
|
this.getSliderRotation(current.hitObject)));
|
|
3895
3786
|
const relativeRotation = Math.atan2(centerOfMassModified.y, centerOfMassModified.x) -
|
|
3896
3787
|
Math.atan2(centerOfMassOriginal.y, centerOfMassOriginal.x);
|
|
3897
|
-
if (!Precision.
|
|
3788
|
+
if (!Precision.almostEquals(relativeRotation, 0)) {
|
|
3898
3789
|
this.rotateSlider(current.hitObject, relativeRotation);
|
|
3899
3790
|
}
|
|
3900
3791
|
}
|
|
@@ -4039,6 +3930,47 @@ class WorkingObject {
|
|
|
4039
3930
|
}
|
|
4040
3931
|
}
|
|
4041
3932
|
|
|
3933
|
+
/**
|
|
3934
|
+
* Defines available axes.
|
|
3935
|
+
*/
|
|
3936
|
+
exports.Axes = void 0;
|
|
3937
|
+
(function (Axes) {
|
|
3938
|
+
/**
|
|
3939
|
+
* No axis.
|
|
3940
|
+
*/
|
|
3941
|
+
Axes[Axes["none"] = 0] = "none";
|
|
3942
|
+
/**
|
|
3943
|
+
* The X axis.
|
|
3944
|
+
*/
|
|
3945
|
+
Axes[Axes["x"] = 1] = "x";
|
|
3946
|
+
/**
|
|
3947
|
+
* The Y axis.
|
|
3948
|
+
*/
|
|
3949
|
+
Axes[Axes["y"] = 2] = "y";
|
|
3950
|
+
/**
|
|
3951
|
+
* The X and Y axes.
|
|
3952
|
+
*/
|
|
3953
|
+
Axes[Axes["both"] = 3] = "both";
|
|
3954
|
+
})(exports.Axes || (exports.Axes = {}));
|
|
3955
|
+
|
|
3956
|
+
// Serializes Axes as a 0-indexed ordinal to match the Kotlin EnumModSetting format:
|
|
3957
|
+
// Axes.x (1) -> 0, Axes.y (2) -> 1, Axes.both (3) -> 2.
|
|
3958
|
+
class AxesModSetting extends ModSetting {
|
|
3959
|
+
load(settings) {
|
|
3960
|
+
if (this.key === null) {
|
|
3961
|
+
return;
|
|
3962
|
+
}
|
|
3963
|
+
const stored = settings[this.key];
|
|
3964
|
+
if (typeof stored === "number") {
|
|
3965
|
+
this.value = (stored + 1);
|
|
3966
|
+
}
|
|
3967
|
+
}
|
|
3968
|
+
save(settings) {
|
|
3969
|
+
if (this.key !== null) {
|
|
3970
|
+
settings[this.key] = this.value - 1;
|
|
3971
|
+
}
|
|
3972
|
+
}
|
|
3973
|
+
}
|
|
4042
3974
|
/**
|
|
4043
3975
|
* Represents the Mirror mod.
|
|
4044
3976
|
*/
|
|
@@ -4050,30 +3982,16 @@ class ModMirror extends Mod {
|
|
|
4050
3982
|
this.droidRanked = false;
|
|
4051
3983
|
this.isDroidRelevant = true;
|
|
4052
3984
|
this.droidScoreMultiplier = 1;
|
|
3985
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
4053
3986
|
this.osuRanked = false;
|
|
4054
3987
|
this.isOsuRelevant = true;
|
|
4055
3988
|
this.osuScoreMultiplier = 1;
|
|
4056
3989
|
/**
|
|
4057
3990
|
* The axes to reflect the `HitObject`s along.
|
|
4058
3991
|
*/
|
|
4059
|
-
this.flippedAxes = new
|
|
3992
|
+
this.flippedAxes = new AxesModSetting("Flipped axes", "flippedAxes", "The axes to reflect the hit objects along.", exports.Axes.x);
|
|
4060
3993
|
this.incompatibleMods.add(ModHardRock);
|
|
4061
3994
|
}
|
|
4062
|
-
copySettings(mod) {
|
|
4063
|
-
var _a;
|
|
4064
|
-
super.copySettings(mod);
|
|
4065
|
-
switch ((_a = mod.settings) === null || _a === void 0 ? void 0 : _a.flippedAxes) {
|
|
4066
|
-
case 0:
|
|
4067
|
-
this.flippedAxes.value = exports.Axes.x;
|
|
4068
|
-
break;
|
|
4069
|
-
case 1:
|
|
4070
|
-
this.flippedAxes.value = exports.Axes.y;
|
|
4071
|
-
break;
|
|
4072
|
-
case 2:
|
|
4073
|
-
this.flippedAxes.value = exports.Axes.both;
|
|
4074
|
-
break;
|
|
4075
|
-
}
|
|
4076
|
-
}
|
|
4077
3995
|
applyToHitObject(_, hitObject) {
|
|
4078
3996
|
switch (this.flippedAxes.value) {
|
|
4079
3997
|
case exports.Axes.x:
|
|
@@ -4088,9 +4006,6 @@ class ModMirror extends Mod {
|
|
|
4088
4006
|
break;
|
|
4089
4007
|
}
|
|
4090
4008
|
}
|
|
4091
|
-
serializeSettings() {
|
|
4092
|
-
return { flippedAxes: this.flippedAxes.value - 1 };
|
|
4093
|
-
}
|
|
4094
4009
|
toString() {
|
|
4095
4010
|
const settings = [];
|
|
4096
4011
|
if (this.flippedAxes.value === exports.Axes.x ||
|
|
@@ -4123,6 +4038,7 @@ class ModReplayV6 extends Mod {
|
|
|
4123
4038
|
this.droidRanked = false;
|
|
4124
4039
|
this.isDroidRelevant = true;
|
|
4125
4040
|
this.droidScoreMultiplier = 1;
|
|
4041
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
4126
4042
|
this.facilitateAdjustment = true;
|
|
4127
4043
|
}
|
|
4128
4044
|
applyToBeatmap(beatmap) {
|
|
@@ -4169,6 +4085,7 @@ class ModHardRock extends Mod {
|
|
|
4169
4085
|
this.droidRanked = true;
|
|
4170
4086
|
this.isDroidRelevant = true;
|
|
4171
4087
|
this.droidScoreMultiplier = 1.06;
|
|
4088
|
+
this.migrationDroidScoreMultiplier = 1.06;
|
|
4172
4089
|
this.osuRanked = true;
|
|
4173
4090
|
this.isOsuRelevant = true;
|
|
4174
4091
|
this.osuScoreMultiplier = 1.06;
|
|
@@ -4218,6 +4135,7 @@ class ModEasy extends Mod {
|
|
|
4218
4135
|
this.droidRanked = true;
|
|
4219
4136
|
this.isDroidRelevant = true;
|
|
4220
4137
|
this.droidScoreMultiplier = 0.5;
|
|
4138
|
+
this.migrationDroidScoreMultiplier = 0.5;
|
|
4221
4139
|
this.osuRanked = true;
|
|
4222
4140
|
this.isOsuRelevant = true;
|
|
4223
4141
|
this.osuScoreMultiplier = 0.5;
|
|
@@ -4260,6 +4178,7 @@ class ModReallyEasy extends Mod {
|
|
|
4260
4178
|
this.droidRanked = false;
|
|
4261
4179
|
this.isDroidRelevant = true;
|
|
4262
4180
|
this.droidScoreMultiplier = 0.4;
|
|
4181
|
+
this.migrationDroidScoreMultiplier = 0.4;
|
|
4263
4182
|
}
|
|
4264
4183
|
applyToDifficultyWithMods(mode, difficulty, mods) {
|
|
4265
4184
|
var _a;
|
|
@@ -4318,6 +4237,7 @@ class ModSmallCircle extends Mod {
|
|
|
4318
4237
|
this.droidRanked = false;
|
|
4319
4238
|
this.isDroidRelevant = true;
|
|
4320
4239
|
this.droidScoreMultiplier = 1;
|
|
4240
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
4321
4241
|
}
|
|
4322
4242
|
migrateDroidMod(difficulty) {
|
|
4323
4243
|
return new ModDifficultyAdjust({ cs: difficulty.cs + 4 });
|
|
@@ -4362,8 +4282,8 @@ class NullableDecimalModSetting extends RangeConstrainedModSetting {
|
|
|
4362
4282
|
this.value = this.processValue(this.value);
|
|
4363
4283
|
}
|
|
4364
4284
|
}
|
|
4365
|
-
constructor(name, description, defaultValue, min = -Number.MAX_VALUE, max = Number.MAX_VALUE, step = 0, precision = null) {
|
|
4366
|
-
super(name, description, defaultValue, min, max, step);
|
|
4285
|
+
constructor(name, key, description, defaultValue, min = -Number.MAX_VALUE, max = Number.MAX_VALUE, step = 0, precision = null) {
|
|
4286
|
+
super(name, key, description, defaultValue, min, max, step);
|
|
4367
4287
|
this.displayFormatter = (v) => {
|
|
4368
4288
|
if (v === null) {
|
|
4369
4289
|
return "None";
|
|
@@ -4389,29 +4309,101 @@ class NullableDecimalModSetting extends RangeConstrainedModSetting {
|
|
|
4389
4309
|
if (value === null) {
|
|
4390
4310
|
return null;
|
|
4391
4311
|
}
|
|
4392
|
-
const
|
|
4312
|
+
const stepped = this.step > 0
|
|
4313
|
+
? Math.round(value / this.step) * this.step
|
|
4314
|
+
: value;
|
|
4315
|
+
const processedValue = MathUtils.clamp(stepped, this.min, this.max);
|
|
4393
4316
|
if (this.precision !== null) {
|
|
4394
4317
|
return parseFloat(processedValue.toFixed(this.precision));
|
|
4395
4318
|
}
|
|
4396
4319
|
return processedValue;
|
|
4397
4320
|
}
|
|
4321
|
+
load(settings) {
|
|
4322
|
+
if (this.key === null) {
|
|
4323
|
+
return;
|
|
4324
|
+
}
|
|
4325
|
+
const stored = settings[this.key];
|
|
4326
|
+
if (stored === null || stored === undefined) {
|
|
4327
|
+
this.value = null;
|
|
4328
|
+
}
|
|
4329
|
+
else if (typeof stored === "number") {
|
|
4330
|
+
this.value = stored;
|
|
4331
|
+
}
|
|
4332
|
+
}
|
|
4333
|
+
save(settings) {
|
|
4334
|
+
if (this.key !== null) {
|
|
4335
|
+
settings[this.key] = this.value;
|
|
4336
|
+
}
|
|
4337
|
+
}
|
|
4398
4338
|
}
|
|
4399
4339
|
|
|
4400
4340
|
/**
|
|
4401
|
-
*
|
|
4341
|
+
* A `NullableDecimalModSetting` variant for `ModDifficultyAdjust` that embeds the beatmap's original
|
|
4342
|
+
* difficulty value alongside the user's adjusted value in the serialized format:
|
|
4343
|
+
*
|
|
4344
|
+
* `{ "adjusted": 7.0, "original": 4.0 }`
|
|
4345
|
+
*
|
|
4346
|
+
* When `originalValue` is non-null, the score multiplier can be computed from the serialized format
|
|
4347
|
+
* alone, without a beatmap lookup. When `null`, `applyFromBeatmapDifficulty` must be called first.
|
|
4348
|
+
*
|
|
4349
|
+
* Legacy scalar values (e.g. `"cs": 7.0`) are accepted in `load` for backward compatibility.
|
|
4402
4350
|
*/
|
|
4403
|
-
class
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4351
|
+
class DifficultyAdjustModSetting extends NullableDecimalModSetting {
|
|
4352
|
+
constructor(name, key, description, min = -Number.MAX_VALUE, max = Number.MAX_VALUE, step = 0, precision = null) {
|
|
4353
|
+
super(name, key, description, null, min, max, step, precision);
|
|
4354
|
+
/**
|
|
4355
|
+
* The beatmap's original value for this setting, populated by `applyFromBeatmapDifficulty`.
|
|
4356
|
+
*
|
|
4357
|
+
* Non-null means the score multiplier is self-contained; `null` means a beatmap lookup is needed.
|
|
4358
|
+
*/
|
|
4359
|
+
this.originalValue = null;
|
|
4409
4360
|
}
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4361
|
+
load(settings) {
|
|
4362
|
+
if (this.key === null) {
|
|
4363
|
+
return;
|
|
4364
|
+
}
|
|
4365
|
+
const data = settings[this.key];
|
|
4366
|
+
if (typeof data === "object" && data !== null) {
|
|
4367
|
+
const { adjusted, original } = data;
|
|
4368
|
+
this.value = typeof adjusted === "number" ? adjusted : null;
|
|
4369
|
+
const originalNum = typeof original === "number" ? original : null;
|
|
4370
|
+
this.originalValue = originalNum;
|
|
4371
|
+
if (originalNum !== null) {
|
|
4372
|
+
this.defaultValue = originalNum;
|
|
4373
|
+
}
|
|
4374
|
+
}
|
|
4375
|
+
else if (typeof data === "number") {
|
|
4376
|
+
// Legacy scalar format.
|
|
4377
|
+
this.value = data;
|
|
4378
|
+
this.originalValue = null;
|
|
4379
|
+
}
|
|
4380
|
+
}
|
|
4381
|
+
save(settings) {
|
|
4382
|
+
if (this.key === null || this.value === null) {
|
|
4383
|
+
return;
|
|
4384
|
+
}
|
|
4385
|
+
settings[this.key] = {
|
|
4386
|
+
adjusted: this.value,
|
|
4387
|
+
original: this.originalValue,
|
|
4388
|
+
};
|
|
4389
|
+
}
|
|
4390
|
+
}
|
|
4391
|
+
|
|
4392
|
+
/**
|
|
4393
|
+
* Represents the Difficulty Adjust mod.
|
|
4394
|
+
*/
|
|
4395
|
+
class ModDifficultyAdjust extends Mod {
|
|
4396
|
+
get isRelevant() {
|
|
4397
|
+
return (this.cs.value !== null ||
|
|
4398
|
+
this.ar.value !== null ||
|
|
4399
|
+
this.od.value !== null ||
|
|
4400
|
+
this.hp.value !== null);
|
|
4401
|
+
}
|
|
4402
|
+
constructor(values) {
|
|
4403
|
+
var _a, _b, _c, _d;
|
|
4404
|
+
super();
|
|
4405
|
+
this.acronym = "DA";
|
|
4406
|
+
this.name = "Difficulty Adjust";
|
|
4415
4407
|
this.droidRanked = false;
|
|
4416
4408
|
this.osuRanked = false;
|
|
4417
4409
|
this.isOsuRelevant = true;
|
|
@@ -4419,32 +4411,24 @@ class ModDifficultyAdjust extends Mod {
|
|
|
4419
4411
|
/**
|
|
4420
4412
|
* The circle size to enforce.
|
|
4421
4413
|
*/
|
|
4422
|
-
this.cs = new
|
|
4414
|
+
this.cs = new DifficultyAdjustModSetting("Circle size", "cs", "The circle size to enforce.", 0, 15, 0.1, 1);
|
|
4423
4415
|
/**
|
|
4424
4416
|
* The approach rate to enforce.
|
|
4425
4417
|
*/
|
|
4426
|
-
this.ar = new
|
|
4418
|
+
this.ar = new DifficultyAdjustModSetting("Approach rate", "ar", "The approach rate to enforce.", 0, 11, 0.1, 1);
|
|
4427
4419
|
/**
|
|
4428
4420
|
* The overall difficulty to enforce.
|
|
4429
4421
|
*/
|
|
4430
|
-
this.od = new
|
|
4422
|
+
this.od = new DifficultyAdjustModSetting("Overall difficulty", "od", "The overall difficulty to enforce.", 0, 11, 0.1, 1);
|
|
4431
4423
|
/**
|
|
4432
4424
|
* The health drain rate to enforce.
|
|
4433
4425
|
*/
|
|
4434
|
-
this.hp = new
|
|
4426
|
+
this.hp = new DifficultyAdjustModSetting("Health drain", "hp", "The health drain to enforce.", 0, 11, 0.1, 1);
|
|
4435
4427
|
this.cs.value = this.cs.defaultValue = (_a = values === null || values === void 0 ? void 0 : values.cs) !== null && _a !== void 0 ? _a : null;
|
|
4436
4428
|
this.ar.value = this.ar.defaultValue = (_b = values === null || values === void 0 ? void 0 : values.ar) !== null && _b !== void 0 ? _b : null;
|
|
4437
4429
|
this.od.value = this.od.defaultValue = (_c = values === null || values === void 0 ? void 0 : values.od) !== null && _c !== void 0 ? _c : null;
|
|
4438
4430
|
this.hp.value = this.hp.defaultValue = (_d = values === null || values === void 0 ? void 0 : values.hp) !== null && _d !== void 0 ? _d : null;
|
|
4439
4431
|
}
|
|
4440
|
-
copySettings(mod) {
|
|
4441
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4442
|
-
super.copySettings(mod);
|
|
4443
|
-
this.cs.value = ((_b = (_a = mod.settings) === null || _a === void 0 ? void 0 : _a.cs) !== null && _b !== void 0 ? _b : null);
|
|
4444
|
-
this.ar.value = ((_d = (_c = mod.settings) === null || _c === void 0 ? void 0 : _c.ar) !== null && _d !== void 0 ? _d : null);
|
|
4445
|
-
this.od.value = ((_f = (_e = mod.settings) === null || _e === void 0 ? void 0 : _e.od) !== null && _f !== void 0 ? _f : null);
|
|
4446
|
-
this.hp.value = ((_h = (_g = mod.settings) === null || _g === void 0 ? void 0 : _g.hp) !== null && _h !== void 0 ? _h : null);
|
|
4447
|
-
}
|
|
4448
4432
|
get isDroidRelevant() {
|
|
4449
4433
|
return this.isRelevant;
|
|
4450
4434
|
}
|
|
@@ -4467,11 +4451,14 @@ class ModDifficultyAdjust extends Mod {
|
|
|
4467
4451
|
}
|
|
4468
4452
|
return multiplier;
|
|
4469
4453
|
}
|
|
4470
|
-
|
|
4471
|
-
this.
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
this.
|
|
4454
|
+
get migrationDroidScoreMultiplier() {
|
|
4455
|
+
return this.droidScoreMultiplier;
|
|
4456
|
+
}
|
|
4457
|
+
applyFromBeatmapDifficulty(difficulty) {
|
|
4458
|
+
this.cs.originalValue = difficulty.cs;
|
|
4459
|
+
this.ar.originalValue = difficulty.ar;
|
|
4460
|
+
this.od.originalValue = difficulty.od;
|
|
4461
|
+
this.hp.originalValue = difficulty.hp;
|
|
4475
4462
|
}
|
|
4476
4463
|
applyToDifficultyWithMods(_, difficulty, mods) {
|
|
4477
4464
|
var _a, _b, _c, _d;
|
|
@@ -4515,25 +4502,6 @@ class ModDifficultyAdjust extends Mod {
|
|
|
4515
4502
|
}
|
|
4516
4503
|
return super.isCompatibleWith(other);
|
|
4517
4504
|
}
|
|
4518
|
-
serializeSettings() {
|
|
4519
|
-
if (!this.isRelevant) {
|
|
4520
|
-
return null;
|
|
4521
|
-
}
|
|
4522
|
-
const settings = {};
|
|
4523
|
-
if (this.cs.value !== null) {
|
|
4524
|
-
settings.cs = this.cs.value;
|
|
4525
|
-
}
|
|
4526
|
-
if (this.ar.value !== null) {
|
|
4527
|
-
settings.ar = this.ar.value;
|
|
4528
|
-
}
|
|
4529
|
-
if (this.od.value !== null) {
|
|
4530
|
-
settings.od = this.od.value;
|
|
4531
|
-
}
|
|
4532
|
-
if (this.hp.value !== null) {
|
|
4533
|
-
settings.hp = this.hp.value;
|
|
4534
|
-
}
|
|
4535
|
-
return settings;
|
|
4536
|
-
}
|
|
4537
4505
|
applyFadeAdjustment(hitObject, mods) {
|
|
4538
4506
|
// IMPORTANT: These do not use `ModUtil.calculateRateWithMods` to avoid circular dependency.
|
|
4539
4507
|
const initialTrackRate = this.calculateTrackRate(mods.values());
|
|
@@ -4594,6 +4562,9 @@ class ModNightCore extends ModRateAdjust {
|
|
|
4594
4562
|
get droidScoreMultiplier() {
|
|
4595
4563
|
return super.droidScoreMultiplier;
|
|
4596
4564
|
}
|
|
4565
|
+
get migrationDroidScoreMultiplier() {
|
|
4566
|
+
return super.migrationDroidScoreMultiplier;
|
|
4567
|
+
}
|
|
4597
4568
|
get isOsuRelevant() {
|
|
4598
4569
|
return this.isRelevant;
|
|
4599
4570
|
}
|
|
@@ -4619,6 +4590,9 @@ class ModHalfTime extends ModRateAdjust {
|
|
|
4619
4590
|
get droidScoreMultiplier() {
|
|
4620
4591
|
return super.droidScoreMultiplier;
|
|
4621
4592
|
}
|
|
4593
|
+
get migrationDroidScoreMultiplier() {
|
|
4594
|
+
return super.migrationDroidScoreMultiplier;
|
|
4595
|
+
}
|
|
4622
4596
|
get isOsuRelevant() {
|
|
4623
4597
|
return this.isRelevant;
|
|
4624
4598
|
}
|
|
@@ -4644,6 +4618,9 @@ class ModDoubleTime extends ModRateAdjust {
|
|
|
4644
4618
|
get droidScoreMultiplier() {
|
|
4645
4619
|
return super.droidScoreMultiplier;
|
|
4646
4620
|
}
|
|
4621
|
+
get migrationDroidScoreMultiplier() {
|
|
4622
|
+
return super.migrationDroidScoreMultiplier;
|
|
4623
|
+
}
|
|
4647
4624
|
get isOsuRelevant() {
|
|
4648
4625
|
return this.isRelevant;
|
|
4649
4626
|
}
|
|
@@ -4660,10 +4637,11 @@ class ModGrow extends ModObjectScaleTween {
|
|
|
4660
4637
|
this.droidRanked = false;
|
|
4661
4638
|
this.isDroidRelevant = true;
|
|
4662
4639
|
this.droidScoreMultiplier = 1;
|
|
4640
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
4663
4641
|
this.osuRanked = false;
|
|
4664
4642
|
this.isOsuRelevant = true;
|
|
4665
4643
|
this.osuScoreMultiplier = 1;
|
|
4666
|
-
this.startScale = new DecimalModSetting("Start scale", "The initial size multiplier applied to all hit objects.", 0.5, 0, 0.99, 0.01, 2);
|
|
4644
|
+
this.startScale = new DecimalModSetting("Start scale", "startScale", "The initial size multiplier applied to all hit objects.", 0.5, 0, 0.99, 0.01, 2);
|
|
4667
4645
|
}
|
|
4668
4646
|
}
|
|
4669
4647
|
|
|
@@ -4681,7 +4659,7 @@ class ModMagnetised extends Mod {
|
|
|
4681
4659
|
/**
|
|
4682
4660
|
* How strong the pull is.
|
|
4683
4661
|
*/
|
|
4684
|
-
this.attractionStrength = new DecimalModSetting("Attraction Strength", "How strong the pull is.", 0.5, 0.05, 1, 0.05, 2);
|
|
4662
|
+
this.attractionStrength = new DecimalModSetting("Attraction Strength", "attractionStrength", "How strong the pull is.", 0.5, 0.05, 1, 0.05, 2);
|
|
4685
4663
|
}
|
|
4686
4664
|
}
|
|
4687
4665
|
|
|
@@ -4689,8 +4667,8 @@ class ModMagnetised extends Mod {
|
|
|
4689
4667
|
* Represents a `Mod` specific setting that is constrained to a range of integer values.
|
|
4690
4668
|
*/
|
|
4691
4669
|
class IntegerModSetting extends NumberModSetting {
|
|
4692
|
-
constructor(name, description, defaultValue, min = -2147483648, max = 2147483647) {
|
|
4693
|
-
super(name, description, defaultValue, min, max, 1);
|
|
4670
|
+
constructor(name, key, description, defaultValue, min = -2147483648, max = 2147483647) {
|
|
4671
|
+
super(name, key, description, defaultValue, min, max, 1);
|
|
4694
4672
|
}
|
|
4695
4673
|
}
|
|
4696
4674
|
|
|
@@ -4705,25 +4683,26 @@ class ModMuted extends Mod {
|
|
|
4705
4683
|
this.droidRanked = false;
|
|
4706
4684
|
this.isDroidRelevant = true;
|
|
4707
4685
|
this.droidScoreMultiplier = 1;
|
|
4686
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
4708
4687
|
this.osuRanked = true;
|
|
4709
4688
|
this.isOsuRelevant = true;
|
|
4710
4689
|
this.osuScoreMultiplier = 1;
|
|
4711
4690
|
/**
|
|
4712
4691
|
* Increase volume as combo builds.
|
|
4713
4692
|
*/
|
|
4714
|
-
this.inverseMuting = new BooleanModSetting("Start muted", "Increase volume as combo builds.", false);
|
|
4693
|
+
this.inverseMuting = new BooleanModSetting("Start muted", "inverseMuting", "Increase volume as combo builds.", false);
|
|
4715
4694
|
/**
|
|
4716
4695
|
* Add a metronome beat to help the player keep track of the rhythm.
|
|
4717
4696
|
*/
|
|
4718
|
-
this.enableMetronome = new BooleanModSetting("Enable metronome", "Add a metronome beat to help you keep track of the rhythm.", true);
|
|
4697
|
+
this.enableMetronome = new BooleanModSetting("Enable metronome", "enableMetronome", "Add a metronome beat to help you keep track of the rhythm.", true);
|
|
4719
4698
|
/**
|
|
4720
4699
|
* The combo count at which point the track reaches its final volume.
|
|
4721
4700
|
*/
|
|
4722
|
-
this.muteComboCount = new IntegerModSetting("Final volume at combo", "The combo count at which point the track reaches its final volume.", 100, 0, 500);
|
|
4701
|
+
this.muteComboCount = new IntegerModSetting("Final volume at combo", "muteComboCount", "The combo count at which point the track reaches its final volume.", 100, 0, 500);
|
|
4723
4702
|
/**
|
|
4724
4703
|
* Hit sounds are also muted alongside the track.
|
|
4725
4704
|
*/
|
|
4726
|
-
this.affectsHitSounds = new BooleanModSetting("Mute hit sounds", "Hit sounds are also muted alongside the track.", true);
|
|
4705
|
+
this.affectsHitSounds = new BooleanModSetting("Mute hit sounds", "affectsHitSounds", "Hit sounds are also muted alongside the track.", true);
|
|
4727
4706
|
this.inverseMuting.bindValueChanged((value) => {
|
|
4728
4707
|
this.muteComboCount.min = value.newValue ? 1 : 0;
|
|
4729
4708
|
}, true);
|
|
@@ -4738,27 +4717,6 @@ class ModMuted extends Mod {
|
|
|
4738
4717
|
const volume = MathUtils.clamp(combo / Math.max(1, this.muteComboCount.value), 0, 1);
|
|
4739
4718
|
return this.inverseMuting.value ? volume : 1 - volume;
|
|
4740
4719
|
}
|
|
4741
|
-
copySettings(mod) {
|
|
4742
|
-
var _a, _b, _c, _d;
|
|
4743
|
-
super.copySettings(mod);
|
|
4744
|
-
const { settings } = mod;
|
|
4745
|
-
this.inverseMuting.value =
|
|
4746
|
-
(_a = settings === null || settings === void 0 ? void 0 : settings.inverseMuting) !== null && _a !== void 0 ? _a : this.inverseMuting.value;
|
|
4747
|
-
this.enableMetronome.value =
|
|
4748
|
-
(_b = settings === null || settings === void 0 ? void 0 : settings.enableMetronome) !== null && _b !== void 0 ? _b : this.enableMetronome.value;
|
|
4749
|
-
this.muteComboCount.value =
|
|
4750
|
-
(_c = settings === null || settings === void 0 ? void 0 : settings.muteComboCount) !== null && _c !== void 0 ? _c : this.muteComboCount.value;
|
|
4751
|
-
this.affectsHitSounds.value =
|
|
4752
|
-
(_d = settings === null || settings === void 0 ? void 0 : settings.affectsHitSounds) !== null && _d !== void 0 ? _d : this.affectsHitSounds.value;
|
|
4753
|
-
}
|
|
4754
|
-
serializeSettings() {
|
|
4755
|
-
return {
|
|
4756
|
-
inverseMuting: this.inverseMuting.value,
|
|
4757
|
-
enableMetronome: this.enableMetronome.value,
|
|
4758
|
-
muteComboCount: this.muteComboCount.value,
|
|
4759
|
-
affectsHitSounds: this.affectsHitSounds.value,
|
|
4760
|
-
};
|
|
4761
|
-
}
|
|
4762
4720
|
}
|
|
4763
4721
|
|
|
4764
4722
|
/**
|
|
@@ -4772,6 +4730,7 @@ class ModSuddenDeath extends Mod {
|
|
|
4772
4730
|
this.droidRanked = true;
|
|
4773
4731
|
this.isDroidRelevant = true;
|
|
4774
4732
|
this.droidScoreMultiplier = 1;
|
|
4733
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
4775
4734
|
this.osuRanked = true;
|
|
4776
4735
|
this.isOsuRelevant = true;
|
|
4777
4736
|
this.osuScoreMultiplier = 1;
|
|
@@ -4791,6 +4750,7 @@ class ModPerfect extends Mod {
|
|
|
4791
4750
|
this.droidRanked = true;
|
|
4792
4751
|
this.isDroidRelevant = true;
|
|
4793
4752
|
this.droidScoreMultiplier = 1;
|
|
4753
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
4794
4754
|
this.osuRanked = true;
|
|
4795
4755
|
this.isOsuRelevant = true;
|
|
4796
4756
|
this.osuScoreMultiplier = 1;
|
|
@@ -4810,6 +4770,7 @@ class ModNoFail extends Mod {
|
|
|
4810
4770
|
this.droidRanked = true;
|
|
4811
4771
|
this.isDroidRelevant = true;
|
|
4812
4772
|
this.droidScoreMultiplier = 0.5;
|
|
4773
|
+
this.migrationDroidScoreMultiplier = 0.5;
|
|
4813
4774
|
this.osuRanked = true;
|
|
4814
4775
|
this.isOsuRelevant = true;
|
|
4815
4776
|
this.osuScoreMultiplier = 0.5;
|
|
@@ -4829,6 +4790,7 @@ class ModPrecise extends Mod {
|
|
|
4829
4790
|
this.droidRanked = true;
|
|
4830
4791
|
this.isDroidRelevant = true;
|
|
4831
4792
|
this.droidScoreMultiplier = 1.06;
|
|
4793
|
+
this.migrationDroidScoreMultiplier = 1.06;
|
|
4832
4794
|
}
|
|
4833
4795
|
applyToHitObject(mode, hitObject) {
|
|
4834
4796
|
var _a, _b;
|
|
@@ -4876,6 +4838,36 @@ class Utils {
|
|
|
4876
4838
|
}
|
|
4877
4839
|
return array;
|
|
4878
4840
|
}
|
|
4841
|
+
/**
|
|
4842
|
+
* Performs a binary search on an array with a custom predicate function.
|
|
4843
|
+
*
|
|
4844
|
+
* The predicate function should return:
|
|
4845
|
+
* - a negative number if the element is less than the target,
|
|
4846
|
+
* - a positive number if the element is greater than the target, and
|
|
4847
|
+
* - 0 if the element is equal to the target.
|
|
4848
|
+
*
|
|
4849
|
+
* @param array The array to search through. Must be sorted according to the predicate function.
|
|
4850
|
+
* @param predicate The predicate function to determine the order of elements.
|
|
4851
|
+
* @returns The result of the binary search.
|
|
4852
|
+
*/
|
|
4853
|
+
static binarySearch(array, predicate) {
|
|
4854
|
+
let left = 0;
|
|
4855
|
+
let right = array.length - 1;
|
|
4856
|
+
while (left <= right) {
|
|
4857
|
+
const mid = left + ((right - left) >> 1);
|
|
4858
|
+
const result = predicate(array[mid]);
|
|
4859
|
+
if (result === 0) {
|
|
4860
|
+
return { index: mid, found: true };
|
|
4861
|
+
}
|
|
4862
|
+
else if (result < 0) {
|
|
4863
|
+
left = mid + 1;
|
|
4864
|
+
}
|
|
4865
|
+
else {
|
|
4866
|
+
right = mid - 1;
|
|
4867
|
+
}
|
|
4868
|
+
}
|
|
4869
|
+
return { index: left, found: false };
|
|
4870
|
+
}
|
|
4879
4871
|
/**
|
|
4880
4872
|
* Pauses the execution of a function for
|
|
4881
4873
|
* the specified duration.
|
|
@@ -4967,8 +4959,8 @@ Random.MAX_VALUE = 2147483647;
|
|
|
4967
4959
|
* The value can be `null`, which is treated as a special case.
|
|
4968
4960
|
*/
|
|
4969
4961
|
class NullableIntegerModSetting extends RangeConstrainedModSetting {
|
|
4970
|
-
constructor(name, description, defaultValue, min = -2147483648, max = 2147483647) {
|
|
4971
|
-
super(name, description, defaultValue, min, max, 1);
|
|
4962
|
+
constructor(name, key, description, defaultValue, min = -2147483648, max = 2147483647) {
|
|
4963
|
+
super(name, key, description, defaultValue, min, max, 1);
|
|
4972
4964
|
this.displayFormatter = (v) => { var _a; return (_a = v === null || v === void 0 ? void 0 : v.toString()) !== null && _a !== void 0 ? _a : "None"; };
|
|
4973
4965
|
if (min > max) {
|
|
4974
4966
|
throw new RangeError(`The minimum value (${min.toString()}) must be less than or equal to the maximum value (${max.toString()}).`);
|
|
@@ -4978,6 +4970,23 @@ class NullableIntegerModSetting extends RangeConstrainedModSetting {
|
|
|
4978
4970
|
throw new RangeError(`The default value (${defaultValue.toString()}) must be between the minimum (${min.toString()}) and maximum (${max.toString()}) values.`);
|
|
4979
4971
|
}
|
|
4980
4972
|
}
|
|
4973
|
+
load(settings) {
|
|
4974
|
+
if (this.key === null) {
|
|
4975
|
+
return;
|
|
4976
|
+
}
|
|
4977
|
+
const stored = settings[this.key];
|
|
4978
|
+
if (stored === null || stored === undefined) {
|
|
4979
|
+
this.value = null;
|
|
4980
|
+
}
|
|
4981
|
+
else if (typeof stored === "number") {
|
|
4982
|
+
this.value = stored;
|
|
4983
|
+
}
|
|
4984
|
+
}
|
|
4985
|
+
save(settings) {
|
|
4986
|
+
if (this.key !== null) {
|
|
4987
|
+
settings[this.key] = this.value;
|
|
4988
|
+
}
|
|
4989
|
+
}
|
|
4981
4990
|
processValue(value) {
|
|
4982
4991
|
if (value === null) {
|
|
4983
4992
|
return null;
|
|
@@ -4997,29 +5006,20 @@ class ModRandom extends Mod {
|
|
|
4997
5006
|
this.droidRanked = false;
|
|
4998
5007
|
this.isDroidRelevant = true;
|
|
4999
5008
|
this.droidScoreMultiplier = 1;
|
|
5009
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
5000
5010
|
this.osuRanked = false;
|
|
5001
5011
|
this.isOsuRelevant = true;
|
|
5002
5012
|
this.osuScoreMultiplier = 1;
|
|
5003
5013
|
/**
|
|
5004
5014
|
* The seed to use.
|
|
5005
5015
|
*/
|
|
5006
|
-
this.seed = new NullableIntegerModSetting("Seed", "Use a custom seed instead of a random one.", null, 0);
|
|
5016
|
+
this.seed = new NullableIntegerModSetting("Seed", "seed", "Use a custom seed instead of a random one.", null, 0, 2147483647);
|
|
5007
5017
|
/**
|
|
5008
5018
|
* Defines how sharp the angles of `HitObject`s should be.
|
|
5009
5019
|
*/
|
|
5010
|
-
this.angleSharpness = new DecimalModSetting("Angle sharpness", "Defines how sharp the angles of hit objects should be.", 7, 1, 10, 0.1, 1);
|
|
5020
|
+
this.angleSharpness = new DecimalModSetting("Angle sharpness", "angleSharpness", "Defines how sharp the angles of hit objects should be.", 7, 1, 10, 0.1, 1);
|
|
5011
5021
|
this.random = null;
|
|
5012
5022
|
}
|
|
5013
|
-
copySettings(mod) {
|
|
5014
|
-
super.copySettings(mod);
|
|
5015
|
-
const { settings } = mod;
|
|
5016
|
-
if (typeof (settings === null || settings === void 0 ? void 0 : settings.seed) === "number") {
|
|
5017
|
-
this.seed.value = settings.seed;
|
|
5018
|
-
}
|
|
5019
|
-
if (typeof (settings === null || settings === void 0 ? void 0 : settings.angleSharpness) === "number") {
|
|
5020
|
-
this.angleSharpness.value = settings.angleSharpness;
|
|
5021
|
-
}
|
|
5022
|
-
}
|
|
5023
5023
|
applyToBeatmap(beatmap) {
|
|
5024
5024
|
var _a;
|
|
5025
5025
|
var _b;
|
|
@@ -5071,14 +5071,6 @@ class ModRandom extends Mod {
|
|
|
5071
5071
|
beatmap.hitObjects.objects[i] = repositionedHitObjects[i];
|
|
5072
5072
|
}
|
|
5073
5073
|
}
|
|
5074
|
-
serializeSettings() {
|
|
5075
|
-
const settings = {};
|
|
5076
|
-
if (this.seed.value !== null) {
|
|
5077
|
-
settings.seed = this.seed.value;
|
|
5078
|
-
}
|
|
5079
|
-
settings.angleSharpness = this.angleSharpness.value;
|
|
5080
|
-
return settings;
|
|
5081
|
-
}
|
|
5082
5074
|
getRandomOffset(stdDev) {
|
|
5083
5075
|
// Range: [0.5, 2]
|
|
5084
5076
|
// Higher angle sharpness -> lower multiplier
|
|
@@ -5154,6 +5146,7 @@ class ModScoreV2 extends Mod {
|
|
|
5154
5146
|
this.droidRanked = false;
|
|
5155
5147
|
this.isDroidRelevant = true;
|
|
5156
5148
|
this.droidScoreMultiplier = 1;
|
|
5149
|
+
this.migrationDroidScoreMultiplier = 1;
|
|
5157
5150
|
this.osuRanked = false;
|
|
5158
5151
|
this.isOsuRelevant = true;
|
|
5159
5152
|
this.osuScoreMultiplier = 1;
|
|
@@ -5187,6 +5180,7 @@ class ModSynesthesia extends Mod {
|
|
|
5187
5180
|
this.droidRanked = false;
|
|
5188
5181
|
this.isDroidRelevant = true;
|
|
5189
5182
|
this.droidScoreMultiplier = 0.8;
|
|
5183
|
+
this.migrationDroidScoreMultiplier = 0.8;
|
|
5190
5184
|
this.osuRanked = false;
|
|
5191
5185
|
this.isOsuRelevant = true;
|
|
5192
5186
|
this.osuScoreMultiplier = 0.8;
|
|
@@ -5394,21 +5388,18 @@ class ModTimeRamp extends Mod {
|
|
|
5394
5388
|
// Graph: https://www.desmos.com/calculator/1zp4vwl3o7
|
|
5395
5389
|
return Interpolation.lerp(this.calculateScoreMultiplierAt(this.initialRate.value), this.calculateScoreMultiplierAt(this.finalRate.value), ModTimeRamp.finalRateProgress);
|
|
5396
5390
|
}
|
|
5391
|
+
/**
|
|
5392
|
+
* The generic osu!droid migration score multiplier of this `Mod`.
|
|
5393
|
+
*/
|
|
5394
|
+
get migrationDroidScoreMultiplier() {
|
|
5395
|
+
return this.droidScoreMultiplier;
|
|
5396
|
+
}
|
|
5397
5397
|
constructor() {
|
|
5398
5398
|
super();
|
|
5399
5399
|
this.initialRateTime = 0;
|
|
5400
5400
|
this.finalRateTime = 0;
|
|
5401
5401
|
this.incompatibleMods.add(ModTimeRamp);
|
|
5402
5402
|
}
|
|
5403
|
-
copySettings(mod) {
|
|
5404
|
-
var _a, _b;
|
|
5405
|
-
super.copySettings(mod);
|
|
5406
|
-
const { settings } = mod;
|
|
5407
|
-
this.initialRate.value =
|
|
5408
|
-
(_a = settings === null || settings === void 0 ? void 0 : settings.initialRate) !== null && _a !== void 0 ? _a : this.initialRate.value;
|
|
5409
|
-
this.finalRate.value =
|
|
5410
|
-
(_b = settings === null || settings === void 0 ? void 0 : settings.finalRate) !== null && _b !== void 0 ? _b : this.finalRate.value;
|
|
5411
|
-
}
|
|
5412
5403
|
applyToBeatmap(beatmap) {
|
|
5413
5404
|
var _a, _b, _c, _d;
|
|
5414
5405
|
this.initialRateTime = (_b = (_a = beatmap.hitObjects.objects.at(0)) === null || _a === void 0 ? void 0 : _a.startTime) !== null && _b !== void 0 ? _b : 0;
|
|
@@ -5423,12 +5414,6 @@ class ModTimeRamp extends Mod {
|
|
|
5423
5414
|
calculateScoreMultiplierAt(rate) {
|
|
5424
5415
|
return rate > 1 ? 1 + (rate - 1) * 0.24 : Math.pow(0.3, (1 - rate) * 4);
|
|
5425
5416
|
}
|
|
5426
|
-
serializeSettings() {
|
|
5427
|
-
return {
|
|
5428
|
-
initialRate: this.initialRate.value,
|
|
5429
|
-
finalRate: this.finalRate.value,
|
|
5430
|
-
};
|
|
5431
|
-
}
|
|
5432
5417
|
toString() {
|
|
5433
5418
|
return `${super.toString()} (${this.initialRate.toDisplayString()}x - ${this.finalRate.toDisplayString()}x)`;
|
|
5434
5419
|
}
|
|
@@ -5445,6 +5430,9 @@ class ModWindDown extends ModTimeRamp {
|
|
|
5445
5430
|
get droidScoreMultiplier() {
|
|
5446
5431
|
return super.droidScoreMultiplier;
|
|
5447
5432
|
}
|
|
5433
|
+
get migrationDroidScoreMultiplier() {
|
|
5434
|
+
return super.migrationDroidScoreMultiplier;
|
|
5435
|
+
}
|
|
5448
5436
|
constructor() {
|
|
5449
5437
|
super();
|
|
5450
5438
|
this.name = "Wind Down";
|
|
@@ -5454,8 +5442,8 @@ class ModWindDown extends ModTimeRamp {
|
|
|
5454
5442
|
this.osuRanked = false;
|
|
5455
5443
|
this.isOsuRelevant = true;
|
|
5456
5444
|
this.osuScoreMultiplier = 1;
|
|
5457
|
-
this.initialRate = new DecimalModSetting("Initial rate", "The starting speed of the track.", 1, 0.51, 2, 0.01, 2);
|
|
5458
|
-
this.finalRate = new DecimalModSetting("Final rate", "The final speed to ramp to.", 0.75, 0.5, 1.99, 0.01, 2);
|
|
5445
|
+
this.initialRate = new DecimalModSetting("Initial rate", "initialRate", "The starting speed of the track.", 1, 0.51, 2, 0.01, 2);
|
|
5446
|
+
this.finalRate = new DecimalModSetting("Final rate", "finalRate", "The final speed to ramp to.", 0.75, 0.5, 1.99, 0.01, 2);
|
|
5459
5447
|
this.initialRate.bindValueChanged((value) => {
|
|
5460
5448
|
if (value.newValue <= this.finalRate.value) {
|
|
5461
5449
|
this.finalRate.value = value.newValue - this.finalRate.step;
|
|
@@ -5476,6 +5464,9 @@ class ModWindUp extends ModTimeRamp {
|
|
|
5476
5464
|
get droidScoreMultiplier() {
|
|
5477
5465
|
return super.droidScoreMultiplier;
|
|
5478
5466
|
}
|
|
5467
|
+
get migrationDroidScoreMultiplier() {
|
|
5468
|
+
return super.migrationDroidScoreMultiplier;
|
|
5469
|
+
}
|
|
5479
5470
|
constructor() {
|
|
5480
5471
|
super();
|
|
5481
5472
|
this.name = "Wind Up";
|
|
@@ -5485,8 +5476,8 @@ class ModWindUp extends ModTimeRamp {
|
|
|
5485
5476
|
this.osuRanked = false;
|
|
5486
5477
|
this.isOsuRelevant = true;
|
|
5487
5478
|
this.osuScoreMultiplier = 1;
|
|
5488
|
-
this.initialRate = new DecimalModSetting("Initial rate", "The starting speed of the track.", 1, 0.5, 1.99, 0.01, 2);
|
|
5489
|
-
this.finalRate = new DecimalModSetting("Final rate", "The final speed to ramp to.", 1.5, 0.51, 2, 0.01, 2);
|
|
5479
|
+
this.initialRate = new DecimalModSetting("Initial rate", "initialRate", "The starting speed of the track.", 1, 0.5, 1.99, 0.01, 2);
|
|
5480
|
+
this.finalRate = new DecimalModSetting("Final rate", "finalRate", "The final speed to ramp to.", 1.5, 0.51, 2, 0.01, 2);
|
|
5490
5481
|
this.initialRate.bindValueChanged((value) => {
|
|
5491
5482
|
if (value.newValue >= this.finalRate.value) {
|
|
5492
5483
|
this.finalRate.value = value.newValue + this.finalRate.step;
|
|
@@ -5528,40 +5519,62 @@ class ModUtil {
|
|
|
5528
5519
|
*
|
|
5529
5520
|
* @param mods The mods to calculate the score multiplier for.
|
|
5530
5521
|
* @param mode The game mode to calculate the score multiplier for.
|
|
5531
|
-
* @param
|
|
5522
|
+
* @param difficulty The `BeatmapDifficulty` to apply to the mods. Needed for some mods to have an effect on
|
|
5532
5523
|
* score multiplier (i.e., `ModDifficultyAdjust`).
|
|
5533
5524
|
* @returns The score multiplier.
|
|
5534
5525
|
*/
|
|
5535
|
-
static calculateScoreMultiplier(mods, mode,
|
|
5526
|
+
static calculateScoreMultiplier(mods, mode, difficulty) {
|
|
5527
|
+
return this.calculateScoreMultiplierInternal(mods, mode, (mod) => {
|
|
5528
|
+
switch (mode) {
|
|
5529
|
+
case exports.Modes.droid:
|
|
5530
|
+
return mod.isApplicableToDroid()
|
|
5531
|
+
? mod.droidScoreMultiplier
|
|
5532
|
+
: 1;
|
|
5533
|
+
case exports.Modes.osu:
|
|
5534
|
+
return mod.isApplicableToOsuStable()
|
|
5535
|
+
? mod.osuScoreMultiplier
|
|
5536
|
+
: 1;
|
|
5537
|
+
default:
|
|
5538
|
+
return 1;
|
|
5539
|
+
}
|
|
5540
|
+
}, (helper) => helper.droidScoreMultiplier, difficulty);
|
|
5541
|
+
}
|
|
5542
|
+
/**
|
|
5543
|
+
* Calculates the score multiplier for the selected `Mod`s using `Mod.migrationDroidScoreMultiplier` instead of
|
|
5544
|
+
* `Mod.droidScoreMultiplier`. Use this when reverse-engineering raw scores from stored effective scores during migration.
|
|
5545
|
+
*
|
|
5546
|
+
* @param mods The selected `Mod`s.
|
|
5547
|
+
* @return The migration score multiplier.
|
|
5548
|
+
*/
|
|
5549
|
+
static calculateMigrationScoreMultiplier(mods) {
|
|
5550
|
+
return this.calculateScoreMultiplierInternal(mods, exports.Modes.droid, (mod) => mod.isApplicableToDroid()
|
|
5551
|
+
? mod.migrationDroidScoreMultiplier
|
|
5552
|
+
: 1, (helper) => helper.migrationDroidScoreMultiplier);
|
|
5553
|
+
}
|
|
5554
|
+
static calculateScoreMultiplierInternal(mods, mode, modSelector, rateAdjustSelector, difficulty) {
|
|
5536
5555
|
// In osu!droid, rate-adjusting mods combine their track rate multipliers together, then bunched together.
|
|
5537
5556
|
let totalRateAdjustTrackRateMultiplier = 1;
|
|
5538
5557
|
let scoreMultiplier = 1;
|
|
5539
5558
|
for (const mod of mods) {
|
|
5540
|
-
if (mod.
|
|
5541
|
-
mod.
|
|
5559
|
+
if (mod.requiresBeatmapDifficulty() && difficulty) {
|
|
5560
|
+
mod.applyFromBeatmapDifficulty(difficulty);
|
|
5542
5561
|
}
|
|
5543
5562
|
if (mode === exports.Modes.droid && mod instanceof ModRateAdjust) {
|
|
5544
5563
|
totalRateAdjustTrackRateMultiplier *=
|
|
5545
5564
|
mod.trackRateMultiplier.value;
|
|
5546
5565
|
}
|
|
5547
5566
|
else {
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
break;
|
|
5554
|
-
case exports.Modes.osu:
|
|
5555
|
-
if (mod.isApplicableToOsuStable()) {
|
|
5556
|
-
scoreMultiplier *= mod.osuScoreMultiplier;
|
|
5557
|
-
}
|
|
5558
|
-
break;
|
|
5559
|
-
}
|
|
5567
|
+
const multiplierValue = modSelector(mod);
|
|
5568
|
+
scoreMultiplier =
|
|
5569
|
+
mode === exports.Modes.droid
|
|
5570
|
+
? Math.fround(scoreMultiplier * Math.fround(multiplierValue))
|
|
5571
|
+
: scoreMultiplier * multiplierValue;
|
|
5560
5572
|
}
|
|
5561
5573
|
}
|
|
5562
5574
|
if (mode === exports.Modes.droid) {
|
|
5563
5575
|
const rateAdjustHelper = new ModRateAdjustHelper(totalRateAdjustTrackRateMultiplier);
|
|
5564
|
-
scoreMultiplier
|
|
5576
|
+
scoreMultiplier = Math.fround(scoreMultiplier *
|
|
5577
|
+
Math.fround(rateAdjustSelector(rateAdjustHelper)));
|
|
5565
5578
|
}
|
|
5566
5579
|
return scoreMultiplier;
|
|
5567
5580
|
}
|
|
@@ -5724,8 +5737,8 @@ class ModUtil {
|
|
|
5724
5737
|
}
|
|
5725
5738
|
break;
|
|
5726
5739
|
case exports.Modes.osu: {
|
|
5727
|
-
const
|
|
5728
|
-
difficulty.od =
|
|
5740
|
+
const greatWindow = new OsuHitWindow(difficulty.od).greatWindow / rate;
|
|
5741
|
+
difficulty.od = (79.5 - greatWindow) / 6;
|
|
5729
5742
|
break;
|
|
5730
5743
|
}
|
|
5731
5744
|
}
|
|
@@ -7132,10 +7145,10 @@ class Beatmap {
|
|
|
7132
7145
|
*/
|
|
7133
7146
|
maxDroidScore(mods) {
|
|
7134
7147
|
const scoreMultiplier = mods
|
|
7135
|
-
? ModUtil.calculateScoreMultiplier(mods.values(), exports.Modes.droid, this)
|
|
7148
|
+
? ModUtil.calculateScoreMultiplier(mods.values(), exports.Modes.droid, this.difficulty)
|
|
7136
7149
|
: 1;
|
|
7137
7150
|
if (mods === null || mods === void 0 ? void 0 : mods.has(ModScoreV2)) {
|
|
7138
|
-
return 1e6 * scoreMultiplier;
|
|
7151
|
+
return Math.round(Math.fround(1e6 * scoreMultiplier));
|
|
7139
7152
|
}
|
|
7140
7153
|
const difficultyMultiplier = 1 +
|
|
7141
7154
|
this.difficulty.od / 10 +
|
|
@@ -7143,27 +7156,39 @@ class Beatmap {
|
|
|
7143
7156
|
(this.difficulty.cs - 3) / 4;
|
|
7144
7157
|
let combo = 0;
|
|
7145
7158
|
let score = 0;
|
|
7159
|
+
// Spinners need non-rate adjusted to calculate required spins.
|
|
7160
|
+
const nonRateAdjustedDifficulty = new BeatmapDifficulty(this.difficulty);
|
|
7161
|
+
if (mods) {
|
|
7162
|
+
ModUtil.applyModsToBeatmapDifficulty(nonRateAdjustedDifficulty, exports.Modes.droid, mods);
|
|
7163
|
+
}
|
|
7146
7164
|
for (const object of this.hitObjects.objects) {
|
|
7147
|
-
if (
|
|
7165
|
+
if (object instanceof Slider) {
|
|
7166
|
+
const { ticks } = object;
|
|
7167
|
+
// Apply slider head.
|
|
7168
|
+
score += 30;
|
|
7169
|
+
++combo;
|
|
7170
|
+
// Apply slider repeats.
|
|
7171
|
+
score += 30 * object.repeatCount;
|
|
7172
|
+
combo += object.repeatCount;
|
|
7173
|
+
// Apply slider ticks.
|
|
7174
|
+
score += 10 * ticks;
|
|
7175
|
+
combo += ticks;
|
|
7176
|
+
// Apply slider end.
|
|
7148
7177
|
score += Math.floor(300 + (300 * combo * difficultyMultiplier) / 25);
|
|
7149
7178
|
++combo;
|
|
7150
|
-
continue;
|
|
7151
7179
|
}
|
|
7152
|
-
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7159
|
-
|
|
7160
|
-
score += 10 * ticks;
|
|
7161
|
-
combo += ticks;
|
|
7162
|
-
// Apply slider end.
|
|
7180
|
+
else if (object instanceof Spinner) {
|
|
7181
|
+
// For each required rotations, a spinner tick (100 score) is awarded, but does not contribute to combo.
|
|
7182
|
+
const minRps = 2 + (2 * nonRateAdjustedDifficulty.od) / 10;
|
|
7183
|
+
const requiredRotations = Math.trunc((minRps * object.duration) / 1000);
|
|
7184
|
+
for (let i = 0; i < requiredRotations; ++i) {
|
|
7185
|
+
score += 100;
|
|
7186
|
+
}
|
|
7187
|
+
}
|
|
7163
7188
|
score += Math.floor(300 + (300 * combo * difficultyMultiplier) / 25);
|
|
7164
7189
|
++combo;
|
|
7165
7190
|
}
|
|
7166
|
-
return Math.
|
|
7191
|
+
return Math.round(Math.fround(score * scoreMultiplier));
|
|
7167
7192
|
}
|
|
7168
7193
|
/**
|
|
7169
7194
|
* Calculates the osu!standard maximum score of the beatmap without taking spinner bonus into account.
|
|
@@ -7174,7 +7199,7 @@ class Beatmap {
|
|
|
7174
7199
|
const accumulatedDiffPoints = this.difficulty.cs + this.difficulty.hp + this.difficulty.od;
|
|
7175
7200
|
let difficultyMultiplier = 2;
|
|
7176
7201
|
const scoreMultiplier = mods
|
|
7177
|
-
? ModUtil.calculateScoreMultiplier(mods.values(), exports.Modes.osu, this)
|
|
7202
|
+
? ModUtil.calculateScoreMultiplier(mods.values(), exports.Modes.osu, this.difficulty)
|
|
7178
7203
|
: 1;
|
|
7179
7204
|
if (mods === null || mods === void 0 ? void 0 : mods.has(ModScoreV2)) {
|
|
7180
7205
|
return 1e6 * scoreMultiplier;
|
|
@@ -7198,25 +7223,34 @@ class Beatmap {
|
|
|
7198
7223
|
}
|
|
7199
7224
|
let combo = 0;
|
|
7200
7225
|
let score = 0;
|
|
7226
|
+
// Spinners need non-rate adjusted to calculate required spins.
|
|
7227
|
+
const nonRateAdjustedDifficulty = new BeatmapDifficulty(this.difficulty);
|
|
7228
|
+
if (mods) {
|
|
7229
|
+
ModUtil.applyModsToBeatmapDifficulty(nonRateAdjustedDifficulty, exports.Modes.osu, mods);
|
|
7230
|
+
}
|
|
7201
7231
|
for (const object of this.hitObjects.objects) {
|
|
7202
|
-
if (
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
|
|
7232
|
+
if (object instanceof Slider) {
|
|
7233
|
+
const { ticks } = object;
|
|
7234
|
+
// Apply slider head.
|
|
7235
|
+
score += 30;
|
|
7206
7236
|
++combo;
|
|
7207
|
-
|
|
7237
|
+
// Apply slider repeats.
|
|
7238
|
+
score += 30 * object.repeatCount;
|
|
7239
|
+
combo += object.repeatCount;
|
|
7240
|
+
// Apply slider ticks.
|
|
7241
|
+
score += 10 * ticks;
|
|
7242
|
+
combo += ticks;
|
|
7243
|
+
// Apply slider end.
|
|
7244
|
+
score += 30;
|
|
7245
|
+
}
|
|
7246
|
+
else if (object instanceof Spinner) {
|
|
7247
|
+
// For each required rotations, a spinner tick (100 score) is awarded, but does not contribute to combo.
|
|
7248
|
+
const minRps = BeatmapDifficulty.difficultyRange(nonRateAdjustedDifficulty.od, 90, 150, 225);
|
|
7249
|
+
const requiredRotations = Math.trunc((minRps * object.duration) / 1000);
|
|
7250
|
+
for (let i = 0; i < requiredRotations; ++i) {
|
|
7251
|
+
score += 100;
|
|
7252
|
+
}
|
|
7208
7253
|
}
|
|
7209
|
-
const { ticks } = object;
|
|
7210
|
-
// Apply slider head.
|
|
7211
|
-
score += 30;
|
|
7212
|
-
++combo;
|
|
7213
|
-
// Apply slider repeats.
|
|
7214
|
-
score += 30 * object.repeatCount;
|
|
7215
|
-
combo += object.repeatCount;
|
|
7216
|
-
// Apply slider ticks.
|
|
7217
|
-
score += 10 * ticks;
|
|
7218
|
-
combo += ticks;
|
|
7219
|
-
// Apply slider end.
|
|
7220
7254
|
score += Math.floor(300 +
|
|
7221
7255
|
(300 * combo * difficultyMultiplier * scoreMultiplier) / 25);
|
|
7222
7256
|
++combo;
|
|
@@ -7343,16 +7377,6 @@ class Beatmap {
|
|
|
7343
7377
|
}
|
|
7344
7378
|
}
|
|
7345
7379
|
|
|
7346
|
-
/**
|
|
7347
|
-
* Represents a beatmap's background.
|
|
7348
|
-
*/
|
|
7349
|
-
class BeatmapBackground {
|
|
7350
|
-
constructor(filename, offset) {
|
|
7351
|
-
this.filename = filename;
|
|
7352
|
-
this.offset = offset;
|
|
7353
|
-
}
|
|
7354
|
-
}
|
|
7355
|
-
|
|
7356
7380
|
/* eslint-disable @typescript-eslint/prefer-literal-enum-member */
|
|
7357
7381
|
/**
|
|
7358
7382
|
* Represents available hitsound types.
|
|
@@ -7708,7 +7732,7 @@ class BeatmapHitObjectsDecoder extends SectionDecoder {
|
|
|
7708
7732
|
if (points.length !== 3) {
|
|
7709
7733
|
pathType = exports.PathType.Bezier;
|
|
7710
7734
|
}
|
|
7711
|
-
else if (Precision.
|
|
7735
|
+
else if (Precision.almostEquals(0, (points[1].y - points[0].y) *
|
|
7712
7736
|
(points[2].x - points[0].x) -
|
|
7713
7737
|
(points[1].x - points[0].x) *
|
|
7714
7738
|
(points[2].y - points[0].y))) {
|
|
@@ -7969,6 +7993,16 @@ class BeatmapEditorDecoder extends SectionDecoder {
|
|
|
7969
7993
|
}
|
|
7970
7994
|
}
|
|
7971
7995
|
|
|
7996
|
+
/**
|
|
7997
|
+
* Represents a beatmap's background.
|
|
7998
|
+
*/
|
|
7999
|
+
class BeatmapBackground {
|
|
8000
|
+
constructor(filename, offset) {
|
|
8001
|
+
this.filename = filename;
|
|
8002
|
+
this.offset = offset;
|
|
8003
|
+
}
|
|
8004
|
+
}
|
|
8005
|
+
|
|
7972
8006
|
/**
|
|
7973
8007
|
* Represents a beatmap's video.
|
|
7974
8008
|
*/
|
|
@@ -8063,16 +8097,16 @@ class BeatmapDifficultyDecoder extends SectionDecoder {
|
|
|
8063
8097
|
const p = this.property(line);
|
|
8064
8098
|
switch (p[0]) {
|
|
8065
8099
|
case "CircleSize":
|
|
8066
|
-
this.target.difficulty.cs = this.tryParseFloat(this.setPosition(p[1]));
|
|
8100
|
+
this.target.difficulty.cs = MathUtils.clamp(this.tryParseFloat(this.setPosition(p[1])), 0, 10);
|
|
8067
8101
|
break;
|
|
8068
8102
|
case "OverallDifficulty":
|
|
8069
|
-
this.target.difficulty.od = this.tryParseFloat(this.setPosition(p[1]));
|
|
8103
|
+
this.target.difficulty.od = MathUtils.clamp(this.tryParseFloat(this.setPosition(p[1])), 0, 10);
|
|
8070
8104
|
break;
|
|
8071
8105
|
case "ApproachRate":
|
|
8072
|
-
this.target.difficulty.ar = this.tryParseFloat(this.setPosition(p[1]));
|
|
8106
|
+
this.target.difficulty.ar = MathUtils.clamp(this.tryParseFloat(this.setPosition(p[1])), 0, 10);
|
|
8073
8107
|
break;
|
|
8074
8108
|
case "HPDrainRate":
|
|
8075
|
-
this.target.difficulty.hp = this.tryParseFloat(this.setPosition(p[1]));
|
|
8109
|
+
this.target.difficulty.hp = MathUtils.clamp(this.tryParseFloat(this.setPosition(p[1])), 0, 10);
|
|
8076
8110
|
break;
|
|
8077
8111
|
case "SliderMultiplier":
|
|
8078
8112
|
this.target.difficulty.sliderMultiplier = MathUtils.clamp(this.tryParseFloat(this.setPosition(p[1])), 0.4, 3.6);
|
|
@@ -8903,6 +8937,15 @@ class StoryboardSample extends StoryboardElement {
|
|
|
8903
8937
|
}
|
|
8904
8938
|
}
|
|
8905
8939
|
|
|
8940
|
+
/**
|
|
8941
|
+
* The loop type of storyboard animations.
|
|
8942
|
+
*/
|
|
8943
|
+
exports.AnimationLoopType = void 0;
|
|
8944
|
+
(function (AnimationLoopType) {
|
|
8945
|
+
AnimationLoopType["loopForever"] = "LoopForever";
|
|
8946
|
+
AnimationLoopType["loopOnce"] = "LoopOnce";
|
|
8947
|
+
})(exports.AnimationLoopType || (exports.AnimationLoopType = {}));
|
|
8948
|
+
|
|
8906
8949
|
/**
|
|
8907
8950
|
* Types of storyboard events.
|
|
8908
8951
|
*/
|
|
@@ -10033,47 +10076,132 @@ class BeatmapEncoder extends Encoder {
|
|
|
10033
10076
|
}
|
|
10034
10077
|
|
|
10035
10078
|
/**
|
|
10036
|
-
*
|
|
10079
|
+
* Represents the hit window of osu!standard that does not apply flooring and half-millisecond adjustments.
|
|
10080
|
+
*
|
|
10081
|
+
* **This class is only used for osu!droid difficulty calculation and will be removed later**.
|
|
10037
10082
|
*/
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
|
|
10048
|
-
|
|
10049
|
-
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10054
|
-
|
|
10083
|
+
class UnadjustedOsuHitWindow extends HitWindow {
|
|
10084
|
+
/**
|
|
10085
|
+
* Calculates the overall difficulty value of a great (300) hit window.
|
|
10086
|
+
*
|
|
10087
|
+
* @param value The value of the hit window, in milliseconds.
|
|
10088
|
+
* @returns The overall difficulty value.
|
|
10089
|
+
*/
|
|
10090
|
+
static greatWindowToOD(value) {
|
|
10091
|
+
return (80 - value) / 6;
|
|
10092
|
+
}
|
|
10093
|
+
/**
|
|
10094
|
+
* Calculates the overall difficulty value of a good (100) hit window.
|
|
10095
|
+
*
|
|
10096
|
+
* @param value The value of the hit window, in milliseconds.
|
|
10097
|
+
* @returns The overall difficulty value.
|
|
10098
|
+
*/
|
|
10099
|
+
static okWindowToOD(value) {
|
|
10100
|
+
return (140 - value) / 8;
|
|
10101
|
+
}
|
|
10102
|
+
/**
|
|
10103
|
+
* Calculates the overall difficulty value of a meh hit window.
|
|
10104
|
+
*
|
|
10105
|
+
* @param value The value of the hit window, in milliseconds.
|
|
10106
|
+
* @returns The overall difficulty value.
|
|
10107
|
+
*/
|
|
10108
|
+
static mehWindowToOD(value) {
|
|
10109
|
+
return (200 - value) / 10;
|
|
10110
|
+
}
|
|
10111
|
+
get greatWindow() {
|
|
10112
|
+
return 80 - 6 * this.overallDifficulty;
|
|
10113
|
+
}
|
|
10114
|
+
get okWindow() {
|
|
10115
|
+
return 140 - 8 * this.overallDifficulty;
|
|
10116
|
+
}
|
|
10117
|
+
get mehWindow() {
|
|
10118
|
+
return 200 - 10 * this.overallDifficulty;
|
|
10119
|
+
}
|
|
10120
|
+
}
|
|
10055
10121
|
|
|
10056
10122
|
/**
|
|
10057
|
-
*
|
|
10123
|
+
* General enum to specify an "anchor" or "origin" point from the standard 9 points on a rectangle.
|
|
10058
10124
|
*/
|
|
10059
|
-
exports.
|
|
10060
|
-
(function (
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10125
|
+
exports.Anchor = void 0;
|
|
10126
|
+
(function (Anchor) {
|
|
10127
|
+
Anchor["topLeft"] = "TopLeft";
|
|
10128
|
+
Anchor["center"] = "Centre";
|
|
10129
|
+
Anchor["centerLeft"] = "CentreLeft";
|
|
10130
|
+
Anchor["topRight"] = "TopRight";
|
|
10131
|
+
Anchor["bottomCenter"] = "BottomCentre";
|
|
10132
|
+
Anchor["topCenter"] = "TopCentre";
|
|
10133
|
+
/**
|
|
10134
|
+
* The user is manually updating the outcome, so we shouldn't.
|
|
10135
|
+
*/
|
|
10136
|
+
Anchor["custom"] = "Custom";
|
|
10137
|
+
Anchor["centerRight"] = "CentreRight";
|
|
10138
|
+
Anchor["bottomLeft"] = "BottomLeft";
|
|
10139
|
+
Anchor["bottomRight"] = "BottomRight";
|
|
10140
|
+
})(exports.Anchor || (exports.Anchor = {}));
|
|
10141
|
+
|
|
10142
|
+
/**
|
|
10143
|
+
* Ranking status of a beatmap.
|
|
10144
|
+
*/
|
|
10145
|
+
exports.RankedStatus = void 0;
|
|
10146
|
+
(function (RankedStatus) {
|
|
10147
|
+
RankedStatus[RankedStatus["graveyard"] = -2] = "graveyard";
|
|
10148
|
+
RankedStatus[RankedStatus["wip"] = -1] = "wip";
|
|
10149
|
+
RankedStatus[RankedStatus["pending"] = 0] = "pending";
|
|
10150
|
+
RankedStatus[RankedStatus["ranked"] = 1] = "ranked";
|
|
10151
|
+
RankedStatus[RankedStatus["approved"] = 2] = "approved";
|
|
10152
|
+
RankedStatus[RankedStatus["qualified"] = 3] = "qualified";
|
|
10153
|
+
RankedStatus[RankedStatus["loved"] = 4] = "loved";
|
|
10154
|
+
})(exports.RankedStatus || (exports.RankedStatus = {}));
|
|
10155
|
+
|
|
10156
|
+
class Bin {
|
|
10157
|
+
constructor() {
|
|
10158
|
+
this.difficulty = 0;
|
|
10159
|
+
this.time = 0;
|
|
10160
|
+
this.noteCount = 0;
|
|
10161
|
+
}
|
|
10162
|
+
/**
|
|
10163
|
+
* Creates a 2D grid of bins using bilinear interpolation.
|
|
10164
|
+
*
|
|
10165
|
+
* Notes are distributed across neighboring bins weighted by their fractional position.
|
|
10166
|
+
*/
|
|
10167
|
+
static createBins(difficulties, times, difficultyDimensionLength, timeDimensionLength) {
|
|
10168
|
+
const maxDifficulty = MathUtils.max(difficulties);
|
|
10169
|
+
const endTime = MathUtils.max(times);
|
|
10170
|
+
const bins = Utils.initializeArray(timeDimensionLength * difficultyDimensionLength, () => new Bin());
|
|
10171
|
+
for (let timeIndex = 0; timeIndex < timeDimensionLength; ++timeIndex) {
|
|
10172
|
+
const time = (endTime * timeIndex) / (timeDimensionLength - 1);
|
|
10173
|
+
for (let diffIndex = 0; diffIndex < difficultyDimensionLength; ++diffIndex) {
|
|
10174
|
+
const binIndex = difficultyDimensionLength * timeIndex + diffIndex;
|
|
10175
|
+
bins[binIndex].time = time;
|
|
10176
|
+
// We do not create a 0 difficulty bin because 0 difficulty notes do not contribute to star rating.
|
|
10177
|
+
bins[binIndex].difficulty =
|
|
10178
|
+
(maxDifficulty * (diffIndex + 1)) /
|
|
10179
|
+
difficultyDimensionLength;
|
|
10180
|
+
}
|
|
10181
|
+
}
|
|
10182
|
+
for (let noteIndex = 0; noteIndex < difficulties.length; ++noteIndex) {
|
|
10183
|
+
const timeBinIndex = timeDimensionLength * (times[noteIndex] / endTime);
|
|
10184
|
+
const difficultyBinIndex = difficultyDimensionLength *
|
|
10185
|
+
(difficulties[noteIndex] / maxDifficulty) -
|
|
10186
|
+
1;
|
|
10187
|
+
const timeLower = Math.min(Math.trunc(timeBinIndex), timeDimensionLength - 1);
|
|
10188
|
+
const timeUpper = Math.min(timeLower + 1, timeDimensionLength - 1);
|
|
10189
|
+
const timeWeight = timeBinIndex - timeLower;
|
|
10190
|
+
const difficultyLower = Math.floor(difficultyBinIndex);
|
|
10191
|
+
const difficultyUpper = Math.min(difficultyLower + 1, difficultyDimensionLength - 1);
|
|
10192
|
+
const difficultyWeight = difficultyBinIndex - difficultyLower;
|
|
10193
|
+
// The lower bound of difficulty can be -1, corresponding to buckets with 0 difficulty.
|
|
10194
|
+
// We do not store those since they do not contribute to star rating.
|
|
10195
|
+
if (difficultyLower >= 0) {
|
|
10196
|
+
bins[difficultyDimensionLength * timeLower + difficultyLower].noteCount += (1 - timeWeight) * (1 - difficultyWeight);
|
|
10197
|
+
bins[difficultyDimensionLength * timeUpper + difficultyLower].noteCount += timeWeight * (1 - difficultyWeight);
|
|
10198
|
+
}
|
|
10199
|
+
bins[difficultyDimensionLength * timeLower + difficultyUpper].noteCount += (1 - timeWeight) * difficultyWeight;
|
|
10200
|
+
bins[difficultyDimensionLength * timeUpper + difficultyUpper].noteCount += timeWeight * difficultyWeight;
|
|
10201
|
+
}
|
|
10202
|
+
return bins;
|
|
10203
|
+
}
|
|
10204
|
+
}
|
|
10077
10205
|
|
|
10078
10206
|
class ZeroCrossingBracketing {
|
|
10079
10207
|
/**
|
|
@@ -10305,363 +10433,339 @@ class Brent {
|
|
|
10305
10433
|
}
|
|
10306
10434
|
}
|
|
10307
10435
|
|
|
10308
|
-
/******************************************************************************
|
|
10309
|
-
Copyright (c) Microsoft Corporation.
|
|
10310
|
-
|
|
10311
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
10312
|
-
purpose with or without fee is hereby granted.
|
|
10313
|
-
|
|
10314
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10315
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10316
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10317
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
10318
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
10319
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
10320
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
10321
|
-
***************************************************************************** */
|
|
10322
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
10323
|
-
|
|
10324
|
-
|
|
10325
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
10326
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10327
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10328
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
10329
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10330
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10331
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10332
|
-
});
|
|
10333
|
-
}
|
|
10334
|
-
|
|
10335
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
10336
|
-
var e = new Error(message);
|
|
10337
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
10338
|
-
};
|
|
10339
|
-
|
|
10340
10436
|
/**
|
|
10341
|
-
*
|
|
10437
|
+
* {@link https://www.sciencedirect.com/science/article/abs/pii/S0965997896000518?via%3Dihub Chandrupatla}'s root-finding algorithm.
|
|
10342
10438
|
*/
|
|
10343
|
-
|
|
10344
|
-
class APIRequestBuilder {
|
|
10345
|
-
constructor() {
|
|
10346
|
-
/**
|
|
10347
|
-
* Whether or not to include the API key in the request URL.
|
|
10348
|
-
*/
|
|
10349
|
-
this.requiresAPIkey = true;
|
|
10350
|
-
/**
|
|
10351
|
-
* The endpoint of this builder.
|
|
10352
|
-
*/
|
|
10353
|
-
this.endpoint = "";
|
|
10354
|
-
/**
|
|
10355
|
-
* The parameters of this builder.
|
|
10356
|
-
*/
|
|
10357
|
-
this.params = new Map();
|
|
10358
|
-
this.fetchAttempts = 0;
|
|
10359
|
-
}
|
|
10360
|
-
/**
|
|
10361
|
-
* The base URL of this builder.
|
|
10362
|
-
*/
|
|
10363
|
-
get baseURL() {
|
|
10364
|
-
return this.host + this.endpoint;
|
|
10365
|
-
}
|
|
10439
|
+
class Chandrupatla {
|
|
10366
10440
|
/**
|
|
10367
|
-
*
|
|
10441
|
+
* Finds the root of a function using {@link https://www.sciencedirect.com/science/article/abs/pii/S0965997896000518?via%3Dihub Chandrupatla}'s
|
|
10442
|
+
* method, expanding the bounds if the root is not located within.
|
|
10368
10443
|
*
|
|
10369
|
-
*
|
|
10370
|
-
|
|
10371
|
-
setEndpoint(endpoint) {
|
|
10372
|
-
this.endpoint = endpoint;
|
|
10373
|
-
return this;
|
|
10374
|
-
}
|
|
10375
|
-
/**
|
|
10376
|
-
* Sets if this builder includes the API key in the request URL.
|
|
10444
|
+
* Expansion only occurs for the upward bound, as this function is optimized for functions of range [0, x), which is
|
|
10445
|
+
* useful for finding positive roots.
|
|
10377
10446
|
*
|
|
10378
|
-
* @param
|
|
10379
|
-
|
|
10380
|
-
|
|
10381
|
-
|
|
10382
|
-
|
|
10383
|
-
}
|
|
10384
|
-
/**
|
|
10385
|
-
* Builds the URL to request the API.
|
|
10447
|
+
* @param f The function of which to find the root.
|
|
10448
|
+
* @param guessLowerBound The lower bound of the function inputs.
|
|
10449
|
+
* @param guessUpperBound The upper bound of the function inputs.
|
|
10450
|
+
* @param options Options for the root-finding algorithm.
|
|
10451
|
+
* @returns The root of the function.
|
|
10386
10452
|
*/
|
|
10387
|
-
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10453
|
+
static findRootExpand(f, guessLowerBound, guessUpperBound, options) {
|
|
10454
|
+
const { maxIterations = 25, accuracy = 1e-6, expansionFactor = 2, maxExpansions = 32, } = options !== null && options !== void 0 ? options : {};
|
|
10455
|
+
let a = guessLowerBound;
|
|
10456
|
+
let b = guessUpperBound;
|
|
10457
|
+
let fa = f(a);
|
|
10458
|
+
let fb = f(b);
|
|
10459
|
+
let expansions = 0;
|
|
10460
|
+
while (fa * fb > 0) {
|
|
10461
|
+
a = b;
|
|
10462
|
+
b *= expansionFactor;
|
|
10463
|
+
fa = fb;
|
|
10464
|
+
fb = f(b);
|
|
10465
|
+
++expansions;
|
|
10466
|
+
if (expansions > maxExpansions) {
|
|
10467
|
+
throw new Error("Chandrupatla: Maximum number of expansions exceeded.");
|
|
10392
10468
|
}
|
|
10393
|
-
url += this.APIkeyParam;
|
|
10394
10469
|
}
|
|
10395
|
-
|
|
10396
|
-
|
|
10470
|
+
let t = 0.5;
|
|
10471
|
+
for (let i = 0; i < maxIterations; ++i) {
|
|
10472
|
+
const xt = a + t * (b - a);
|
|
10473
|
+
const ft = f(xt);
|
|
10474
|
+
let c;
|
|
10475
|
+
let fc;
|
|
10476
|
+
if (Math.sign(ft) == Math.sign(fa)) {
|
|
10477
|
+
c = a;
|
|
10478
|
+
fc = fa;
|
|
10479
|
+
}
|
|
10480
|
+
else {
|
|
10481
|
+
c = b;
|
|
10482
|
+
b = a;
|
|
10483
|
+
fc = fb;
|
|
10484
|
+
fb = fa;
|
|
10485
|
+
}
|
|
10486
|
+
a = xt;
|
|
10487
|
+
fa = ft;
|
|
10488
|
+
let xm;
|
|
10489
|
+
let fm;
|
|
10490
|
+
if (Math.abs(fa) < Math.abs(fb)) {
|
|
10491
|
+
xm = a;
|
|
10492
|
+
fm = fa;
|
|
10493
|
+
}
|
|
10494
|
+
else {
|
|
10495
|
+
xm = b;
|
|
10496
|
+
fm = fb;
|
|
10497
|
+
}
|
|
10498
|
+
if (fm == 0) {
|
|
10499
|
+
return xm;
|
|
10500
|
+
}
|
|
10501
|
+
const tol = 2 * accuracy * Math.abs(xm) + 2 * accuracy;
|
|
10502
|
+
const tlim = tol / Math.abs(b - c);
|
|
10503
|
+
if (tlim > 0.5) {
|
|
10504
|
+
return xm;
|
|
10505
|
+
}
|
|
10506
|
+
const chi = (a - b) / (c - b);
|
|
10507
|
+
const phi = (fa - fb) / (fc - fb);
|
|
10508
|
+
const iqi = phi * phi < chi && (1 - phi) * (1 - phi) < chi;
|
|
10509
|
+
if (iqi) {
|
|
10510
|
+
t =
|
|
10511
|
+
((fa / (fb - fa)) * fc) / (fb - fc) +
|
|
10512
|
+
(((((c - a) / (b - a)) * fa) / (fc - fa)) * fb) / (fc - fb);
|
|
10513
|
+
}
|
|
10514
|
+
else {
|
|
10515
|
+
t = 0.5;
|
|
10516
|
+
}
|
|
10517
|
+
t = Math.min(1 - tlim, Math.max(tlim, t));
|
|
10397
10518
|
}
|
|
10398
|
-
return
|
|
10519
|
+
return 0;
|
|
10399
10520
|
}
|
|
10521
|
+
}
|
|
10522
|
+
|
|
10523
|
+
/**
|
|
10524
|
+
* A single-variable polynomial with real-valued coefficients and non-negative exponents.
|
|
10525
|
+
*
|
|
10526
|
+
* This class shares the same implementation as {@link https://numerics.mathdotnet.com/ Math.NET Numerics}.
|
|
10527
|
+
*/
|
|
10528
|
+
class Polynomial {
|
|
10400
10529
|
/**
|
|
10401
|
-
*
|
|
10530
|
+
* Evaluates a polynomial at point `z`.
|
|
10402
10531
|
*
|
|
10403
|
-
*
|
|
10404
|
-
|
|
10405
|
-
sendRequest() {
|
|
10406
|
-
return new Promise((resolve) => {
|
|
10407
|
-
const url = this.buildURL();
|
|
10408
|
-
fetch(url)
|
|
10409
|
-
.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
10410
|
-
++this.fetchAttempts;
|
|
10411
|
-
if (res.status >= 500 && this.fetchAttempts < 5) {
|
|
10412
|
-
console.error(`Request to ${url} failed with the following error: ${yield res.text()}; ${this.fetchAttempts.toString()} attempts so far; retrying`);
|
|
10413
|
-
resolve(this.sendRequest());
|
|
10414
|
-
return;
|
|
10415
|
-
}
|
|
10416
|
-
this.fetchAttempts = 0;
|
|
10417
|
-
resolve({
|
|
10418
|
-
data: Buffer.from(yield res.arrayBuffer()),
|
|
10419
|
-
statusCode: res.status,
|
|
10420
|
-
});
|
|
10421
|
-
}))
|
|
10422
|
-
.catch((e) => {
|
|
10423
|
-
console.error(`Request to ${url} failed with the following error: ${e.message}; ${this.fetchAttempts.toString()} attempts so far; aborting`);
|
|
10424
|
-
this.fetchAttempts = 0;
|
|
10425
|
-
resolve({
|
|
10426
|
-
data: Buffer.from([]),
|
|
10427
|
-
statusCode: 400,
|
|
10428
|
-
});
|
|
10429
|
-
return;
|
|
10430
|
-
});
|
|
10431
|
-
});
|
|
10432
|
-
}
|
|
10433
|
-
/**
|
|
10434
|
-
* Adds a parameter to the builder.
|
|
10532
|
+
* Coefficients are ordered ascending by power with power `k` at index `k`.
|
|
10533
|
+
* For example, coefficients `[3, -1, 2]` represent `y = 2x^2 - x + 3`.
|
|
10435
10534
|
*
|
|
10436
|
-
* @param
|
|
10437
|
-
* @param
|
|
10535
|
+
* @param z The location where to evaluate the polynomial at.
|
|
10536
|
+
* @param coefficients The coefficients of the polynomial, coefficient for power `k` at index `k`.
|
|
10537
|
+
* @returns The polynomial at `z`.
|
|
10438
10538
|
*/
|
|
10439
|
-
|
|
10440
|
-
|
|
10441
|
-
|
|
10539
|
+
static evaluate(z, coefficients) {
|
|
10540
|
+
// Zero polynomials need explicit handling, otherwise we
|
|
10541
|
+
// will attempt to peek coefficients at negative indices.
|
|
10542
|
+
if (coefficients.length === 0) {
|
|
10543
|
+
return 0;
|
|
10544
|
+
}
|
|
10545
|
+
let sum = coefficients.at(-1);
|
|
10546
|
+
for (let i = coefficients.length - 2; i >= 0; --i) {
|
|
10547
|
+
sum *= z;
|
|
10548
|
+
sum += coefficients[i];
|
|
10549
|
+
}
|
|
10550
|
+
return sum;
|
|
10442
10551
|
}
|
|
10443
10552
|
/**
|
|
10444
|
-
*
|
|
10553
|
+
* Solve for the exact real roots of any polynomial up to degree 4.
|
|
10445
10554
|
*
|
|
10446
|
-
* @param
|
|
10555
|
+
* @param coefficients The coefficients of the polynomial, in ascending order ([1, 3, 5] -> x^2 + 3x + 5).
|
|
10556
|
+
* @returns The real roots of the polynomial, and `null` if the root does not exist.
|
|
10447
10557
|
*/
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10558
|
+
static solve(coefficients) {
|
|
10559
|
+
let xVals = [];
|
|
10560
|
+
switch (coefficients.length) {
|
|
10561
|
+
case 5:
|
|
10562
|
+
xVals = this.solveP4(coefficients[0], coefficients[1], coefficients[2], coefficients[3], coefficients[4]).roots;
|
|
10563
|
+
break;
|
|
10564
|
+
case 4:
|
|
10565
|
+
xVals = this.solveP3(coefficients[0], coefficients[1], coefficients[2], coefficients[3]).roots;
|
|
10566
|
+
break;
|
|
10567
|
+
case 3:
|
|
10568
|
+
xVals = this.solveP2(coefficients[0], coefficients[1], coefficients[2]).roots;
|
|
10569
|
+
break;
|
|
10570
|
+
case 2:
|
|
10571
|
+
xVals = this.solveP2(0, coefficients[0], coefficients[1]).roots;
|
|
10572
|
+
break;
|
|
10573
|
+
}
|
|
10574
|
+
return xVals;
|
|
10451
10575
|
}
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
|
|
10459
|
-
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
|
|
10576
|
+
// https://github.com/sasamil/Quartic/blob/master/quartic.cpp
|
|
10577
|
+
static solveP4(a, b, c, d, e) {
|
|
10578
|
+
const result = {
|
|
10579
|
+
count: 0,
|
|
10580
|
+
roots: new Array(4),
|
|
10581
|
+
};
|
|
10582
|
+
if (a === 0) {
|
|
10583
|
+
const xValsCubic = this.solveP3(b, c, d, e);
|
|
10584
|
+
result.count = xValsCubic.count;
|
|
10585
|
+
result.roots[0] = xValsCubic.roots[0];
|
|
10586
|
+
result.roots[1] = xValsCubic.roots[1];
|
|
10587
|
+
result.roots[2] = xValsCubic.roots[2];
|
|
10588
|
+
result.roots[3] = null;
|
|
10589
|
+
return result;
|
|
10590
|
+
}
|
|
10591
|
+
b /= a;
|
|
10592
|
+
c /= a;
|
|
10593
|
+
d /= a;
|
|
10594
|
+
e /= a;
|
|
10595
|
+
const a3 = -c;
|
|
10596
|
+
const b3 = b * d - 4 * e;
|
|
10597
|
+
const c3 = -b * b * e - d * d + 4 * c * e;
|
|
10598
|
+
const x3 = this.solveP3(1, a3, b3, c3);
|
|
10599
|
+
let q1;
|
|
10600
|
+
let q2;
|
|
10601
|
+
let p1;
|
|
10602
|
+
let p2;
|
|
10603
|
+
let sqD;
|
|
10604
|
+
let y = x3.roots[0];
|
|
10605
|
+
// Get the y value with the highest absolute value.
|
|
10606
|
+
if (x3.count !== 1) {
|
|
10607
|
+
if (Math.abs(x3.roots[1]) > Math.abs(y)) {
|
|
10608
|
+
y = x3.roots[1];
|
|
10609
|
+
}
|
|
10610
|
+
if (Math.abs(x3.roots[2]) > Math.abs(y)) {
|
|
10611
|
+
y = x3.roots[2];
|
|
10612
|
+
}
|
|
10613
|
+
}
|
|
10614
|
+
let upperD = y * y - 4 * e;
|
|
10615
|
+
if (Precision.almostEquals(upperD, 0)) {
|
|
10616
|
+
q1 = q2 = y * 0.5;
|
|
10617
|
+
upperD = b * b - 4 * (c - y);
|
|
10618
|
+
if (Precision.almostEquals(upperD, 0)) {
|
|
10619
|
+
p1 = p2 = b * 0.5;
|
|
10620
|
+
}
|
|
10621
|
+
else {
|
|
10622
|
+
sqD = Math.sqrt(upperD);
|
|
10623
|
+
p1 = (b + sqD) * 0.5;
|
|
10624
|
+
p2 = (b - sqD) * 0.5;
|
|
10625
|
+
}
|
|
10626
|
+
}
|
|
10627
|
+
else {
|
|
10628
|
+
sqD = Math.sqrt(upperD);
|
|
10629
|
+
q1 = (y + sqD) * 0.5;
|
|
10630
|
+
q2 = (y - sqD) * 0.5;
|
|
10631
|
+
p1 = (b * q1 - d) / (q1 - q2);
|
|
10632
|
+
p2 = (d - b * q2) / (q1 - q2);
|
|
10633
|
+
}
|
|
10634
|
+
// Solving quadratic eq. - x^2 + p1*x + q1 = 0.
|
|
10635
|
+
upperD = p1 * p1 - 4 * q1;
|
|
10636
|
+
if (upperD >= 0) {
|
|
10637
|
+
result.count += 2;
|
|
10638
|
+
sqD = Math.sqrt(upperD);
|
|
10639
|
+
result.roots[0] = (-p1 + sqD) * 0.5;
|
|
10640
|
+
result.roots[1] = (-p1 - sqD) * 0.5;
|
|
10641
|
+
}
|
|
10642
|
+
// Solving quadratic eq. - x^2 + p2*x + q2 = 0.
|
|
10643
|
+
upperD = p2 * p2 - 4 * q2;
|
|
10644
|
+
if (upperD >= 0) {
|
|
10645
|
+
result.count += 2;
|
|
10646
|
+
sqD = Math.sqrt(upperD);
|
|
10647
|
+
result.roots[2] = (-p2 + sqD) * 0.5;
|
|
10648
|
+
result.roots[3] = (-p2 - sqD) * 0.5;
|
|
10649
|
+
}
|
|
10650
|
+
// Put the null roots at the end of the array.
|
|
10651
|
+
result.roots.sort((a, b) => {
|
|
10652
|
+
if (a === null && b === null) {
|
|
10653
|
+
return 0;
|
|
10654
|
+
}
|
|
10655
|
+
if (a === null) {
|
|
10656
|
+
return 1;
|
|
10657
|
+
}
|
|
10658
|
+
if (b === null) {
|
|
10659
|
+
return -1;
|
|
10660
|
+
}
|
|
10661
|
+
return 0;
|
|
10662
|
+
});
|
|
10663
|
+
return result;
|
|
10463
10664
|
}
|
|
10464
|
-
|
|
10465
|
-
|
|
10466
|
-
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10470
|
-
|
|
10665
|
+
static solveP3(a, b, c, d) {
|
|
10666
|
+
const result = {
|
|
10667
|
+
count: 0,
|
|
10668
|
+
roots: new Array(3),
|
|
10669
|
+
};
|
|
10670
|
+
if (a === 0) {
|
|
10671
|
+
const xValsQuadratic = this.solveP2(b, c, d);
|
|
10672
|
+
result.count = xValsQuadratic.count;
|
|
10673
|
+
result.roots[0] = xValsQuadratic.roots[0];
|
|
10674
|
+
result.roots[1] = xValsQuadratic.roots[1];
|
|
10675
|
+
result.roots[2] = null;
|
|
10676
|
+
return result;
|
|
10677
|
+
}
|
|
10678
|
+
b /= a;
|
|
10679
|
+
c /= a;
|
|
10680
|
+
d /= a;
|
|
10681
|
+
const a2 = b * b;
|
|
10682
|
+
let q = (a2 - 3 * c) / 9;
|
|
10683
|
+
const q3 = q * q * q;
|
|
10684
|
+
const r = (b * (2 * a2 - 9 * c) + 27 * d) / 54;
|
|
10685
|
+
const r2 = r * r;
|
|
10686
|
+
if (r2 < q3) {
|
|
10687
|
+
let t = r / Math.sqrt(q3);
|
|
10688
|
+
t = MathUtils.clamp(t, -1, 1);
|
|
10689
|
+
t = Math.acos(t);
|
|
10690
|
+
b /= 3;
|
|
10691
|
+
q = -2 * Math.sqrt(q);
|
|
10692
|
+
result.count = 3;
|
|
10693
|
+
result.roots[0] = q * Math.cos(t / 3) - b;
|
|
10694
|
+
result.roots[1] = q * Math.cos((t + Math.PI * 2) / 3) - b;
|
|
10695
|
+
result.roots[2] = q * Math.cos((t - Math.PI * 2) / 3) - b;
|
|
10696
|
+
return result;
|
|
10697
|
+
}
|
|
10698
|
+
let upperA = -Math.cbrt(Math.abs(r) + Math.sqrt(r2 - q3));
|
|
10699
|
+
if (r < 0) {
|
|
10700
|
+
upperA = -upperA;
|
|
10701
|
+
}
|
|
10702
|
+
const upperB = upperA == 0 ? 0 : q / upperA;
|
|
10703
|
+
b /= 3;
|
|
10704
|
+
result.count = 1;
|
|
10705
|
+
result.roots[0] = upperA + upperB - b;
|
|
10706
|
+
if (Precision.almostEquals(0.5 * Math.sqrt(3) * (upperA - upperB), 0)) {
|
|
10707
|
+
result.count = 2;
|
|
10708
|
+
result.roots[1] = -0.5 * (upperA + upperB) - b;
|
|
10709
|
+
return result;
|
|
10710
|
+
}
|
|
10711
|
+
return result;
|
|
10471
10712
|
}
|
|
10472
|
-
|
|
10473
|
-
|
|
10474
|
-
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
|
|
10478
|
-
|
|
10479
|
-
|
|
10480
|
-
return url;
|
|
10713
|
+
static solveP2(a, b, c) {
|
|
10714
|
+
const result = {
|
|
10715
|
+
count: 0,
|
|
10716
|
+
roots: new Array(2),
|
|
10717
|
+
};
|
|
10718
|
+
if (a === 0) {
|
|
10719
|
+
if (b === 0) {
|
|
10720
|
+
return result;
|
|
10481
10721
|
}
|
|
10722
|
+
result.count = 1;
|
|
10723
|
+
result.roots[0] = -c / b;
|
|
10724
|
+
}
|
|
10725
|
+
const discriminant = b * b - 4 * a * c;
|
|
10726
|
+
if (discriminant < 0) {
|
|
10727
|
+
return result;
|
|
10728
|
+
}
|
|
10729
|
+
switch (discriminant) {
|
|
10730
|
+
case 0:
|
|
10731
|
+
result.count = 1;
|
|
10732
|
+
result.roots[0] = -b / (2 * a);
|
|
10733
|
+
break;
|
|
10482
10734
|
default:
|
|
10483
|
-
|
|
10735
|
+
result.count = 2;
|
|
10736
|
+
result.roots[0] = (-b + Math.sqrt(discriminant)) / (2 * a);
|
|
10737
|
+
result.roots[1] = (-b - Math.sqrt(discriminant)) / (2 * a);
|
|
10738
|
+
break;
|
|
10484
10739
|
}
|
|
10740
|
+
return result;
|
|
10485
10741
|
}
|
|
10486
10742
|
}
|
|
10487
|
-
DroidAPIRequestBuilder.apiKey = "";
|
|
10488
10743
|
|
|
10489
10744
|
/**
|
|
10490
|
-
* A
|
|
10745
|
+
* A Math utility class containing all methods related to the error function.
|
|
10746
|
+
*
|
|
10747
|
+
* This class shares the same implementation as {@link https://numerics.mathdotnet.com/ Math.NET Numerics}.
|
|
10491
10748
|
*/
|
|
10492
|
-
class
|
|
10749
|
+
class ErrorFunction {
|
|
10750
|
+
//#endregion
|
|
10751
|
+
//#region Evaluations
|
|
10493
10752
|
/**
|
|
10494
|
-
*
|
|
10753
|
+
* Calculates the error function evaluated at `x`.
|
|
10495
10754
|
*
|
|
10496
|
-
* @param
|
|
10497
|
-
* @
|
|
10498
|
-
*
|
|
10755
|
+
* @param x The value to evaluate.
|
|
10756
|
+
* @returns The error function evaluated at `x`, or:
|
|
10757
|
+
* - 1 if `x == Number.POSITIVE_INFINITY`;
|
|
10758
|
+
* - -1 if `x == Number.NEGATIVE_INFINITY`.
|
|
10499
10759
|
*/
|
|
10500
|
-
static
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
return map;
|
|
10760
|
+
static erf(x) {
|
|
10761
|
+
if (x === 0) {
|
|
10762
|
+
return 0;
|
|
10504
10763
|
}
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
const modType = this.legacyStorableMods.get(c);
|
|
10508
|
-
if (!modType) {
|
|
10509
|
-
continue;
|
|
10510
|
-
}
|
|
10511
|
-
const mod = new modType();
|
|
10512
|
-
if (mod.isMigratableDroidMod() && difficulty) {
|
|
10513
|
-
map.set(mod.migrateDroidMod(difficulty));
|
|
10514
|
-
}
|
|
10515
|
-
else {
|
|
10516
|
-
map.set(mod);
|
|
10517
|
-
}
|
|
10764
|
+
if (x === Number.POSITIVE_INFINITY) {
|
|
10765
|
+
return 1;
|
|
10518
10766
|
}
|
|
10519
|
-
if (
|
|
10520
|
-
|
|
10521
|
-
}
|
|
10522
|
-
return map;
|
|
10523
|
-
}
|
|
10524
|
-
/**
|
|
10525
|
-
* Parses the extra strings of a mod string.
|
|
10526
|
-
*
|
|
10527
|
-
* @param map The current `Mod`s.
|
|
10528
|
-
* @param extraStrings The extra strings to parse.
|
|
10529
|
-
*/
|
|
10530
|
-
static parseExtraModString(map, extraStrings) {
|
|
10531
|
-
let customCS;
|
|
10532
|
-
let customAR;
|
|
10533
|
-
let customOD;
|
|
10534
|
-
let customHP;
|
|
10535
|
-
for (const s of extraStrings) {
|
|
10536
|
-
switch (true) {
|
|
10537
|
-
// Forced stats
|
|
10538
|
-
case s.startsWith("CS"):
|
|
10539
|
-
customCS = parseFloat(s.slice(2));
|
|
10540
|
-
break;
|
|
10541
|
-
case s.startsWith("AR"):
|
|
10542
|
-
customAR = parseFloat(s.slice(2));
|
|
10543
|
-
break;
|
|
10544
|
-
case s.startsWith("OD"):
|
|
10545
|
-
customOD = parseFloat(s.slice(2));
|
|
10546
|
-
break;
|
|
10547
|
-
case s.startsWith("HP"):
|
|
10548
|
-
customHP = parseFloat(s.slice(2));
|
|
10549
|
-
break;
|
|
10550
|
-
// FL follow delay
|
|
10551
|
-
case s.startsWith("FLD"): {
|
|
10552
|
-
let flashlight = map.get(ModFlashlight);
|
|
10553
|
-
if (!flashlight) {
|
|
10554
|
-
flashlight = new ModFlashlight();
|
|
10555
|
-
map.set(flashlight);
|
|
10556
|
-
}
|
|
10557
|
-
flashlight.followDelay.value = parseFloat(s.slice(3));
|
|
10558
|
-
break;
|
|
10559
|
-
}
|
|
10560
|
-
// Speed multiplier
|
|
10561
|
-
case s.startsWith("x"): {
|
|
10562
|
-
let customSpeed = map.get(ModCustomSpeed);
|
|
10563
|
-
if (!customSpeed) {
|
|
10564
|
-
customSpeed = new ModCustomSpeed();
|
|
10565
|
-
map.set(customSpeed);
|
|
10566
|
-
}
|
|
10567
|
-
customSpeed.trackRateMultiplier.value = parseFloat(s.slice(1));
|
|
10568
|
-
break;
|
|
10569
|
-
}
|
|
10570
|
-
}
|
|
10571
|
-
}
|
|
10572
|
-
if (customCS !== undefined ||
|
|
10573
|
-
customAR !== undefined ||
|
|
10574
|
-
customOD !== undefined ||
|
|
10575
|
-
customHP !== undefined) {
|
|
10576
|
-
map.set(new ModDifficultyAdjust({
|
|
10577
|
-
cs: customCS,
|
|
10578
|
-
ar: customAR,
|
|
10579
|
-
od: customOD,
|
|
10580
|
-
hp: customHP,
|
|
10581
|
-
}));
|
|
10582
|
-
}
|
|
10583
|
-
}
|
|
10584
|
-
}
|
|
10585
|
-
/**
|
|
10586
|
-
* All `Mod`s that can be stored in the legacy mods format by their respective encode character.
|
|
10587
|
-
*/
|
|
10588
|
-
DroidLegacyModConverter.legacyStorableMods = new Map([
|
|
10589
|
-
["a", ModAuto],
|
|
10590
|
-
["b", ModTraceable],
|
|
10591
|
-
["c", ModNightCore],
|
|
10592
|
-
["d", ModDoubleTime],
|
|
10593
|
-
["e", ModEasy],
|
|
10594
|
-
["f", ModPerfect],
|
|
10595
|
-
["h", ModHidden],
|
|
10596
|
-
["i", ModFlashlight],
|
|
10597
|
-
["l", ModReallyEasy],
|
|
10598
|
-
["m", ModSmallCircle],
|
|
10599
|
-
["n", ModNoFail],
|
|
10600
|
-
["p", ModAutopilot],
|
|
10601
|
-
["r", ModHardRock],
|
|
10602
|
-
["s", ModPrecise],
|
|
10603
|
-
["t", ModHalfTime],
|
|
10604
|
-
["u", ModSuddenDeath],
|
|
10605
|
-
["v", ModScoreV2],
|
|
10606
|
-
["x", ModRelax],
|
|
10607
|
-
]);
|
|
10608
|
-
|
|
10609
|
-
/**
|
|
10610
|
-
* A single-variable polynomial with real-valued coefficients and non-negative exponents.
|
|
10611
|
-
*
|
|
10612
|
-
* This class shares the same implementation as {@link https://numerics.mathdotnet.com/ Math.NET Numerics}.
|
|
10613
|
-
*/
|
|
10614
|
-
class Polynomial {
|
|
10615
|
-
/**
|
|
10616
|
-
* Evaluates a polynomial at point `z`.
|
|
10617
|
-
*
|
|
10618
|
-
* Coefficients are ordered ascending by power with power `k` at index `k`.
|
|
10619
|
-
* For example, coefficients `[3, -1, 2]` represent `y = 2x^2 - x + 3`.
|
|
10620
|
-
*
|
|
10621
|
-
* @param z The location where to evaluate the polynomial at.
|
|
10622
|
-
* @param coefficients The coefficients of the polynomial, coefficient for power `k` at index `k`.
|
|
10623
|
-
* @returns The polynomial at `z`.
|
|
10624
|
-
*/
|
|
10625
|
-
static evaluate(z, coefficients) {
|
|
10626
|
-
// Zero polynomials need explicit handling, otherwise we
|
|
10627
|
-
// will attempt to peek coefficients at negative indices.
|
|
10628
|
-
if (coefficients.length === 0) {
|
|
10629
|
-
return 0;
|
|
10630
|
-
}
|
|
10631
|
-
let sum = coefficients.at(-1);
|
|
10632
|
-
for (let i = coefficients.length - 2; i >= 0; --i) {
|
|
10633
|
-
sum *= z;
|
|
10634
|
-
sum += coefficients[i];
|
|
10635
|
-
}
|
|
10636
|
-
return sum;
|
|
10637
|
-
}
|
|
10638
|
-
}
|
|
10639
|
-
|
|
10640
|
-
/**
|
|
10641
|
-
* A Math utility class containing all methods related to the error function.
|
|
10642
|
-
*
|
|
10643
|
-
* This class shares the same implementation as {@link https://numerics.mathdotnet.com/ Math.NET Numerics}.
|
|
10644
|
-
*/
|
|
10645
|
-
class ErrorFunction {
|
|
10646
|
-
//#endregion
|
|
10647
|
-
//#region Evaluations
|
|
10648
|
-
/**
|
|
10649
|
-
* Calculates the error function evaluated at `x`.
|
|
10650
|
-
*
|
|
10651
|
-
* @param x The value to evaluate.
|
|
10652
|
-
* @returns The error function evaluated at `x`, or:
|
|
10653
|
-
* - 1 if `x == Number.POSITIVE_INFINITY`;
|
|
10654
|
-
* - -1 if `x == Number.NEGATIVE_INFINITY`.
|
|
10655
|
-
*/
|
|
10656
|
-
static erf(x) {
|
|
10657
|
-
if (x === 0) {
|
|
10658
|
-
return 0;
|
|
10659
|
-
}
|
|
10660
|
-
if (x === Number.POSITIVE_INFINITY) {
|
|
10661
|
-
return 1;
|
|
10662
|
-
}
|
|
10663
|
-
if (x === Number.NEGATIVE_INFINITY) {
|
|
10664
|
-
return -1;
|
|
10767
|
+
if (x === Number.NEGATIVE_INFINITY) {
|
|
10768
|
+
return -1;
|
|
10665
10769
|
}
|
|
10666
10770
|
if (Number.isNaN(x)) {
|
|
10667
10771
|
return Number.NaN;
|
|
@@ -11384,18 +11488,571 @@ ErrorFunction.ervInvImpGd = [
|
|
|
11384
11488
|
];
|
|
11385
11489
|
|
|
11386
11490
|
/**
|
|
11387
|
-
*
|
|
11491
|
+
* Continuous Univariate Normal distribution, also known as Gaussian distribution.
|
|
11492
|
+
*
|
|
11493
|
+
* For details about this distribution, see {@link http://en.wikipedia.org/wiki/Normal_distribution Wikipedia - Normal distribution}.
|
|
11494
|
+
*
|
|
11495
|
+
* This class shares the same implementation as {@link https://numerics.mathdotnet.com/ Math.NET Numerics}.
|
|
11496
|
+
*/
|
|
11497
|
+
class NormalDistribution {
|
|
11498
|
+
/**
|
|
11499
|
+
* Computes the cumulative distribution function (CDF) of the distribution at x, i.e. P(X ≤ x).
|
|
11500
|
+
*
|
|
11501
|
+
* @param mean The mean (μ) of the normal distribution.
|
|
11502
|
+
* @param stdDev The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
|
|
11503
|
+
* @param x The location at which to compute the cumulative distribution function.
|
|
11504
|
+
* @returns The cumulative distribution at {@link x}.
|
|
11505
|
+
*/
|
|
11506
|
+
static cdf(mean, stdDev, x) {
|
|
11507
|
+
if (stdDev < 0) {
|
|
11508
|
+
throw new RangeError("Invalid parametrization for the distribution.");
|
|
11509
|
+
}
|
|
11510
|
+
if (mean === x && stdDev === 0) {
|
|
11511
|
+
return 0;
|
|
11512
|
+
}
|
|
11513
|
+
return 0.5 * ErrorFunction.erfc((mean - x) / (stdDev * Math.SQRT2));
|
|
11514
|
+
}
|
|
11515
|
+
/**
|
|
11516
|
+
* Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
|
|
11517
|
+
*
|
|
11518
|
+
* In MATLAB, this is known as `normpdf`.
|
|
11519
|
+
*
|
|
11520
|
+
* @param mean The mean (μ) of the normal distribution.
|
|
11521
|
+
* @param stdDev The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
|
|
11522
|
+
* @param x The location at which to compute the density.
|
|
11523
|
+
* @returns The density at {@link x}.
|
|
11524
|
+
*/
|
|
11525
|
+
static pdf(mean, stdDev, x) {
|
|
11526
|
+
if (stdDev < 0) {
|
|
11527
|
+
throw new RangeError("Invalid parametrization for the distribution.");
|
|
11528
|
+
}
|
|
11529
|
+
const d = (x - mean) / stdDev;
|
|
11530
|
+
return Math.exp(-0.5 * d * d) / (stdDev * Math.sqrt(2 * Math.PI));
|
|
11531
|
+
}
|
|
11532
|
+
/**
|
|
11533
|
+
* Computes the inverse of the cumulative distribution function (InvCDF) for the distribution
|
|
11534
|
+
* at the given probability. This is also known as the quantile or percent point function.
|
|
11535
|
+
*
|
|
11536
|
+
* @param mean The mean (μ) of the normal distribution.
|
|
11537
|
+
* @param stdDev The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
|
|
11538
|
+
* @param p The location at which to compute the inverse cumulative density.
|
|
11539
|
+
* @returns The inverse cumulative density at `p`.
|
|
11540
|
+
*/
|
|
11541
|
+
static invCDF(mean, stdDev, p) {
|
|
11542
|
+
if (stdDev < 0) {
|
|
11543
|
+
throw new RangeError("Invalid parametrization for the distribution.");
|
|
11544
|
+
}
|
|
11545
|
+
return mean - stdDev * Math.SQRT2 * ErrorFunction.erfcInv(2 * p);
|
|
11546
|
+
}
|
|
11547
|
+
}
|
|
11548
|
+
|
|
11549
|
+
/**
|
|
11550
|
+
* Approximation of the {@link https://en.wikipedia.org/wiki/Poisson_binomial_distribution Poisson binomial distribution}, which can be
|
|
11551
|
+
* updated iteratively.
|
|
11552
|
+
*
|
|
11553
|
+
* For the approximation method, see "Refined Normal Approximation (RNA)" from:
|
|
11554
|
+
*
|
|
11555
|
+
* {@link https://www.researchgate.net/publication/257017356_On_computing_the_distribution_function_for_the_Poisson_binomial_distribution Hong, Y. (2013). On computing the distribution function for the Poisson binomial distribution. Computational Statistics and Data Analysis, Vol. 59, pp. 41-51}.
|
|
11556
|
+
*
|
|
11557
|
+
* This has been verified against a reference implementation provided by the authors in the R package "poibin",
|
|
11558
|
+
* which can be viewed {@link https://rdrr.io/cran/poibin/man/poibin-package.html here}.
|
|
11559
|
+
*/
|
|
11560
|
+
class IterativePoissonBinomial {
|
|
11561
|
+
constructor() {
|
|
11562
|
+
this.mu = 0;
|
|
11563
|
+
this.var = 0;
|
|
11564
|
+
this.gamma = 0;
|
|
11565
|
+
}
|
|
11566
|
+
/**
|
|
11567
|
+
* Adds a new trial with the provided probability of success to the distribution.
|
|
11568
|
+
*
|
|
11569
|
+
* @param p The probability of success for the new trial.
|
|
11570
|
+
*/
|
|
11571
|
+
addProbability(p) {
|
|
11572
|
+
this.mu += p;
|
|
11573
|
+
this.var += p * (1 - p);
|
|
11574
|
+
this.gamma += p * (1 - p) * (1 - 2 * p);
|
|
11575
|
+
}
|
|
11576
|
+
/**
|
|
11577
|
+
* Adds multiple trials with the same probability of success to the distribution.
|
|
11578
|
+
*
|
|
11579
|
+
* @param p The probability of success for the new trials.
|
|
11580
|
+
* @param count The number of trials to add.
|
|
11581
|
+
*/
|
|
11582
|
+
addBinnedProbabilities(p, count) {
|
|
11583
|
+
this.mu += p * count;
|
|
11584
|
+
this.var += p * (1 - p) * count;
|
|
11585
|
+
this.gamma += p * (1 - p) * (1 - 2 * p) * count;
|
|
11586
|
+
}
|
|
11587
|
+
/**
|
|
11588
|
+
* Computes the value of the cumulative distribution function for this distribution.
|
|
11589
|
+
*
|
|
11590
|
+
* @param count The argument of the CDF to sample the distribution for. In the discrete case (when it is a whole number),
|
|
11591
|
+
* this corresponds to the number of successful Bernoulli trials to query the CDF for.
|
|
11592
|
+
* @returns The value of CDF at {@link count}. In the discrete case, this corresponds to the probability that at most
|
|
11593
|
+
* {@link count} Bernoulli trials ended in a success.
|
|
11594
|
+
*/
|
|
11595
|
+
cdf(count) {
|
|
11596
|
+
if (this.var === 0) {
|
|
11597
|
+
return this.mu <= count ? 1 : 0;
|
|
11598
|
+
}
|
|
11599
|
+
const sigma = Math.sqrt(this.var);
|
|
11600
|
+
const v = this.gamma / (6 * Math.pow(sigma, 3));
|
|
11601
|
+
const k = (count + 0.5 - this.mu) / sigma;
|
|
11602
|
+
const result = NormalDistribution.cdf(0, 1, k) +
|
|
11603
|
+
v * (1 - k * k) * NormalDistribution.pdf(0, 1, k);
|
|
11604
|
+
return MathUtils.clamp(result, 0, 1);
|
|
11605
|
+
}
|
|
11606
|
+
/**
|
|
11607
|
+
* Resets the distribution to an empty state.
|
|
11608
|
+
*/
|
|
11609
|
+
reset() {
|
|
11610
|
+
this.mu = 0;
|
|
11611
|
+
this.var = 0;
|
|
11612
|
+
this.gamma = 0;
|
|
11613
|
+
}
|
|
11614
|
+
}
|
|
11615
|
+
|
|
11616
|
+
/**
|
|
11617
|
+
* Approximation of the {@link https://en.wikipedia.org/wiki/Poisson_binomial_distribution Poisson binomial distribution}.
|
|
11618
|
+
*
|
|
11619
|
+
* For the approximation method, see "Refined Normal Approximation (RNA)" from:
|
|
11620
|
+
*
|
|
11621
|
+
* {@link https://www.researchgate.net/publication/257017356_On_computing_the_distribution_function_for_the_Poisson_binomial_distribution Hong, Y. (2013). On computing the distribution function for the Poisson binomial distribution. Computational Statistics and Data Analysis, Vol. 59, pp. 41-51}.
|
|
11622
|
+
*
|
|
11623
|
+
* This has been verified against a reference implementation provided by the authors in the R package "poibin",
|
|
11624
|
+
* which can be viewed {@link https://rdrr.io/cran/poibin/man/poibin-package.html here}.
|
|
11625
|
+
*/
|
|
11626
|
+
class PoissonBinomial {
|
|
11627
|
+
/**
|
|
11628
|
+
* Creates a new Poisson binomial distribution based on N trials with the provided list or bins of
|
|
11629
|
+
* difficulties, skill, and method for getting the miss probabilities.
|
|
11630
|
+
*
|
|
11631
|
+
* @param difficulties The list or bins of difficulties.
|
|
11632
|
+
* @param skill The skill level to get the miss probabilities with.
|
|
11633
|
+
* @param hitProbability The method for converting difficulties and skill into miss probabilities.
|
|
11634
|
+
*/
|
|
11635
|
+
constructor(difficulties, skill, hitProbability) {
|
|
11636
|
+
this.mu = 0;
|
|
11637
|
+
let variance = 0;
|
|
11638
|
+
let gamma = 0;
|
|
11639
|
+
for (const d of difficulties) {
|
|
11640
|
+
if (d instanceof Bin) {
|
|
11641
|
+
const p = 1 - hitProbability(skill, d.difficulty);
|
|
11642
|
+
this.mu += p * d.noteCount;
|
|
11643
|
+
variance += p * (1 - p) * d.noteCount;
|
|
11644
|
+
gamma += p * (1 - p) * (1 - 2 * p) * d.noteCount;
|
|
11645
|
+
}
|
|
11646
|
+
else {
|
|
11647
|
+
const p = 1 - hitProbability(skill, d);
|
|
11648
|
+
this.mu += p;
|
|
11649
|
+
variance += p * (1 - p);
|
|
11650
|
+
gamma += p * (1 - p) * (1 - 2 * p);
|
|
11651
|
+
}
|
|
11652
|
+
}
|
|
11653
|
+
this.sigma = Math.sqrt(variance);
|
|
11654
|
+
this.v = gamma / (6 * Math.pow(this.sigma, 3));
|
|
11655
|
+
}
|
|
11656
|
+
/**
|
|
11657
|
+
* Computes the value of the cumulative distribution function for this distribution.
|
|
11658
|
+
*
|
|
11659
|
+
* @param count The argument of the CDF to sample the distribution for. In the discrete case (when it is a whole number),
|
|
11660
|
+
* this corresponds to the number of successful Bernoulli trials to query the CDF for.
|
|
11661
|
+
* @returns The value of CDF at {@link count}. In the discrete case, this corresponds to the probability that at most
|
|
11662
|
+
* {@link count} Bernoulli trials ended in a success.
|
|
11663
|
+
*/
|
|
11664
|
+
cdf(count) {
|
|
11665
|
+
if (this.sigma === 0) {
|
|
11666
|
+
return 1;
|
|
11667
|
+
}
|
|
11668
|
+
const k = (count + 0.5 - this.mu) / this.sigma;
|
|
11669
|
+
// See equation (14) of the cited paper.
|
|
11670
|
+
const result = NormalDistribution.cdf(0, 1, k) +
|
|
11671
|
+
this.v * (1 - k * k) * NormalDistribution.pdf(0, 1, k);
|
|
11672
|
+
return MathUtils.clamp(result, 0, 1);
|
|
11673
|
+
}
|
|
11674
|
+
}
|
|
11675
|
+
|
|
11676
|
+
/**
|
|
11677
|
+
* A set of utilities to handle legacy mods storage conversion to the new storage format in osu!droid.
|
|
11678
|
+
*/
|
|
11679
|
+
class DroidLegacyModConverter {
|
|
11680
|
+
/**
|
|
11681
|
+
* Converts a legacy mod string to an array of `Mod`s.
|
|
11682
|
+
*
|
|
11683
|
+
* @param str The mod string to convert.
|
|
11684
|
+
* @param difficulty The `BeatmapDifficulty` to use for `IMigratableDroidMod` migrations. When omitted, `IMigratableDroidMod`s will not be migrated.
|
|
11685
|
+
* @returns An array of `Mod`s.
|
|
11686
|
+
*/
|
|
11687
|
+
static convert(str, difficulty) {
|
|
11688
|
+
const map = new ModMap();
|
|
11689
|
+
if (!str) {
|
|
11690
|
+
return map;
|
|
11691
|
+
}
|
|
11692
|
+
const data = str.split("|");
|
|
11693
|
+
for (const c of data[0]) {
|
|
11694
|
+
const modType = this.legacyStorableMods.get(c);
|
|
11695
|
+
if (!modType) {
|
|
11696
|
+
continue;
|
|
11697
|
+
}
|
|
11698
|
+
const mod = new modType();
|
|
11699
|
+
if (mod.isMigratableDroidMod() && difficulty) {
|
|
11700
|
+
map.set(mod.migrateDroidMod(difficulty));
|
|
11701
|
+
}
|
|
11702
|
+
else {
|
|
11703
|
+
map.set(mod);
|
|
11704
|
+
}
|
|
11705
|
+
}
|
|
11706
|
+
if (data.length > 1) {
|
|
11707
|
+
this.parseExtraModString(map, data.slice(1));
|
|
11708
|
+
}
|
|
11709
|
+
return map;
|
|
11710
|
+
}
|
|
11711
|
+
/**
|
|
11712
|
+
* Parses the extra strings of a mod string.
|
|
11713
|
+
*
|
|
11714
|
+
* @param map The current `Mod`s.
|
|
11715
|
+
* @param extraStrings The extra strings to parse.
|
|
11716
|
+
*/
|
|
11717
|
+
static parseExtraModString(map, extraStrings) {
|
|
11718
|
+
let customCS;
|
|
11719
|
+
let customAR;
|
|
11720
|
+
let customOD;
|
|
11721
|
+
let customHP;
|
|
11722
|
+
for (const s of extraStrings) {
|
|
11723
|
+
switch (true) {
|
|
11724
|
+
// Forced stats
|
|
11725
|
+
case s.startsWith("CS"):
|
|
11726
|
+
customCS = parseFloat(s.slice(2));
|
|
11727
|
+
break;
|
|
11728
|
+
case s.startsWith("AR"):
|
|
11729
|
+
customAR = parseFloat(s.slice(2));
|
|
11730
|
+
break;
|
|
11731
|
+
case s.startsWith("OD"):
|
|
11732
|
+
customOD = parseFloat(s.slice(2));
|
|
11733
|
+
break;
|
|
11734
|
+
case s.startsWith("HP"):
|
|
11735
|
+
customHP = parseFloat(s.slice(2));
|
|
11736
|
+
break;
|
|
11737
|
+
// FL follow delay
|
|
11738
|
+
case s.startsWith("FLD"): {
|
|
11739
|
+
let flashlight = map.get(ModFlashlight);
|
|
11740
|
+
if (!flashlight) {
|
|
11741
|
+
flashlight = new ModFlashlight();
|
|
11742
|
+
map.set(flashlight);
|
|
11743
|
+
}
|
|
11744
|
+
flashlight.followDelay.value = parseFloat(s.slice(3));
|
|
11745
|
+
break;
|
|
11746
|
+
}
|
|
11747
|
+
// Speed multiplier
|
|
11748
|
+
case s.startsWith("x"): {
|
|
11749
|
+
let customSpeed = map.get(ModCustomSpeed);
|
|
11750
|
+
if (!customSpeed) {
|
|
11751
|
+
customSpeed = new ModCustomSpeed();
|
|
11752
|
+
map.set(customSpeed);
|
|
11753
|
+
}
|
|
11754
|
+
customSpeed.trackRateMultiplier.value = parseFloat(s.slice(1));
|
|
11755
|
+
break;
|
|
11756
|
+
}
|
|
11757
|
+
}
|
|
11758
|
+
}
|
|
11759
|
+
if (customCS !== undefined ||
|
|
11760
|
+
customAR !== undefined ||
|
|
11761
|
+
customOD !== undefined ||
|
|
11762
|
+
customHP !== undefined) {
|
|
11763
|
+
map.set(new ModDifficultyAdjust({
|
|
11764
|
+
cs: customCS,
|
|
11765
|
+
ar: customAR,
|
|
11766
|
+
od: customOD,
|
|
11767
|
+
hp: customHP,
|
|
11768
|
+
}));
|
|
11769
|
+
}
|
|
11770
|
+
}
|
|
11771
|
+
}
|
|
11772
|
+
/**
|
|
11773
|
+
* All `Mod`s that can be stored in the legacy mods format by their respective encode character.
|
|
11774
|
+
*/
|
|
11775
|
+
DroidLegacyModConverter.legacyStorableMods = new Map([
|
|
11776
|
+
["a", ModAuto],
|
|
11777
|
+
["b", ModTraceable],
|
|
11778
|
+
["c", ModNightCore],
|
|
11779
|
+
["d", ModDoubleTime],
|
|
11780
|
+
["e", ModEasy],
|
|
11781
|
+
["f", ModPerfect],
|
|
11782
|
+
["h", ModHidden],
|
|
11783
|
+
["i", ModFlashlight],
|
|
11784
|
+
["l", ModReallyEasy],
|
|
11785
|
+
["m", ModSmallCircle],
|
|
11786
|
+
["n", ModNoFail],
|
|
11787
|
+
["p", ModAutopilot],
|
|
11788
|
+
["r", ModHardRock],
|
|
11789
|
+
["s", ModPrecise],
|
|
11790
|
+
["t", ModHalfTime],
|
|
11791
|
+
["u", ModSuddenDeath],
|
|
11792
|
+
["v", ModScoreV2],
|
|
11793
|
+
["x", ModRelax],
|
|
11794
|
+
]);
|
|
11795
|
+
|
|
11796
|
+
/**
|
|
11797
|
+
* Represents the "old" `ModNightCore`.
|
|
11798
|
+
*
|
|
11799
|
+
* This `Mod` is used solely for difficulty calculation of replays with version 3 or older. The reason behind this is a
|
|
11800
|
+
* bug that was patched in replay version 4, where all audio that did not have 44100Hz frequency would slow down or
|
|
11801
|
+
* speed up depending on the frequency of the audio.
|
|
11802
|
+
*
|
|
11803
|
+
* The equation for the playback rate with respect to the audio frequency (in Hz) was:
|
|
11804
|
+
*
|
|
11805
|
+
* ```
|
|
11806
|
+
* playback_rate = 44100 * 1.5 / audio_frequency
|
|
11807
|
+
* ```
|
|
11808
|
+
*
|
|
11809
|
+
* For example, if the audio's frequency is 48000Hz, the audio would play at `44100 * 1.5 / 48000 = 1.378125` playback
|
|
11810
|
+
* rate.
|
|
11811
|
+
*
|
|
11812
|
+
* This `Mod` assumes that the audio frequency is 48000Hz and applies the same equation to calculate the playback rate.
|
|
11813
|
+
* The frequency was chosen after sampling many audio files that were affected by this bug, and it seemed that 48000Hz
|
|
11814
|
+
* was the most common frequency used in those files.
|
|
11815
|
+
*
|
|
11816
|
+
* Realistically, it is possible to obtain the audio frequency in the game during gameplay loading (and therefore would
|
|
11817
|
+
* result in the correct playback rate), but this would require additional work and the current solution is deemed
|
|
11818
|
+
* sufficient for the purpose it serves.
|
|
11819
|
+
*/
|
|
11820
|
+
class ModOldNightCore extends ModNightCore {
|
|
11821
|
+
constructor() {
|
|
11822
|
+
super();
|
|
11823
|
+
this.trackRateMultiplier.value = (44.1 * 1.5) / 48;
|
|
11824
|
+
}
|
|
11825
|
+
get droidScoreMultiplier() {
|
|
11826
|
+
return 1.12;
|
|
11827
|
+
}
|
|
11828
|
+
get migrationDroidScoreMultiplier() {
|
|
11829
|
+
return this.droidScoreMultiplier;
|
|
11830
|
+
}
|
|
11831
|
+
}
|
|
11832
|
+
|
|
11833
|
+
/**
|
|
11834
|
+
* Available genres in an online osu! beatmap.
|
|
11835
|
+
*/
|
|
11836
|
+
exports.BeatmapGenre = void 0;
|
|
11837
|
+
(function (BeatmapGenre) {
|
|
11838
|
+
BeatmapGenre[BeatmapGenre["any"] = 0] = "any";
|
|
11839
|
+
BeatmapGenre[BeatmapGenre["unspecified"] = 1] = "unspecified";
|
|
11840
|
+
BeatmapGenre[BeatmapGenre["videoGame"] = 2] = "videoGame";
|
|
11841
|
+
BeatmapGenre[BeatmapGenre["anime"] = 3] = "anime";
|
|
11842
|
+
BeatmapGenre[BeatmapGenre["rock"] = 4] = "rock";
|
|
11843
|
+
BeatmapGenre[BeatmapGenre["pop"] = 5] = "pop";
|
|
11844
|
+
BeatmapGenre[BeatmapGenre["other"] = 6] = "other";
|
|
11845
|
+
BeatmapGenre[BeatmapGenre["novelty"] = 7] = "novelty";
|
|
11846
|
+
BeatmapGenre[BeatmapGenre["hipHop"] = 9] = "hipHop";
|
|
11847
|
+
BeatmapGenre[BeatmapGenre["electronic"] = 10] = "electronic";
|
|
11848
|
+
BeatmapGenre[BeatmapGenre["metal"] = 11] = "metal";
|
|
11849
|
+
BeatmapGenre[BeatmapGenre["classical"] = 12] = "classical";
|
|
11850
|
+
BeatmapGenre[BeatmapGenre["folk"] = 13] = "folk";
|
|
11851
|
+
BeatmapGenre[BeatmapGenre["jazz"] = 14] = "jazz";
|
|
11852
|
+
})(exports.BeatmapGenre || (exports.BeatmapGenre = {}));
|
|
11853
|
+
|
|
11854
|
+
/**
|
|
11855
|
+
* Available languages in an online osu! beatmap.
|
|
11856
|
+
*/
|
|
11857
|
+
exports.BeatmapLanguage = void 0;
|
|
11858
|
+
(function (BeatmapLanguage) {
|
|
11859
|
+
BeatmapLanguage[BeatmapLanguage["any"] = 0] = "any";
|
|
11860
|
+
BeatmapLanguage[BeatmapLanguage["unspecified"] = 1] = "unspecified";
|
|
11861
|
+
BeatmapLanguage[BeatmapLanguage["english"] = 2] = "english";
|
|
11862
|
+
BeatmapLanguage[BeatmapLanguage["japanese"] = 3] = "japanese";
|
|
11863
|
+
BeatmapLanguage[BeatmapLanguage["chinese"] = 4] = "chinese";
|
|
11864
|
+
BeatmapLanguage[BeatmapLanguage["instrumental"] = 5] = "instrumental";
|
|
11865
|
+
BeatmapLanguage[BeatmapLanguage["korean"] = 6] = "korean";
|
|
11866
|
+
BeatmapLanguage[BeatmapLanguage["french"] = 7] = "french";
|
|
11867
|
+
BeatmapLanguage[BeatmapLanguage["german"] = 8] = "german";
|
|
11868
|
+
BeatmapLanguage[BeatmapLanguage["swedish"] = 9] = "swedish";
|
|
11869
|
+
BeatmapLanguage[BeatmapLanguage["spanish"] = 10] = "spanish";
|
|
11870
|
+
BeatmapLanguage[BeatmapLanguage["italian"] = 11] = "italian";
|
|
11871
|
+
BeatmapLanguage[BeatmapLanguage["russian"] = 12] = "russian";
|
|
11872
|
+
BeatmapLanguage[BeatmapLanguage["polish"] = 13] = "polish";
|
|
11873
|
+
BeatmapLanguage[BeatmapLanguage["other"] = 14] = "other";
|
|
11874
|
+
})(exports.BeatmapLanguage || (exports.BeatmapLanguage = {}));
|
|
11875
|
+
|
|
11876
|
+
/******************************************************************************
|
|
11877
|
+
Copyright (c) Microsoft Corporation.
|
|
11878
|
+
|
|
11879
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11880
|
+
purpose with or without fee is hereby granted.
|
|
11881
|
+
|
|
11882
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
11883
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11884
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11885
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11886
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
11887
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
11888
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
11889
|
+
***************************************************************************** */
|
|
11890
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
11891
|
+
|
|
11892
|
+
|
|
11893
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
11894
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11895
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11896
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11897
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
11898
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
11899
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11900
|
+
});
|
|
11901
|
+
}
|
|
11902
|
+
|
|
11903
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
11904
|
+
var e = new Error(message);
|
|
11905
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
11906
|
+
};
|
|
11907
|
+
|
|
11908
|
+
/**
|
|
11909
|
+
* The base of API request builders.
|
|
11910
|
+
*/
|
|
11911
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
|
|
11912
|
+
class APIRequestBuilder {
|
|
11913
|
+
constructor() {
|
|
11914
|
+
/**
|
|
11915
|
+
* Whether or not to include the API key in the request URL.
|
|
11916
|
+
*/
|
|
11917
|
+
this.requiresAPIkey = true;
|
|
11918
|
+
/**
|
|
11919
|
+
* The endpoint of this builder.
|
|
11920
|
+
*/
|
|
11921
|
+
this.endpoint = "";
|
|
11922
|
+
/**
|
|
11923
|
+
* The parameters of this builder.
|
|
11924
|
+
*/
|
|
11925
|
+
this.params = new Map();
|
|
11926
|
+
this.fetchAttempts = 0;
|
|
11927
|
+
}
|
|
11928
|
+
/**
|
|
11929
|
+
* The base URL of this builder.
|
|
11930
|
+
*/
|
|
11931
|
+
get baseURL() {
|
|
11932
|
+
return this.host + this.endpoint;
|
|
11933
|
+
}
|
|
11934
|
+
/**
|
|
11935
|
+
* Sets the API endpoint.
|
|
11936
|
+
*
|
|
11937
|
+
* @param endpoint The endpoint to set.
|
|
11938
|
+
*/
|
|
11939
|
+
setEndpoint(endpoint) {
|
|
11940
|
+
this.endpoint = endpoint;
|
|
11941
|
+
return this;
|
|
11942
|
+
}
|
|
11943
|
+
/**
|
|
11944
|
+
* Sets if this builder includes the API key in the request URL.
|
|
11945
|
+
*
|
|
11946
|
+
* @param requireAPIkey Whether or not to include the API key in the request URL.
|
|
11947
|
+
*/
|
|
11948
|
+
setRequireAPIkey(requireAPIkey) {
|
|
11949
|
+
this.requiresAPIkey = requireAPIkey;
|
|
11950
|
+
return this;
|
|
11951
|
+
}
|
|
11952
|
+
/**
|
|
11953
|
+
* Builds the URL to request the API.
|
|
11954
|
+
*/
|
|
11955
|
+
buildURL() {
|
|
11956
|
+
let url = this.baseURL + "?";
|
|
11957
|
+
if (this.requiresAPIkey) {
|
|
11958
|
+
if (!this.APIkey) {
|
|
11959
|
+
throw new Error("An API key has not been specified");
|
|
11960
|
+
}
|
|
11961
|
+
url += this.APIkeyParam;
|
|
11962
|
+
}
|
|
11963
|
+
for (const [param, value] of this.params.entries()) {
|
|
11964
|
+
url += `${param}=${encodeURIComponent(value)}&`;
|
|
11965
|
+
}
|
|
11966
|
+
return url;
|
|
11967
|
+
}
|
|
11968
|
+
/**
|
|
11969
|
+
* Sends a request to the API using built parameters.
|
|
11970
|
+
*
|
|
11971
|
+
* If the request fails, it will be redone 5 times.
|
|
11972
|
+
*/
|
|
11973
|
+
sendRequest() {
|
|
11974
|
+
return new Promise((resolve) => {
|
|
11975
|
+
const url = this.buildURL();
|
|
11976
|
+
fetch(url)
|
|
11977
|
+
.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
11978
|
+
++this.fetchAttempts;
|
|
11979
|
+
if (res.status >= 500 && this.fetchAttempts < 5) {
|
|
11980
|
+
console.error(`Request to ${url} failed with the following error: ${yield res.text()}; ${this.fetchAttempts.toString()} attempts so far; retrying`);
|
|
11981
|
+
resolve(this.sendRequest());
|
|
11982
|
+
return;
|
|
11983
|
+
}
|
|
11984
|
+
this.fetchAttempts = 0;
|
|
11985
|
+
resolve({
|
|
11986
|
+
data: Buffer.from(yield res.arrayBuffer()),
|
|
11987
|
+
statusCode: res.status,
|
|
11988
|
+
});
|
|
11989
|
+
}))
|
|
11990
|
+
.catch((e) => {
|
|
11991
|
+
console.error(`Request to ${url} failed with the following error: ${e.message}; ${this.fetchAttempts.toString()} attempts so far; aborting`);
|
|
11992
|
+
this.fetchAttempts = 0;
|
|
11993
|
+
resolve({
|
|
11994
|
+
data: Buffer.from([]),
|
|
11995
|
+
statusCode: 400,
|
|
11996
|
+
});
|
|
11997
|
+
return;
|
|
11998
|
+
});
|
|
11999
|
+
});
|
|
12000
|
+
}
|
|
12001
|
+
/**
|
|
12002
|
+
* Adds a parameter to the builder.
|
|
12003
|
+
*
|
|
12004
|
+
* @param param The parameter to add.
|
|
12005
|
+
* @param value The value to add for the parameter.
|
|
12006
|
+
*/
|
|
12007
|
+
addParameter(param, value) {
|
|
12008
|
+
this.params.set(param, value.toString());
|
|
12009
|
+
return this;
|
|
12010
|
+
}
|
|
12011
|
+
/**
|
|
12012
|
+
* Removes a parameter from the builder.
|
|
12013
|
+
*
|
|
12014
|
+
* @param param The parameter to remove.
|
|
12015
|
+
*/
|
|
12016
|
+
removeParameter(param) {
|
|
12017
|
+
this.params.delete(param);
|
|
12018
|
+
return this;
|
|
12019
|
+
}
|
|
12020
|
+
}
|
|
12021
|
+
|
|
12022
|
+
/**
|
|
12023
|
+
* An API request builder for osu!droid.
|
|
11388
12024
|
*/
|
|
11389
|
-
|
|
11390
|
-
(
|
|
11391
|
-
|
|
11392
|
-
|
|
11393
|
-
|
|
11394
|
-
|
|
11395
|
-
|
|
11396
|
-
|
|
11397
|
-
|
|
11398
|
-
|
|
12025
|
+
class DroidAPIRequestBuilder extends APIRequestBuilder {
|
|
12026
|
+
constructor() {
|
|
12027
|
+
super(...arguments);
|
|
12028
|
+
this.host = "https://osudroid.moe/api/";
|
|
12029
|
+
this.APIkey = DroidAPIRequestBuilder.apiKey;
|
|
12030
|
+
this.APIkeyParam = `apiKey=${this.APIkey}&`;
|
|
12031
|
+
}
|
|
12032
|
+
/**
|
|
12033
|
+
* Sets the API key for all subsequent initializations of a `DroidAPIRequestBuilder`.
|
|
12034
|
+
*
|
|
12035
|
+
* @param key The API key.
|
|
12036
|
+
*/
|
|
12037
|
+
static setAPIKey(key) {
|
|
12038
|
+
this.apiKey = key;
|
|
12039
|
+
}
|
|
12040
|
+
buildURL() {
|
|
12041
|
+
switch (this.endpoint) {
|
|
12042
|
+
case "upload":
|
|
12043
|
+
case "bestpp": {
|
|
12044
|
+
let url = this.baseURL + "/";
|
|
12045
|
+
for (const [, value] of this.params.entries()) {
|
|
12046
|
+
url += encodeURIComponent(value);
|
|
12047
|
+
}
|
|
12048
|
+
return url;
|
|
12049
|
+
}
|
|
12050
|
+
default:
|
|
12051
|
+
return super.buildURL();
|
|
12052
|
+
}
|
|
12053
|
+
}
|
|
12054
|
+
}
|
|
12055
|
+
DroidAPIRequestBuilder.apiKey = "";
|
|
11399
12056
|
|
|
11400
12057
|
/**
|
|
11401
12058
|
* An API request builder for osu!standard.
|
|
@@ -11808,61 +12465,107 @@ class MapInfo {
|
|
|
11808
12465
|
}
|
|
11809
12466
|
|
|
11810
12467
|
/**
|
|
11811
|
-
*
|
|
11812
|
-
*
|
|
11813
|
-
* This `Mod` is used solely for difficulty calculation of replays with version 3 or older. The reason behind this is a
|
|
11814
|
-
* bug that was patched in replay version 4, where all audio that did not have 44100Hz frequency would slow down or
|
|
11815
|
-
* speed up depending on the frequency of the audio.
|
|
11816
|
-
*
|
|
11817
|
-
* The equation for the playback rate with respect to the audio frequency (in Hz) was:
|
|
11818
|
-
*
|
|
11819
|
-
* ```
|
|
11820
|
-
* playback_rate = 44100 * 1.5 / audio_frequency
|
|
11821
|
-
* ```
|
|
11822
|
-
*
|
|
11823
|
-
* For example, if the audio's frequency is 48000Hz, the audio would play at `44100 * 1.5 / 48000 = 1.378125` playback
|
|
11824
|
-
* rate.
|
|
11825
|
-
*
|
|
11826
|
-
* This `Mod` assumes that the audio frequency is 48000Hz and applies the same equation to calculate the playback rate.
|
|
11827
|
-
* The frequency was chosen after sampling many audio files that were affected by this bug, and it seemed that 48000Hz
|
|
11828
|
-
* was the most common frequency used in those files.
|
|
11829
|
-
*
|
|
11830
|
-
* Realistically, it is possible to obtain the audio frequency in the game during gameplay loading (and therefore would
|
|
11831
|
-
* result in the correct playback rate), but this would require additional work and the current solution is deemed
|
|
11832
|
-
* sufficient for the purpose it serves.
|
|
12468
|
+
* An accuracy calculator that calculates accuracy based on given parameters.
|
|
11833
12469
|
*/
|
|
11834
|
-
class
|
|
11835
|
-
|
|
11836
|
-
|
|
11837
|
-
|
|
11838
|
-
|
|
11839
|
-
|
|
11840
|
-
|
|
12470
|
+
class Accuracy {
|
|
12471
|
+
/**
|
|
12472
|
+
* Calculates accuracy based on given parameters.
|
|
12473
|
+
*
|
|
12474
|
+
* If `percent` and `nobjects` are specified, `n300`, `n100`, and `n50` will
|
|
12475
|
+
* be automatically calculated to be the closest to the given
|
|
12476
|
+
* acc percent.
|
|
12477
|
+
*
|
|
12478
|
+
* @param values Function parameters.
|
|
12479
|
+
*/
|
|
12480
|
+
constructor(values) {
|
|
12481
|
+
var _a, _b, _c, _d;
|
|
12482
|
+
this.nmiss = (_a = values.nmiss) !== null && _a !== void 0 ? _a : 0;
|
|
12483
|
+
this.n300 = (_b = values.n300) !== null && _b !== void 0 ? _b : -1;
|
|
12484
|
+
this.n100 = (_c = values.n100) !== null && _c !== void 0 ? _c : 0;
|
|
12485
|
+
this.n50 = (_d = values.n50) !== null && _d !== void 0 ? _d : 0;
|
|
12486
|
+
let nobjects;
|
|
12487
|
+
if (values.nobjects) {
|
|
12488
|
+
let n300 = this.n300;
|
|
12489
|
+
nobjects = values.nobjects;
|
|
12490
|
+
let hitcount;
|
|
12491
|
+
if (n300 < 0) {
|
|
12492
|
+
n300 = Math.max(0, nobjects - this.n100 - this.n50 - this.nmiss);
|
|
12493
|
+
}
|
|
12494
|
+
hitcount = n300 + this.n100 + this.n50 + this.nmiss;
|
|
12495
|
+
if (hitcount > nobjects) {
|
|
12496
|
+
n300 -= Math.min(n300, hitcount - nobjects);
|
|
12497
|
+
}
|
|
12498
|
+
hitcount = n300 + this.n100 + this.n50 + this.nmiss;
|
|
12499
|
+
if (hitcount > nobjects) {
|
|
12500
|
+
this.n100 -= Math.min(this.n100, hitcount - nobjects);
|
|
12501
|
+
}
|
|
12502
|
+
hitcount = n300 + this.n100 + this.n50 + this.nmiss;
|
|
12503
|
+
if (hitcount > nobjects) {
|
|
12504
|
+
this.n50 -= Math.min(this.n50, hitcount - nobjects);
|
|
12505
|
+
}
|
|
12506
|
+
hitcount = n300 + this.n100 + this.n50 + this.nmiss;
|
|
12507
|
+
if (hitcount > nobjects) {
|
|
12508
|
+
this.nmiss -= Math.min(this.nmiss, hitcount - nobjects);
|
|
12509
|
+
}
|
|
12510
|
+
this.n300 = nobjects - this.n100 - this.n50 - this.nmiss;
|
|
12511
|
+
}
|
|
12512
|
+
if (values.percent) {
|
|
12513
|
+
if (!values.nobjects) {
|
|
12514
|
+
throw new TypeError("nobjects is required when specifying percent");
|
|
12515
|
+
}
|
|
12516
|
+
nobjects = values.nobjects;
|
|
12517
|
+
const max300 = nobjects - this.nmiss;
|
|
12518
|
+
const maxacc = new Accuracy({
|
|
12519
|
+
n300: max300,
|
|
12520
|
+
n100: 0,
|
|
12521
|
+
n50: 0,
|
|
12522
|
+
nmiss: this.nmiss,
|
|
12523
|
+
}).value() * 100;
|
|
12524
|
+
let acc_percent = values.percent;
|
|
12525
|
+
acc_percent = Math.max(0, Math.min(maxacc, acc_percent));
|
|
12526
|
+
// just some black magic maths from wolfram alpha
|
|
12527
|
+
this.n100 = Math.round(-3 * ((acc_percent * 0.01 - 1) * nobjects + this.nmiss) * 0.5);
|
|
12528
|
+
if (this.n100 > max300) {
|
|
12529
|
+
// acc lower than all 100s, use 50s
|
|
12530
|
+
this.n100 = 0;
|
|
12531
|
+
this.n50 = Math.round(-6 *
|
|
12532
|
+
((acc_percent * 0.01 - 1) * nobjects + this.nmiss) *
|
|
12533
|
+
0.5);
|
|
12534
|
+
this.n50 = Math.min(max300, this.n50);
|
|
12535
|
+
}
|
|
12536
|
+
this.n300 = nobjects - this.n100 - this.n50 - this.nmiss;
|
|
12537
|
+
}
|
|
11841
12538
|
}
|
|
11842
|
-
}
|
|
11843
|
-
|
|
11844
|
-
/**
|
|
11845
|
-
* Continuous Univariate Normal distribution, also known as Gaussian distribution.
|
|
11846
|
-
*
|
|
11847
|
-
* For details about this distribution, see {@link http://en.wikipedia.org/wiki/Normal_distribution Wikipedia - Normal distribution}.
|
|
11848
|
-
*
|
|
11849
|
-
* This class shares the same implementation as {@link https://numerics.mathdotnet.com/ Math.NET Numerics}.
|
|
11850
|
-
*/
|
|
11851
|
-
class NormalDistribution {
|
|
11852
12539
|
/**
|
|
11853
|
-
*
|
|
11854
|
-
* at the given probability. This is also known as the quantile or percent point function.
|
|
12540
|
+
* Calculates the accuracy value (0.0 - 1.0).
|
|
11855
12541
|
*
|
|
11856
|
-
* @param
|
|
11857
|
-
* @param stdDev The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
|
|
11858
|
-
* @param p The location at which to compute the inverse cumulative density.
|
|
11859
|
-
* @returns The inverse cumulative density at `p`.
|
|
12542
|
+
* @param nobjects The amount of objects in the beatmap. If `n300` was not specified in the constructor, this is required.
|
|
11860
12543
|
*/
|
|
11861
|
-
|
|
11862
|
-
|
|
11863
|
-
|
|
12544
|
+
value(nobjects) {
|
|
12545
|
+
let n300 = this.n300;
|
|
12546
|
+
if (n300 < 0) {
|
|
12547
|
+
if (!nobjects) {
|
|
12548
|
+
throw new TypeError("Either n300 or nobjects must be specified");
|
|
12549
|
+
}
|
|
12550
|
+
n300 = nobjects - this.n100 - this.n50 - this.nmiss;
|
|
11864
12551
|
}
|
|
11865
|
-
|
|
12552
|
+
else {
|
|
12553
|
+
nobjects !== null && nobjects !== void 0 ? nobjects : (nobjects = n300 + this.n100 + this.n50 + this.nmiss);
|
|
12554
|
+
}
|
|
12555
|
+
const res = (n300 * 6 + this.n100 * 2 + this.n50) / (nobjects * 6);
|
|
12556
|
+
return MathUtils.clamp(res, 0, 1);
|
|
12557
|
+
}
|
|
12558
|
+
/**
|
|
12559
|
+
* Determines whether this accuracy instance is equal to another instance.
|
|
12560
|
+
*
|
|
12561
|
+
* @param other The other accuracy instance.
|
|
12562
|
+
* @returns Whether both instances are equal.
|
|
12563
|
+
*/
|
|
12564
|
+
equals(other) {
|
|
12565
|
+
return (this.n300 === other.n300 &&
|
|
12566
|
+
this.n100 === other.n100 &&
|
|
12567
|
+
this.n50 === other.n50 &&
|
|
12568
|
+
this.nmiss === other.nmiss);
|
|
11866
12569
|
}
|
|
11867
12570
|
}
|
|
11868
12571
|
|
|
@@ -11883,10 +12586,12 @@ exports.BeatmapHitObjects = BeatmapHitObjects;
|
|
|
11883
12586
|
exports.BeatmapMetadata = BeatmapMetadata;
|
|
11884
12587
|
exports.BeatmapProcessor = BeatmapProcessor;
|
|
11885
12588
|
exports.BeatmapVideo = BeatmapVideo;
|
|
12589
|
+
exports.Bin = Bin;
|
|
11886
12590
|
exports.BlendingParameters = BlendingParameters;
|
|
11887
12591
|
exports.BooleanModSetting = BooleanModSetting;
|
|
11888
12592
|
exports.BreakPoint = BreakPoint;
|
|
11889
12593
|
exports.Brent = Brent;
|
|
12594
|
+
exports.Chandrupatla = Chandrupatla;
|
|
11890
12595
|
exports.Circle = Circle;
|
|
11891
12596
|
exports.CircleSizeCalculator = CircleSizeCalculator;
|
|
11892
12597
|
exports.Command = Command;
|
|
@@ -11896,6 +12601,7 @@ exports.CommandTimelineGroup = CommandTimelineGroup;
|
|
|
11896
12601
|
exports.CommandTrigger = CommandTrigger;
|
|
11897
12602
|
exports.ControlPointManager = ControlPointManager;
|
|
11898
12603
|
exports.DecimalModSetting = DecimalModSetting;
|
|
12604
|
+
exports.DifficultyAdjustModSetting = DifficultyAdjustModSetting;
|
|
11899
12605
|
exports.DifficultyControlPoint = DifficultyControlPoint;
|
|
11900
12606
|
exports.DifficultyControlPointManager = DifficultyControlPointManager;
|
|
11901
12607
|
exports.DroidAPIRequestBuilder = DroidAPIRequestBuilder;
|
|
@@ -11913,6 +12619,7 @@ exports.HitSampleInfo = HitSampleInfo;
|
|
|
11913
12619
|
exports.HitWindow = HitWindow;
|
|
11914
12620
|
exports.IntegerModSetting = IntegerModSetting;
|
|
11915
12621
|
exports.Interpolation = Interpolation;
|
|
12622
|
+
exports.IterativePoissonBinomial = IterativePoissonBinomial;
|
|
11916
12623
|
exports.MapInfo = MapInfo;
|
|
11917
12624
|
exports.MathUtils = MathUtils;
|
|
11918
12625
|
exports.Mod = Mod;
|
|
@@ -11968,6 +12675,7 @@ exports.OsuPlayableBeatmap = OsuPlayableBeatmap;
|
|
|
11968
12675
|
exports.PathApproximator = PathApproximator;
|
|
11969
12676
|
exports.PlayableBeatmap = PlayableBeatmap;
|
|
11970
12677
|
exports.Playfield = Playfield;
|
|
12678
|
+
exports.PoissonBinomial = PoissonBinomial;
|
|
11971
12679
|
exports.Polynomial = Polynomial;
|
|
11972
12680
|
exports.PreciseDroidHitWindow = PreciseDroidHitWindow;
|
|
11973
12681
|
exports.Precision = Precision;
|
|
@@ -11997,6 +12705,7 @@ exports.StoryboardSprite = StoryboardSprite;
|
|
|
11997
12705
|
exports.TimedHitSampleInfo = TimedHitSampleInfo;
|
|
11998
12706
|
exports.TimingControlPoint = TimingControlPoint;
|
|
11999
12707
|
exports.TimingControlPointManager = TimingControlPointManager;
|
|
12708
|
+
exports.UnadjustedOsuHitWindow = UnadjustedOsuHitWindow;
|
|
12000
12709
|
exports.Utils = Utils;
|
|
12001
12710
|
exports.Vector2 = Vector2;
|
|
12002
12711
|
exports.Vector4 = Vector4;
|