@rian8337/osu-base 4.0.0-beta.87 → 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.
Files changed (3) hide show
  1. package/dist/index.js +1409 -1181
  2. package/package.json +2 -2
  3. package/typings/index.d.ts +2535 -2368
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
- * An accuracy calculator that calculates accuracy based on given parameters.
220
- */
221
- class Accuracy {
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.Axes = void 0;
347
- (function (Axes) {
232
+ exports.HitResult = void 0;
233
+ (function (HitResult) {
348
234
  /**
349
- * No axis.
235
+ * Miss (0).
350
236
  */
351
- Axes[Axes["none"] = 0] = "none";
237
+ HitResult[HitResult["miss"] = 1] = "miss";
352
238
  /**
353
- * The X axis.
239
+ * Meh (50).
354
240
  */
355
- Axes[Axes["x"] = 1] = "x";
241
+ HitResult[HitResult["meh"] = 2] = "meh";
356
242
  /**
357
- * The Y axis.
243
+ * Good (100).
358
244
  */
359
- Axes[Axes["y"] = 2] = "y";
245
+ HitResult[HitResult["good"] = 3] = "good";
360
246
  /**
361
- * The X and Y axes.
247
+ * Great (300).
362
248
  */
363
- Axes[Axes["both"] = 3] = "both";
364
- })(exports.Axes || (exports.Axes = {}));
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 (80 - value) / 6;
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 (140 - value) / 8;
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 (200 - value) / 10;
373
+ return 5 - (value - 180) / 10;
532
374
  }
533
375
  get greatWindow() {
534
- return 80 - 6 * this.overallDifficulty;
376
+ return 55 + 6 * (5 - this.overallDifficulty);
535
377
  }
536
378
  get okWindow() {
537
- return 140 - 8 * this.overallDifficulty;
379
+ return 120 + 8 * (5 - this.overallDifficulty);
538
380
  }
539
381
  get mehWindow() {
540
- return 200 - 10 * this.overallDifficulty;
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
- var _a;
1500
- const serialized = {
1501
- acronym: this.acronym,
1502
- settings: (_a = this.serializeSettings()) !== null && _a !== void 0 ? _a : undefined,
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 serialized;
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 `Beatmap` for conversion and processing.
1475
+ * Whether this `Mod` requires the original `BeatmapDifficulty` for conversion and processing.
1588
1476
  */
1589
- requiresOriginalBeatmap() {
1590
- return "applyFromBeatmap" in this;
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
- return MathUtils.clamp(Math.round(value / this.step) * this.step, this.min, this.max);
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.followDelay.value === ModFlashlight.defaultFollowDelay) {
2567
+ if (this.usesDefaultSettings) {
2678
2568
  return super.toString();
2679
2569
  }
2680
- return `${super.toString()} (${this.followDelay.toDisplayString()}s follow delay)`;
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
 
@@ -4028,6 +3930,47 @@ class WorkingObject {
4028
3930
  }
4029
3931
  }
4030
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
+ }
4031
3974
  /**
4032
3975
  * Represents the Mirror mod.
4033
3976
  */
@@ -4039,30 +3982,16 @@ class ModMirror extends Mod {
4039
3982
  this.droidRanked = false;
4040
3983
  this.isDroidRelevant = true;
4041
3984
  this.droidScoreMultiplier = 1;
3985
+ this.migrationDroidScoreMultiplier = 1;
4042
3986
  this.osuRanked = false;
4043
3987
  this.isOsuRelevant = true;
4044
3988
  this.osuScoreMultiplier = 1;
4045
3989
  /**
4046
3990
  * The axes to reflect the `HitObject`s along.
4047
3991
  */
4048
- this.flippedAxes = new ModSetting("Flipped axes", "The axes to reflect the hit objects along.", exports.Axes.x);
3992
+ this.flippedAxes = new AxesModSetting("Flipped axes", "flippedAxes", "The axes to reflect the hit objects along.", exports.Axes.x);
4049
3993
  this.incompatibleMods.add(ModHardRock);
4050
3994
  }
4051
- copySettings(mod) {
4052
- var _a;
4053
- super.copySettings(mod);
4054
- switch ((_a = mod.settings) === null || _a === void 0 ? void 0 : _a.flippedAxes) {
4055
- case 0:
4056
- this.flippedAxes.value = exports.Axes.x;
4057
- break;
4058
- case 1:
4059
- this.flippedAxes.value = exports.Axes.y;
4060
- break;
4061
- case 2:
4062
- this.flippedAxes.value = exports.Axes.both;
4063
- break;
4064
- }
4065
- }
4066
3995
  applyToHitObject(_, hitObject) {
4067
3996
  switch (this.flippedAxes.value) {
4068
3997
  case exports.Axes.x:
@@ -4077,9 +4006,6 @@ class ModMirror extends Mod {
4077
4006
  break;
4078
4007
  }
4079
4008
  }
4080
- serializeSettings() {
4081
- return { flippedAxes: this.flippedAxes.value - 1 };
4082
- }
4083
4009
  toString() {
4084
4010
  const settings = [];
4085
4011
  if (this.flippedAxes.value === exports.Axes.x ||
@@ -4112,6 +4038,7 @@ class ModReplayV6 extends Mod {
4112
4038
  this.droidRanked = false;
4113
4039
  this.isDroidRelevant = true;
4114
4040
  this.droidScoreMultiplier = 1;
4041
+ this.migrationDroidScoreMultiplier = 1;
4115
4042
  this.facilitateAdjustment = true;
4116
4043
  }
4117
4044
  applyToBeatmap(beatmap) {
@@ -4158,6 +4085,7 @@ class ModHardRock extends Mod {
4158
4085
  this.droidRanked = true;
4159
4086
  this.isDroidRelevant = true;
4160
4087
  this.droidScoreMultiplier = 1.06;
4088
+ this.migrationDroidScoreMultiplier = 1.06;
4161
4089
  this.osuRanked = true;
4162
4090
  this.isOsuRelevant = true;
4163
4091
  this.osuScoreMultiplier = 1.06;
@@ -4207,6 +4135,7 @@ class ModEasy extends Mod {
4207
4135
  this.droidRanked = true;
4208
4136
  this.isDroidRelevant = true;
4209
4137
  this.droidScoreMultiplier = 0.5;
4138
+ this.migrationDroidScoreMultiplier = 0.5;
4210
4139
  this.osuRanked = true;
4211
4140
  this.isOsuRelevant = true;
4212
4141
  this.osuScoreMultiplier = 0.5;
@@ -4249,6 +4178,7 @@ class ModReallyEasy extends Mod {
4249
4178
  this.droidRanked = false;
4250
4179
  this.isDroidRelevant = true;
4251
4180
  this.droidScoreMultiplier = 0.4;
4181
+ this.migrationDroidScoreMultiplier = 0.4;
4252
4182
  }
4253
4183
  applyToDifficultyWithMods(mode, difficulty, mods) {
4254
4184
  var _a;
@@ -4307,6 +4237,7 @@ class ModSmallCircle extends Mod {
4307
4237
  this.droidRanked = false;
4308
4238
  this.isDroidRelevant = true;
4309
4239
  this.droidScoreMultiplier = 1;
4240
+ this.migrationDroidScoreMultiplier = 1;
4310
4241
  }
4311
4242
  migrateDroidMod(difficulty) {
4312
4243
  return new ModDifficultyAdjust({ cs: difficulty.cs + 4 });
@@ -4351,8 +4282,8 @@ class NullableDecimalModSetting extends RangeConstrainedModSetting {
4351
4282
  this.value = this.processValue(this.value);
4352
4283
  }
4353
4284
  }
4354
- constructor(name, description, defaultValue, min = -Number.MAX_VALUE, max = Number.MAX_VALUE, step = 0, precision = null) {
4355
- 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);
4356
4287
  this.displayFormatter = (v) => {
4357
4288
  if (v === null) {
4358
4289
  return "None";
@@ -4378,12 +4309,84 @@ class NullableDecimalModSetting extends RangeConstrainedModSetting {
4378
4309
  if (value === null) {
4379
4310
  return null;
4380
4311
  }
4381
- const processedValue = MathUtils.clamp(Math.round(value / this.step) * this.step, this.min, this.max);
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);
4382
4316
  if (this.precision !== null) {
4383
4317
  return parseFloat(processedValue.toFixed(this.precision));
4384
4318
  }
4385
4319
  return processedValue;
4386
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
+ }
4338
+ }
4339
+
4340
+ /**
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.
4350
+ */
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;
4360
+ }
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
+ }
4387
4390
  }
4388
4391
 
4389
4392
  /**
@@ -4408,32 +4411,24 @@ class ModDifficultyAdjust extends Mod {
4408
4411
  /**
4409
4412
  * The circle size to enforce.
4410
4413
  */
4411
- this.cs = new NullableDecimalModSetting("Circle size", "The circle size to enforce.", null, 0, 15, 0.1, 1);
4414
+ this.cs = new DifficultyAdjustModSetting("Circle size", "cs", "The circle size to enforce.", 0, 15, 0.1, 1);
4412
4415
  /**
4413
4416
  * The approach rate to enforce.
4414
4417
  */
4415
- this.ar = new NullableDecimalModSetting("Approach rate", "The approach rate to enforce.", null, 0, 11, 0.1, 1);
4418
+ this.ar = new DifficultyAdjustModSetting("Approach rate", "ar", "The approach rate to enforce.", 0, 11, 0.1, 1);
4416
4419
  /**
4417
4420
  * The overall difficulty to enforce.
4418
4421
  */
4419
- this.od = new NullableDecimalModSetting("Overall difficulty", "The overall difficulty to enforce.", null, 0, 11, 0.1, 1);
4422
+ this.od = new DifficultyAdjustModSetting("Overall difficulty", "od", "The overall difficulty to enforce.", 0, 11, 0.1, 1);
4420
4423
  /**
4421
4424
  * The health drain rate to enforce.
4422
4425
  */
4423
- this.hp = new NullableDecimalModSetting("Health drain", "The health drain to enforce.", null, 0, 11, 0.1, 1);
4426
+ this.hp = new DifficultyAdjustModSetting("Health drain", "hp", "The health drain to enforce.", 0, 11, 0.1, 1);
4424
4427
  this.cs.value = this.cs.defaultValue = (_a = values === null || values === void 0 ? void 0 : values.cs) !== null && _a !== void 0 ? _a : null;
4425
4428
  this.ar.value = this.ar.defaultValue = (_b = values === null || values === void 0 ? void 0 : values.ar) !== null && _b !== void 0 ? _b : null;
4426
4429
  this.od.value = this.od.defaultValue = (_c = values === null || values === void 0 ? void 0 : values.od) !== null && _c !== void 0 ? _c : null;
4427
4430
  this.hp.value = this.hp.defaultValue = (_d = values === null || values === void 0 ? void 0 : values.hp) !== null && _d !== void 0 ? _d : null;
4428
4431
  }
4429
- copySettings(mod) {
4430
- var _a, _b, _c, _d, _e, _f, _g, _h;
4431
- super.copySettings(mod);
4432
- this.cs.value = ((_b = (_a = mod.settings) === null || _a === void 0 ? void 0 : _a.cs) !== null && _b !== void 0 ? _b : null);
4433
- this.ar.value = ((_d = (_c = mod.settings) === null || _c === void 0 ? void 0 : _c.ar) !== null && _d !== void 0 ? _d : null);
4434
- this.od.value = ((_f = (_e = mod.settings) === null || _e === void 0 ? void 0 : _e.od) !== null && _f !== void 0 ? _f : null);
4435
- this.hp.value = ((_h = (_g = mod.settings) === null || _g === void 0 ? void 0 : _g.hp) !== null && _h !== void 0 ? _h : null);
4436
- }
4437
4432
  get isDroidRelevant() {
4438
4433
  return this.isRelevant;
4439
4434
  }
@@ -4456,11 +4451,14 @@ class ModDifficultyAdjust extends Mod {
4456
4451
  }
4457
4452
  return multiplier;
4458
4453
  }
4459
- applyFromBeatmap(beatmap) {
4460
- this.cs.defaultValue = beatmap.difficulty.cs;
4461
- this.ar.defaultValue = beatmap.difficulty.ar;
4462
- this.od.defaultValue = beatmap.difficulty.od;
4463
- this.hp.defaultValue = beatmap.difficulty.hp;
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;
4464
4462
  }
4465
4463
  applyToDifficultyWithMods(_, difficulty, mods) {
4466
4464
  var _a, _b, _c, _d;
@@ -4504,25 +4502,6 @@ class ModDifficultyAdjust extends Mod {
4504
4502
  }
4505
4503
  return super.isCompatibleWith(other);
4506
4504
  }
4507
- serializeSettings() {
4508
- if (!this.isRelevant) {
4509
- return null;
4510
- }
4511
- const settings = {};
4512
- if (this.cs.value !== null) {
4513
- settings.cs = this.cs.value;
4514
- }
4515
- if (this.ar.value !== null) {
4516
- settings.ar = this.ar.value;
4517
- }
4518
- if (this.od.value !== null) {
4519
- settings.od = this.od.value;
4520
- }
4521
- if (this.hp.value !== null) {
4522
- settings.hp = this.hp.value;
4523
- }
4524
- return settings;
4525
- }
4526
4505
  applyFadeAdjustment(hitObject, mods) {
4527
4506
  // IMPORTANT: These do not use `ModUtil.calculateRateWithMods` to avoid circular dependency.
4528
4507
  const initialTrackRate = this.calculateTrackRate(mods.values());
@@ -4583,6 +4562,9 @@ class ModNightCore extends ModRateAdjust {
4583
4562
  get droidScoreMultiplier() {
4584
4563
  return super.droidScoreMultiplier;
4585
4564
  }
4565
+ get migrationDroidScoreMultiplier() {
4566
+ return super.migrationDroidScoreMultiplier;
4567
+ }
4586
4568
  get isOsuRelevant() {
4587
4569
  return this.isRelevant;
4588
4570
  }
@@ -4608,6 +4590,9 @@ class ModHalfTime extends ModRateAdjust {
4608
4590
  get droidScoreMultiplier() {
4609
4591
  return super.droidScoreMultiplier;
4610
4592
  }
4593
+ get migrationDroidScoreMultiplier() {
4594
+ return super.migrationDroidScoreMultiplier;
4595
+ }
4611
4596
  get isOsuRelevant() {
4612
4597
  return this.isRelevant;
4613
4598
  }
@@ -4633,6 +4618,9 @@ class ModDoubleTime extends ModRateAdjust {
4633
4618
  get droidScoreMultiplier() {
4634
4619
  return super.droidScoreMultiplier;
4635
4620
  }
4621
+ get migrationDroidScoreMultiplier() {
4622
+ return super.migrationDroidScoreMultiplier;
4623
+ }
4636
4624
  get isOsuRelevant() {
4637
4625
  return this.isRelevant;
4638
4626
  }
@@ -4649,10 +4637,11 @@ class ModGrow extends ModObjectScaleTween {
4649
4637
  this.droidRanked = false;
4650
4638
  this.isDroidRelevant = true;
4651
4639
  this.droidScoreMultiplier = 1;
4640
+ this.migrationDroidScoreMultiplier = 1;
4652
4641
  this.osuRanked = false;
4653
4642
  this.isOsuRelevant = true;
4654
4643
  this.osuScoreMultiplier = 1;
4655
- 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);
4656
4645
  }
4657
4646
  }
4658
4647
 
@@ -4670,7 +4659,7 @@ class ModMagnetised extends Mod {
4670
4659
  /**
4671
4660
  * How strong the pull is.
4672
4661
  */
4673
- 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);
4674
4663
  }
4675
4664
  }
4676
4665
 
@@ -4678,8 +4667,8 @@ class ModMagnetised extends Mod {
4678
4667
  * Represents a `Mod` specific setting that is constrained to a range of integer values.
4679
4668
  */
4680
4669
  class IntegerModSetting extends NumberModSetting {
4681
- constructor(name, description, defaultValue, min = -2147483648, max = 2147483647) {
4682
- 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);
4683
4672
  }
4684
4673
  }
4685
4674
 
@@ -4694,25 +4683,26 @@ class ModMuted extends Mod {
4694
4683
  this.droidRanked = false;
4695
4684
  this.isDroidRelevant = true;
4696
4685
  this.droidScoreMultiplier = 1;
4686
+ this.migrationDroidScoreMultiplier = 1;
4697
4687
  this.osuRanked = true;
4698
4688
  this.isOsuRelevant = true;
4699
4689
  this.osuScoreMultiplier = 1;
4700
4690
  /**
4701
4691
  * Increase volume as combo builds.
4702
4692
  */
4703
- 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);
4704
4694
  /**
4705
4695
  * Add a metronome beat to help the player keep track of the rhythm.
4706
4696
  */
4707
- 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);
4708
4698
  /**
4709
4699
  * The combo count at which point the track reaches its final volume.
4710
4700
  */
4711
- 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);
4712
4702
  /**
4713
4703
  * Hit sounds are also muted alongside the track.
4714
4704
  */
4715
- 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);
4716
4706
  this.inverseMuting.bindValueChanged((value) => {
4717
4707
  this.muteComboCount.min = value.newValue ? 1 : 0;
4718
4708
  }, true);
@@ -4727,27 +4717,6 @@ class ModMuted extends Mod {
4727
4717
  const volume = MathUtils.clamp(combo / Math.max(1, this.muteComboCount.value), 0, 1);
4728
4718
  return this.inverseMuting.value ? volume : 1 - volume;
4729
4719
  }
4730
- copySettings(mod) {
4731
- var _a, _b, _c, _d;
4732
- super.copySettings(mod);
4733
- const { settings } = mod;
4734
- this.inverseMuting.value =
4735
- (_a = settings === null || settings === void 0 ? void 0 : settings.inverseMuting) !== null && _a !== void 0 ? _a : this.inverseMuting.value;
4736
- this.enableMetronome.value =
4737
- (_b = settings === null || settings === void 0 ? void 0 : settings.enableMetronome) !== null && _b !== void 0 ? _b : this.enableMetronome.value;
4738
- this.muteComboCount.value =
4739
- (_c = settings === null || settings === void 0 ? void 0 : settings.muteComboCount) !== null && _c !== void 0 ? _c : this.muteComboCount.value;
4740
- this.affectsHitSounds.value =
4741
- (_d = settings === null || settings === void 0 ? void 0 : settings.affectsHitSounds) !== null && _d !== void 0 ? _d : this.affectsHitSounds.value;
4742
- }
4743
- serializeSettings() {
4744
- return {
4745
- inverseMuting: this.inverseMuting.value,
4746
- enableMetronome: this.enableMetronome.value,
4747
- muteComboCount: this.muteComboCount.value,
4748
- affectsHitSounds: this.affectsHitSounds.value,
4749
- };
4750
- }
4751
4720
  }
4752
4721
 
4753
4722
  /**
@@ -4761,6 +4730,7 @@ class ModSuddenDeath extends Mod {
4761
4730
  this.droidRanked = true;
4762
4731
  this.isDroidRelevant = true;
4763
4732
  this.droidScoreMultiplier = 1;
4733
+ this.migrationDroidScoreMultiplier = 1;
4764
4734
  this.osuRanked = true;
4765
4735
  this.isOsuRelevant = true;
4766
4736
  this.osuScoreMultiplier = 1;
@@ -4780,6 +4750,7 @@ class ModPerfect extends Mod {
4780
4750
  this.droidRanked = true;
4781
4751
  this.isDroidRelevant = true;
4782
4752
  this.droidScoreMultiplier = 1;
4753
+ this.migrationDroidScoreMultiplier = 1;
4783
4754
  this.osuRanked = true;
4784
4755
  this.isOsuRelevant = true;
4785
4756
  this.osuScoreMultiplier = 1;
@@ -4799,6 +4770,7 @@ class ModNoFail extends Mod {
4799
4770
  this.droidRanked = true;
4800
4771
  this.isDroidRelevant = true;
4801
4772
  this.droidScoreMultiplier = 0.5;
4773
+ this.migrationDroidScoreMultiplier = 0.5;
4802
4774
  this.osuRanked = true;
4803
4775
  this.isOsuRelevant = true;
4804
4776
  this.osuScoreMultiplier = 0.5;
@@ -4818,6 +4790,7 @@ class ModPrecise extends Mod {
4818
4790
  this.droidRanked = true;
4819
4791
  this.isDroidRelevant = true;
4820
4792
  this.droidScoreMultiplier = 1.06;
4793
+ this.migrationDroidScoreMultiplier = 1.06;
4821
4794
  }
4822
4795
  applyToHitObject(mode, hitObject) {
4823
4796
  var _a, _b;
@@ -4865,6 +4838,36 @@ class Utils {
4865
4838
  }
4866
4839
  return array;
4867
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
+ }
4868
4871
  /**
4869
4872
  * Pauses the execution of a function for
4870
4873
  * the specified duration.
@@ -4956,8 +4959,8 @@ Random.MAX_VALUE = 2147483647;
4956
4959
  * The value can be `null`, which is treated as a special case.
4957
4960
  */
4958
4961
  class NullableIntegerModSetting extends RangeConstrainedModSetting {
4959
- constructor(name, description, defaultValue, min = -2147483648, max = 2147483647) {
4960
- 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);
4961
4964
  this.displayFormatter = (v) => { var _a; return (_a = v === null || v === void 0 ? void 0 : v.toString()) !== null && _a !== void 0 ? _a : "None"; };
4962
4965
  if (min > max) {
4963
4966
  throw new RangeError(`The minimum value (${min.toString()}) must be less than or equal to the maximum value (${max.toString()}).`);
@@ -4967,6 +4970,23 @@ class NullableIntegerModSetting extends RangeConstrainedModSetting {
4967
4970
  throw new RangeError(`The default value (${defaultValue.toString()}) must be between the minimum (${min.toString()}) and maximum (${max.toString()}) values.`);
4968
4971
  }
4969
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
+ }
4970
4990
  processValue(value) {
4971
4991
  if (value === null) {
4972
4992
  return null;
@@ -4986,29 +5006,20 @@ class ModRandom extends Mod {
4986
5006
  this.droidRanked = false;
4987
5007
  this.isDroidRelevant = true;
4988
5008
  this.droidScoreMultiplier = 1;
5009
+ this.migrationDroidScoreMultiplier = 1;
4989
5010
  this.osuRanked = false;
4990
5011
  this.isOsuRelevant = true;
4991
5012
  this.osuScoreMultiplier = 1;
4992
5013
  /**
4993
5014
  * The seed to use.
4994
5015
  */
4995
- 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);
4996
5017
  /**
4997
5018
  * Defines how sharp the angles of `HitObject`s should be.
4998
5019
  */
4999
- 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);
5000
5021
  this.random = null;
5001
5022
  }
5002
- copySettings(mod) {
5003
- super.copySettings(mod);
5004
- const { settings } = mod;
5005
- if (typeof (settings === null || settings === void 0 ? void 0 : settings.seed) === "number") {
5006
- this.seed.value = settings.seed;
5007
- }
5008
- if (typeof (settings === null || settings === void 0 ? void 0 : settings.angleSharpness) === "number") {
5009
- this.angleSharpness.value = settings.angleSharpness;
5010
- }
5011
- }
5012
5023
  applyToBeatmap(beatmap) {
5013
5024
  var _a;
5014
5025
  var _b;
@@ -5060,14 +5071,6 @@ class ModRandom extends Mod {
5060
5071
  beatmap.hitObjects.objects[i] = repositionedHitObjects[i];
5061
5072
  }
5062
5073
  }
5063
- serializeSettings() {
5064
- const settings = {};
5065
- if (this.seed.value !== null) {
5066
- settings.seed = this.seed.value;
5067
- }
5068
- settings.angleSharpness = this.angleSharpness.value;
5069
- return settings;
5070
- }
5071
5074
  getRandomOffset(stdDev) {
5072
5075
  // Range: [0.5, 2]
5073
5076
  // Higher angle sharpness -> lower multiplier
@@ -5143,6 +5146,7 @@ class ModScoreV2 extends Mod {
5143
5146
  this.droidRanked = false;
5144
5147
  this.isDroidRelevant = true;
5145
5148
  this.droidScoreMultiplier = 1;
5149
+ this.migrationDroidScoreMultiplier = 1;
5146
5150
  this.osuRanked = false;
5147
5151
  this.isOsuRelevant = true;
5148
5152
  this.osuScoreMultiplier = 1;
@@ -5176,6 +5180,7 @@ class ModSynesthesia extends Mod {
5176
5180
  this.droidRanked = false;
5177
5181
  this.isDroidRelevant = true;
5178
5182
  this.droidScoreMultiplier = 0.8;
5183
+ this.migrationDroidScoreMultiplier = 0.8;
5179
5184
  this.osuRanked = false;
5180
5185
  this.isOsuRelevant = true;
5181
5186
  this.osuScoreMultiplier = 0.8;
@@ -5383,21 +5388,18 @@ class ModTimeRamp extends Mod {
5383
5388
  // Graph: https://www.desmos.com/calculator/1zp4vwl3o7
5384
5389
  return Interpolation.lerp(this.calculateScoreMultiplierAt(this.initialRate.value), this.calculateScoreMultiplierAt(this.finalRate.value), ModTimeRamp.finalRateProgress);
5385
5390
  }
5391
+ /**
5392
+ * The generic osu!droid migration score multiplier of this `Mod`.
5393
+ */
5394
+ get migrationDroidScoreMultiplier() {
5395
+ return this.droidScoreMultiplier;
5396
+ }
5386
5397
  constructor() {
5387
5398
  super();
5388
5399
  this.initialRateTime = 0;
5389
5400
  this.finalRateTime = 0;
5390
5401
  this.incompatibleMods.add(ModTimeRamp);
5391
5402
  }
5392
- copySettings(mod) {
5393
- var _a, _b;
5394
- super.copySettings(mod);
5395
- const { settings } = mod;
5396
- this.initialRate.value =
5397
- (_a = settings === null || settings === void 0 ? void 0 : settings.initialRate) !== null && _a !== void 0 ? _a : this.initialRate.value;
5398
- this.finalRate.value =
5399
- (_b = settings === null || settings === void 0 ? void 0 : settings.finalRate) !== null && _b !== void 0 ? _b : this.finalRate.value;
5400
- }
5401
5403
  applyToBeatmap(beatmap) {
5402
5404
  var _a, _b, _c, _d;
5403
5405
  this.initialRateTime = (_b = (_a = beatmap.hitObjects.objects.at(0)) === null || _a === void 0 ? void 0 : _a.startTime) !== null && _b !== void 0 ? _b : 0;
@@ -5412,12 +5414,6 @@ class ModTimeRamp extends Mod {
5412
5414
  calculateScoreMultiplierAt(rate) {
5413
5415
  return rate > 1 ? 1 + (rate - 1) * 0.24 : Math.pow(0.3, (1 - rate) * 4);
5414
5416
  }
5415
- serializeSettings() {
5416
- return {
5417
- initialRate: this.initialRate.value,
5418
- finalRate: this.finalRate.value,
5419
- };
5420
- }
5421
5417
  toString() {
5422
5418
  return `${super.toString()} (${this.initialRate.toDisplayString()}x - ${this.finalRate.toDisplayString()}x)`;
5423
5419
  }
@@ -5434,6 +5430,9 @@ class ModWindDown extends ModTimeRamp {
5434
5430
  get droidScoreMultiplier() {
5435
5431
  return super.droidScoreMultiplier;
5436
5432
  }
5433
+ get migrationDroidScoreMultiplier() {
5434
+ return super.migrationDroidScoreMultiplier;
5435
+ }
5437
5436
  constructor() {
5438
5437
  super();
5439
5438
  this.name = "Wind Down";
@@ -5443,8 +5442,8 @@ class ModWindDown extends ModTimeRamp {
5443
5442
  this.osuRanked = false;
5444
5443
  this.isOsuRelevant = true;
5445
5444
  this.osuScoreMultiplier = 1;
5446
- this.initialRate = new DecimalModSetting("Initial rate", "The starting speed of the track.", 1, 0.51, 2, 0.01, 2);
5447
- 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);
5448
5447
  this.initialRate.bindValueChanged((value) => {
5449
5448
  if (value.newValue <= this.finalRate.value) {
5450
5449
  this.finalRate.value = value.newValue - this.finalRate.step;
@@ -5465,6 +5464,9 @@ class ModWindUp extends ModTimeRamp {
5465
5464
  get droidScoreMultiplier() {
5466
5465
  return super.droidScoreMultiplier;
5467
5466
  }
5467
+ get migrationDroidScoreMultiplier() {
5468
+ return super.migrationDroidScoreMultiplier;
5469
+ }
5468
5470
  constructor() {
5469
5471
  super();
5470
5472
  this.name = "Wind Up";
@@ -5474,8 +5476,8 @@ class ModWindUp extends ModTimeRamp {
5474
5476
  this.osuRanked = false;
5475
5477
  this.isOsuRelevant = true;
5476
5478
  this.osuScoreMultiplier = 1;
5477
- this.initialRate = new DecimalModSetting("Initial rate", "The starting speed of the track.", 1, 0.5, 1.99, 0.01, 2);
5478
- 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);
5479
5481
  this.initialRate.bindValueChanged((value) => {
5480
5482
  if (value.newValue >= this.finalRate.value) {
5481
5483
  this.finalRate.value = value.newValue + this.finalRate.step;
@@ -5517,40 +5519,62 @@ class ModUtil {
5517
5519
  *
5518
5520
  * @param mods The mods to calculate the score multiplier for.
5519
5521
  * @param mode The game mode to calculate the score multiplier for.
5520
- * @param beatmap The beatmap the mods are applied to. Needed for some mods to have an effect on
5522
+ * @param difficulty The `BeatmapDifficulty` to apply to the mods. Needed for some mods to have an effect on
5521
5523
  * score multiplier (i.e., `ModDifficultyAdjust`).
5522
5524
  * @returns The score multiplier.
5523
5525
  */
5524
- static calculateScoreMultiplier(mods, mode, beatmap) {
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) {
5525
5555
  // In osu!droid, rate-adjusting mods combine their track rate multipliers together, then bunched together.
5526
5556
  let totalRateAdjustTrackRateMultiplier = 1;
5527
5557
  let scoreMultiplier = 1;
5528
5558
  for (const mod of mods) {
5529
- if (mod.requiresOriginalBeatmap() && beatmap) {
5530
- mod.applyFromBeatmap(beatmap);
5559
+ if (mod.requiresBeatmapDifficulty() && difficulty) {
5560
+ mod.applyFromBeatmapDifficulty(difficulty);
5531
5561
  }
5532
5562
  if (mode === exports.Modes.droid && mod instanceof ModRateAdjust) {
5533
5563
  totalRateAdjustTrackRateMultiplier *=
5534
5564
  mod.trackRateMultiplier.value;
5535
5565
  }
5536
5566
  else {
5537
- switch (mode) {
5538
- case exports.Modes.droid:
5539
- if (mod.isApplicableToDroid()) {
5540
- scoreMultiplier *= mod.droidScoreMultiplier;
5541
- }
5542
- break;
5543
- case exports.Modes.osu:
5544
- if (mod.isApplicableToOsuStable()) {
5545
- scoreMultiplier *= mod.osuScoreMultiplier;
5546
- }
5547
- break;
5548
- }
5567
+ const multiplierValue = modSelector(mod);
5568
+ scoreMultiplier =
5569
+ mode === exports.Modes.droid
5570
+ ? Math.fround(scoreMultiplier * Math.fround(multiplierValue))
5571
+ : scoreMultiplier * multiplierValue;
5549
5572
  }
5550
5573
  }
5551
5574
  if (mode === exports.Modes.droid) {
5552
5575
  const rateAdjustHelper = new ModRateAdjustHelper(totalRateAdjustTrackRateMultiplier);
5553
- scoreMultiplier *= rateAdjustHelper.droidScoreMultiplier;
5576
+ scoreMultiplier = Math.fround(scoreMultiplier *
5577
+ Math.fround(rateAdjustSelector(rateAdjustHelper)));
5554
5578
  }
5555
5579
  return scoreMultiplier;
5556
5580
  }
@@ -5713,8 +5737,8 @@ class ModUtil {
5713
5737
  }
5714
5738
  break;
5715
5739
  case exports.Modes.osu: {
5716
- const hitWindow = new OsuHitWindow(difficulty.od);
5717
- difficulty.od = OsuHitWindow.greatWindowToOD(hitWindow.greatWindow / rate);
5740
+ const greatWindow = new OsuHitWindow(difficulty.od).greatWindow / rate;
5741
+ difficulty.od = (79.5 - greatWindow) / 6;
5718
5742
  break;
5719
5743
  }
5720
5744
  }
@@ -7121,10 +7145,10 @@ class Beatmap {
7121
7145
  */
7122
7146
  maxDroidScore(mods) {
7123
7147
  const scoreMultiplier = mods
7124
- ? ModUtil.calculateScoreMultiplier(mods.values(), exports.Modes.droid, this)
7148
+ ? ModUtil.calculateScoreMultiplier(mods.values(), exports.Modes.droid, this.difficulty)
7125
7149
  : 1;
7126
7150
  if (mods === null || mods === void 0 ? void 0 : mods.has(ModScoreV2)) {
7127
- return 1e6 * scoreMultiplier;
7151
+ return Math.round(Math.fround(1e6 * scoreMultiplier));
7128
7152
  }
7129
7153
  const difficultyMultiplier = 1 +
7130
7154
  this.difficulty.od / 10 +
@@ -7132,27 +7156,39 @@ class Beatmap {
7132
7156
  (this.difficulty.cs - 3) / 4;
7133
7157
  let combo = 0;
7134
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
+ }
7135
7164
  for (const object of this.hitObjects.objects) {
7136
- if (!(object instanceof Slider)) {
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.
7137
7177
  score += Math.floor(300 + (300 * combo * difficultyMultiplier) / 25);
7138
7178
  ++combo;
7139
- continue;
7140
7179
  }
7141
- const { ticks } = object;
7142
- // Apply slider head.
7143
- score += 30;
7144
- ++combo;
7145
- // Apply slider repeats.
7146
- score += 30 * object.repeatCount;
7147
- combo += object.repeatCount;
7148
- // Apply slider ticks.
7149
- score += 10 * ticks;
7150
- combo += ticks;
7151
- // 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
+ }
7152
7188
  score += Math.floor(300 + (300 * combo * difficultyMultiplier) / 25);
7153
7189
  ++combo;
7154
7190
  }
7155
- return Math.floor(score * scoreMultiplier);
7191
+ return Math.round(Math.fround(score * scoreMultiplier));
7156
7192
  }
7157
7193
  /**
7158
7194
  * Calculates the osu!standard maximum score of the beatmap without taking spinner bonus into account.
@@ -7163,7 +7199,7 @@ class Beatmap {
7163
7199
  const accumulatedDiffPoints = this.difficulty.cs + this.difficulty.hp + this.difficulty.od;
7164
7200
  let difficultyMultiplier = 2;
7165
7201
  const scoreMultiplier = mods
7166
- ? ModUtil.calculateScoreMultiplier(mods.values(), exports.Modes.osu, this)
7202
+ ? ModUtil.calculateScoreMultiplier(mods.values(), exports.Modes.osu, this.difficulty)
7167
7203
  : 1;
7168
7204
  if (mods === null || mods === void 0 ? void 0 : mods.has(ModScoreV2)) {
7169
7205
  return 1e6 * scoreMultiplier;
@@ -7187,25 +7223,34 @@ class Beatmap {
7187
7223
  }
7188
7224
  let combo = 0;
7189
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
+ }
7190
7231
  for (const object of this.hitObjects.objects) {
7191
- if (!(object instanceof Slider)) {
7192
- score += Math.floor(300 +
7193
- (300 * combo * difficultyMultiplier * scoreMultiplier) /
7194
- 25);
7232
+ if (object instanceof Slider) {
7233
+ const { ticks } = object;
7234
+ // Apply slider head.
7235
+ score += 30;
7195
7236
  ++combo;
7196
- continue;
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
+ }
7197
7253
  }
7198
- const { ticks } = object;
7199
- // Apply slider head.
7200
- score += 30;
7201
- ++combo;
7202
- // Apply slider repeats.
7203
- score += 30 * object.repeatCount;
7204
- combo += object.repeatCount;
7205
- // Apply slider ticks.
7206
- score += 10 * ticks;
7207
- combo += ticks;
7208
- // Apply slider end.
7209
7254
  score += Math.floor(300 +
7210
7255
  (300 * combo * difficultyMultiplier * scoreMultiplier) / 25);
7211
7256
  ++combo;
@@ -7332,16 +7377,6 @@ class Beatmap {
7332
7377
  }
7333
7378
  }
7334
7379
 
7335
- /**
7336
- * Represents a beatmap's background.
7337
- */
7338
- class BeatmapBackground {
7339
- constructor(filename, offset) {
7340
- this.filename = filename;
7341
- this.offset = offset;
7342
- }
7343
- }
7344
-
7345
7380
  /* eslint-disable @typescript-eslint/prefer-literal-enum-member */
7346
7381
  /**
7347
7382
  * Represents available hitsound types.
@@ -7958,6 +7993,16 @@ class BeatmapEditorDecoder extends SectionDecoder {
7958
7993
  }
7959
7994
  }
7960
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
+
7961
8006
  /**
7962
8007
  * Represents a beatmap's video.
7963
8008
  */
@@ -8052,16 +8097,16 @@ class BeatmapDifficultyDecoder extends SectionDecoder {
8052
8097
  const p = this.property(line);
8053
8098
  switch (p[0]) {
8054
8099
  case "CircleSize":
8055
- 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);
8056
8101
  break;
8057
8102
  case "OverallDifficulty":
8058
- 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);
8059
8104
  break;
8060
8105
  case "ApproachRate":
8061
- 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);
8062
8107
  break;
8063
8108
  case "HPDrainRate":
8064
- 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);
8065
8110
  break;
8066
8111
  case "SliderMultiplier":
8067
8112
  this.target.difficulty.sliderMultiplier = MathUtils.clamp(this.tryParseFloat(this.setPosition(p[1])), 0.4, 3.6);
@@ -8892,6 +8937,15 @@ class StoryboardSample extends StoryboardElement {
8892
8937
  }
8893
8938
  }
8894
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
+
8895
8949
  /**
8896
8950
  * Types of storyboard events.
8897
8951
  */
@@ -10022,47 +10076,82 @@ class BeatmapEncoder extends Encoder {
10022
10076
  }
10023
10077
 
10024
10078
  /**
10025
- * Available genres in an online osu! beatmap.
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**.
10026
10082
  */
10027
- exports.BeatmapGenre = void 0;
10028
- (function (BeatmapGenre) {
10029
- BeatmapGenre[BeatmapGenre["any"] = 0] = "any";
10030
- BeatmapGenre[BeatmapGenre["unspecified"] = 1] = "unspecified";
10031
- BeatmapGenre[BeatmapGenre["videoGame"] = 2] = "videoGame";
10032
- BeatmapGenre[BeatmapGenre["anime"] = 3] = "anime";
10033
- BeatmapGenre[BeatmapGenre["rock"] = 4] = "rock";
10034
- BeatmapGenre[BeatmapGenre["pop"] = 5] = "pop";
10035
- BeatmapGenre[BeatmapGenre["other"] = 6] = "other";
10036
- BeatmapGenre[BeatmapGenre["novelty"] = 7] = "novelty";
10037
- BeatmapGenre[BeatmapGenre["hipHop"] = 9] = "hipHop";
10038
- BeatmapGenre[BeatmapGenre["electronic"] = 10] = "electronic";
10039
- BeatmapGenre[BeatmapGenre["metal"] = 11] = "metal";
10040
- BeatmapGenre[BeatmapGenre["classical"] = 12] = "classical";
10041
- BeatmapGenre[BeatmapGenre["folk"] = 13] = "folk";
10042
- BeatmapGenre[BeatmapGenre["jazz"] = 14] = "jazz";
10043
- })(exports.BeatmapGenre || (exports.BeatmapGenre = {}));
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
+ }
10044
10121
 
10045
10122
  /**
10046
- * Available languages in an online osu! beatmap.
10123
+ * General enum to specify an "anchor" or "origin" point from the standard 9 points on a rectangle.
10047
10124
  */
10048
- exports.BeatmapLanguage = void 0;
10049
- (function (BeatmapLanguage) {
10050
- BeatmapLanguage[BeatmapLanguage["any"] = 0] = "any";
10051
- BeatmapLanguage[BeatmapLanguage["unspecified"] = 1] = "unspecified";
10052
- BeatmapLanguage[BeatmapLanguage["english"] = 2] = "english";
10053
- BeatmapLanguage[BeatmapLanguage["japanese"] = 3] = "japanese";
10054
- BeatmapLanguage[BeatmapLanguage["chinese"] = 4] = "chinese";
10055
- BeatmapLanguage[BeatmapLanguage["instrumental"] = 5] = "instrumental";
10056
- BeatmapLanguage[BeatmapLanguage["korean"] = 6] = "korean";
10057
- BeatmapLanguage[BeatmapLanguage["french"] = 7] = "french";
10058
- BeatmapLanguage[BeatmapLanguage["german"] = 8] = "german";
10059
- BeatmapLanguage[BeatmapLanguage["swedish"] = 9] = "swedish";
10060
- BeatmapLanguage[BeatmapLanguage["spanish"] = 10] = "spanish";
10061
- BeatmapLanguage[BeatmapLanguage["italian"] = 11] = "italian";
10062
- BeatmapLanguage[BeatmapLanguage["russian"] = 12] = "russian";
10063
- BeatmapLanguage[BeatmapLanguage["polish"] = 13] = "polish";
10064
- BeatmapLanguage[BeatmapLanguage["other"] = 14] = "other";
10065
- })(exports.BeatmapLanguage || (exports.BeatmapLanguage = {}));
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 = {}));
10066
10155
 
10067
10156
  class Bin {
10068
10157
  constructor() {
@@ -10431,417 +10520,116 @@ class Chandrupatla {
10431
10520
  }
10432
10521
  }
10433
10522
 
10434
- /******************************************************************************
10435
- Copyright (c) Microsoft Corporation.
10436
-
10437
- Permission to use, copy, modify, and/or distribute this software for any
10438
- purpose with or without fee is hereby granted.
10439
-
10440
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
10441
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10442
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10443
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
10444
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
10445
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
10446
- PERFORMANCE OF THIS SOFTWARE.
10447
- ***************************************************************************** */
10448
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
10449
-
10450
-
10451
- function __awaiter(thisArg, _arguments, P, generator) {
10452
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10453
- return new (P || (P = Promise))(function (resolve, reject) {
10454
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10455
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
10456
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10457
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10458
- });
10459
- }
10460
-
10461
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
10462
- var e = new Error(message);
10463
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
10464
- };
10465
-
10466
10523
  /**
10467
- * The base of API request builders.
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}.
10468
10527
  */
10469
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
10470
- class APIRequestBuilder {
10471
- constructor() {
10472
- /**
10473
- * Whether or not to include the API key in the request URL.
10474
- */
10475
- this.requiresAPIkey = true;
10476
- /**
10477
- * The endpoint of this builder.
10478
- */
10479
- this.endpoint = "";
10480
- /**
10481
- * The parameters of this builder.
10482
- */
10483
- this.params = new Map();
10484
- this.fetchAttempts = 0;
10485
- }
10486
- /**
10487
- * The base URL of this builder.
10488
- */
10489
- get baseURL() {
10490
- return this.host + this.endpoint;
10491
- }
10528
+ class Polynomial {
10492
10529
  /**
10493
- * Sets the API endpoint.
10530
+ * Evaluates a polynomial at point `z`.
10494
10531
  *
10495
- * @param endpoint The endpoint to set.
10496
- */
10497
- setEndpoint(endpoint) {
10498
- this.endpoint = endpoint;
10499
- return this;
10500
- }
10501
- /**
10502
- * Sets if this builder includes the API key in the request URL.
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`.
10503
10534
  *
10504
- * @param requireAPIkey Whether or not to include the API key in the request URL.
10505
- */
10506
- setRequireAPIkey(requireAPIkey) {
10507
- this.requiresAPIkey = requireAPIkey;
10508
- return this;
10509
- }
10510
- /**
10511
- * Builds the URL to request the API.
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`.
10512
10538
  */
10513
- buildURL() {
10514
- let url = this.baseURL + "?";
10515
- if (this.requiresAPIkey) {
10516
- if (!this.APIkey) {
10517
- throw new Error("An API key has not been specified");
10518
- }
10519
- url += this.APIkeyParam;
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;
10520
10544
  }
10521
- for (const [param, value] of this.params.entries()) {
10522
- url += `${param}=${encodeURIComponent(value)}&`;
10545
+ let sum = coefficients.at(-1);
10546
+ for (let i = coefficients.length - 2; i >= 0; --i) {
10547
+ sum *= z;
10548
+ sum += coefficients[i];
10523
10549
  }
10524
- return url;
10525
- }
10526
- /**
10527
- * Sends a request to the API using built parameters.
10528
- *
10529
- * If the request fails, it will be redone 5 times.
10530
- */
10531
- sendRequest() {
10532
- return new Promise((resolve) => {
10533
- const url = this.buildURL();
10534
- fetch(url)
10535
- .then((res) => __awaiter(this, void 0, void 0, function* () {
10536
- ++this.fetchAttempts;
10537
- if (res.status >= 500 && this.fetchAttempts < 5) {
10538
- console.error(`Request to ${url} failed with the following error: ${yield res.text()}; ${this.fetchAttempts.toString()} attempts so far; retrying`);
10539
- resolve(this.sendRequest());
10540
- return;
10541
- }
10542
- this.fetchAttempts = 0;
10543
- resolve({
10544
- data: Buffer.from(yield res.arrayBuffer()),
10545
- statusCode: res.status,
10546
- });
10547
- }))
10548
- .catch((e) => {
10549
- console.error(`Request to ${url} failed with the following error: ${e.message}; ${this.fetchAttempts.toString()} attempts so far; aborting`);
10550
- this.fetchAttempts = 0;
10551
- resolve({
10552
- data: Buffer.from([]),
10553
- statusCode: 400,
10554
- });
10555
- return;
10556
- });
10557
- });
10558
- }
10559
- /**
10560
- * Adds a parameter to the builder.
10561
- *
10562
- * @param param The parameter to add.
10563
- * @param value The value to add for the parameter.
10564
- */
10565
- addParameter(param, value) {
10566
- this.params.set(param, value.toString());
10567
- return this;
10568
- }
10569
- /**
10570
- * Removes a parameter from the builder.
10571
- *
10572
- * @param param The parameter to remove.
10573
- */
10574
- removeParameter(param) {
10575
- this.params.delete(param);
10576
- return this;
10577
- }
10578
- }
10579
-
10580
- /**
10581
- * An API request builder for osu!droid.
10582
- */
10583
- class DroidAPIRequestBuilder extends APIRequestBuilder {
10584
- constructor() {
10585
- super(...arguments);
10586
- this.host = "https://osudroid.moe/api/";
10587
- this.APIkey = DroidAPIRequestBuilder.apiKey;
10588
- this.APIkeyParam = `apiKey=${this.APIkey}&`;
10550
+ return sum;
10589
10551
  }
10590
10552
  /**
10591
- * Sets the API key for all subsequent initializations of a `DroidAPIRequestBuilder`.
10553
+ * Solve for the exact real roots of any polynomial up to degree 4.
10592
10554
  *
10593
- * @param key The API key.
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.
10594
10557
  */
10595
- static setAPIKey(key) {
10596
- this.apiKey = key;
10597
- }
10598
- buildURL() {
10599
- switch (this.endpoint) {
10600
- case "upload":
10601
- case "bestpp": {
10602
- let url = this.baseURL + "/";
10603
- for (const [, value] of this.params.entries()) {
10604
- url += encodeURIComponent(value);
10605
- }
10606
- return url;
10607
- }
10608
- default:
10609
- return super.buildURL();
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;
10610
10573
  }
10574
+ return xVals;
10611
10575
  }
10612
- }
10613
- DroidAPIRequestBuilder.apiKey = "";
10614
-
10615
- /**
10616
- * A set of utilities to handle legacy mods storage conversion to the new storage format in osu!droid.
10617
- */
10618
- class DroidLegacyModConverter {
10619
- /**
10620
- * Converts a legacy mod string to an array of `Mod`s.
10621
- *
10622
- * @param str The mod string to convert.
10623
- * @param difficulty The `BeatmapDifficulty` to use for `IMigratableDroidMod` migrations. When omitted, `IMigratableDroidMod`s will not be migrated.
10624
- * @returns An array of `Mod`s.
10625
- */
10626
- static convert(str, difficulty) {
10627
- const map = new ModMap();
10628
- if (!str) {
10629
- return map;
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;
10630
10590
  }
10631
- const data = str.split("|");
10632
- for (const c of data[0]) {
10633
- const modType = this.legacyStorableMods.get(c);
10634
- if (!modType) {
10635
- continue;
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];
10636
10609
  }
10637
- const mod = new modType();
10638
- if (mod.isMigratableDroidMod() && difficulty) {
10639
- map.set(mod.migrateDroidMod(difficulty));
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;
10640
10620
  }
10641
10621
  else {
10642
- map.set(mod);
10622
+ sqD = Math.sqrt(upperD);
10623
+ p1 = (b + sqD) * 0.5;
10624
+ p2 = (b - sqD) * 0.5;
10643
10625
  }
10644
10626
  }
10645
- if (data.length > 1) {
10646
- this.parseExtraModString(map, data.slice(1));
10647
- }
10648
- return map;
10649
- }
10650
- /**
10651
- * Parses the extra strings of a mod string.
10652
- *
10653
- * @param map The current `Mod`s.
10654
- * @param extraStrings The extra strings to parse.
10655
- */
10656
- static parseExtraModString(map, extraStrings) {
10657
- let customCS;
10658
- let customAR;
10659
- let customOD;
10660
- let customHP;
10661
- for (const s of extraStrings) {
10662
- switch (true) {
10663
- // Forced stats
10664
- case s.startsWith("CS"):
10665
- customCS = parseFloat(s.slice(2));
10666
- break;
10667
- case s.startsWith("AR"):
10668
- customAR = parseFloat(s.slice(2));
10669
- break;
10670
- case s.startsWith("OD"):
10671
- customOD = parseFloat(s.slice(2));
10672
- break;
10673
- case s.startsWith("HP"):
10674
- customHP = parseFloat(s.slice(2));
10675
- break;
10676
- // FL follow delay
10677
- case s.startsWith("FLD"): {
10678
- let flashlight = map.get(ModFlashlight);
10679
- if (!flashlight) {
10680
- flashlight = new ModFlashlight();
10681
- map.set(flashlight);
10682
- }
10683
- flashlight.followDelay.value = parseFloat(s.slice(3));
10684
- break;
10685
- }
10686
- // Speed multiplier
10687
- case s.startsWith("x"): {
10688
- let customSpeed = map.get(ModCustomSpeed);
10689
- if (!customSpeed) {
10690
- customSpeed = new ModCustomSpeed();
10691
- map.set(customSpeed);
10692
- }
10693
- customSpeed.trackRateMultiplier.value = parseFloat(s.slice(1));
10694
- break;
10695
- }
10696
- }
10697
- }
10698
- if (customCS !== undefined ||
10699
- customAR !== undefined ||
10700
- customOD !== undefined ||
10701
- customHP !== undefined) {
10702
- map.set(new ModDifficultyAdjust({
10703
- cs: customCS,
10704
- ar: customAR,
10705
- od: customOD,
10706
- hp: customHP,
10707
- }));
10708
- }
10709
- }
10710
- }
10711
- /**
10712
- * All `Mod`s that can be stored in the legacy mods format by their respective encode character.
10713
- */
10714
- DroidLegacyModConverter.legacyStorableMods = new Map([
10715
- ["a", ModAuto],
10716
- ["b", ModTraceable],
10717
- ["c", ModNightCore],
10718
- ["d", ModDoubleTime],
10719
- ["e", ModEasy],
10720
- ["f", ModPerfect],
10721
- ["h", ModHidden],
10722
- ["i", ModFlashlight],
10723
- ["l", ModReallyEasy],
10724
- ["m", ModSmallCircle],
10725
- ["n", ModNoFail],
10726
- ["p", ModAutopilot],
10727
- ["r", ModHardRock],
10728
- ["s", ModPrecise],
10729
- ["t", ModHalfTime],
10730
- ["u", ModSuddenDeath],
10731
- ["v", ModScoreV2],
10732
- ["x", ModRelax],
10733
- ]);
10734
-
10735
- /**
10736
- * A single-variable polynomial with real-valued coefficients and non-negative exponents.
10737
- *
10738
- * This class shares the same implementation as {@link https://numerics.mathdotnet.com/ Math.NET Numerics}.
10739
- */
10740
- class Polynomial {
10741
- /**
10742
- * Evaluates a polynomial at point `z`.
10743
- *
10744
- * Coefficients are ordered ascending by power with power `k` at index `k`.
10745
- * For example, coefficients `[3, -1, 2]` represent `y = 2x^2 - x + 3`.
10746
- *
10747
- * @param z The location where to evaluate the polynomial at.
10748
- * @param coefficients The coefficients of the polynomial, coefficient for power `k` at index `k`.
10749
- * @returns The polynomial at `z`.
10750
- */
10751
- static evaluate(z, coefficients) {
10752
- // Zero polynomials need explicit handling, otherwise we
10753
- // will attempt to peek coefficients at negative indices.
10754
- if (coefficients.length === 0) {
10755
- return 0;
10756
- }
10757
- let sum = coefficients.at(-1);
10758
- for (let i = coefficients.length - 2; i >= 0; --i) {
10759
- sum *= z;
10760
- sum += coefficients[i];
10761
- }
10762
- return sum;
10763
- }
10764
- /**
10765
- * Solve for the exact real roots of any polynomial up to degree 4.
10766
- *
10767
- * @param coefficients The coefficients of the polynomial, in ascending order ([1, 3, 5] -> x^2 + 3x + 5).
10768
- * @returns The real roots of the polynomial, and `null` if the root does not exist.
10769
- */
10770
- static solve(coefficients) {
10771
- let xVals = [];
10772
- switch (coefficients.length) {
10773
- case 5:
10774
- xVals = this.solveP4(coefficients[0], coefficients[1], coefficients[2], coefficients[3], coefficients[4]).roots;
10775
- break;
10776
- case 4:
10777
- xVals = this.solveP3(coefficients[0], coefficients[1], coefficients[2], coefficients[3]).roots;
10778
- break;
10779
- case 3:
10780
- xVals = this.solveP2(coefficients[0], coefficients[1], coefficients[2]).roots;
10781
- break;
10782
- case 2:
10783
- xVals = this.solveP2(0, coefficients[0], coefficients[1]).roots;
10784
- break;
10785
- }
10786
- return xVals;
10787
- }
10788
- // https://github.com/sasamil/Quartic/blob/master/quartic.cpp
10789
- static solveP4(a, b, c, d, e) {
10790
- const result = {
10791
- count: 0,
10792
- roots: new Array(4),
10793
- };
10794
- if (a === 0) {
10795
- const xValsCubic = this.solveP3(b, c, d, e);
10796
- result.count = xValsCubic.count;
10797
- result.roots[0] = xValsCubic.roots[0];
10798
- result.roots[1] = xValsCubic.roots[1];
10799
- result.roots[2] = xValsCubic.roots[2];
10800
- result.roots[3] = null;
10801
- return result;
10802
- }
10803
- b /= a;
10804
- c /= a;
10805
- d /= a;
10806
- e /= a;
10807
- const a3 = -c;
10808
- const b3 = b * d - 4 * e;
10809
- const c3 = -b * b * e - d * d + 4 * c * e;
10810
- const x3 = this.solveP3(1, a3, b3, c3);
10811
- let q1;
10812
- let q2;
10813
- let p1;
10814
- let p2;
10815
- let sqD;
10816
- let y = x3.roots[0];
10817
- // Get the y value with the highest absolute value.
10818
- if (x3.count !== 1) {
10819
- if (Math.abs(x3.roots[1]) > Math.abs(y)) {
10820
- y = x3.roots[1];
10821
- }
10822
- if (Math.abs(x3.roots[2]) > Math.abs(y)) {
10823
- y = x3.roots[2];
10824
- }
10825
- }
10826
- let upperD = y * y - 4 * e;
10827
- if (Precision.almostEquals(upperD, 0)) {
10828
- q1 = q2 = y * 0.5;
10829
- upperD = b * b - 4 * (c - y);
10830
- if (Precision.almostEquals(upperD, 0)) {
10831
- p1 = p2 = b * 0.5;
10832
- }
10833
- else {
10834
- sqD = Math.sqrt(upperD);
10835
- p1 = (b + sqD) * 0.5;
10836
- p2 = (b - sqD) * 0.5;
10837
- }
10838
- }
10839
- else {
10840
- sqD = Math.sqrt(upperD);
10841
- q1 = (y + sqD) * 0.5;
10842
- q2 = (y - sqD) * 0.5;
10843
- p1 = (b * q1 - d) / (q1 - q2);
10844
- p2 = (d - b * q2) / (q1 - q2);
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);
10845
10633
  }
10846
10634
  // Solving quadratic eq. - x^2 + p1*x + q1 = 0.
10847
10635
  upperD = p1 * p1 - 4 * q1;
@@ -11677,167 +11465,594 @@ ErrorFunction.ervInvImpFn = [
11677
11465
  * Polynomial coefficients for a denominator of erfInvImp
11678
11466
  * calculation for erf^-1(z) in the interval [0.75, 1] with x between 18 and 44.
11679
11467
  */
11680
- ErrorFunction.ervInvImpFd = [
11681
- 1, 0.20712311221442251, 0.01694108381209759, 0.0006905382656226846,
11682
- 0.14500735981823264e-4, 0.14443775662814415e-6, 0.5097612765997785e-9,
11683
- ];
11468
+ ErrorFunction.ervInvImpFd = [
11469
+ 1, 0.20712311221442251, 0.01694108381209759, 0.0006905382656226846,
11470
+ 0.14500735981823264e-4, 0.14443775662814415e-6, 0.5097612765997785e-9,
11471
+ ];
11472
+ /**
11473
+ * Polynomial coefficients for a numerator of erfInvImp
11474
+ * calculation for erf^-1(z) in the interval [0.75, 1] with x greater than 44.
11475
+ */
11476
+ ErrorFunction.ervInvImpGn = [
11477
+ -5390429110190786e-19, -2.839875900472772e-7, 0.8994651148922914e-6,
11478
+ 0.2293458592659209e-7, 0.2255614448635001e-9, 0.9478466275030226e-12,
11479
+ 0.13588013010892486e-14, -3488903933999489e-37,
11480
+ ];
11481
+ /**
11482
+ * Polynomial coefficients for a denominator of erfInvImp
11483
+ * calculation for erf^-1(z) in the interval [0.75, 1] with x greater than 44.
11484
+ */
11485
+ ErrorFunction.ervInvImpGd = [
11486
+ 1, 0.08457462340018994, 0.002820929847262647, 0.4682929219408942e-4,
11487
+ 0.3999688121938621e-6, 0.1618092908879045e-8, 0.2315586083102596e-11,
11488
+ ];
11489
+
11490
+ /**
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
+
11684
11833
  /**
11685
- * Polynomial coefficients for a numerator of erfInvImp
11686
- * calculation for erf^-1(z) in the interval [0.75, 1] with x greater than 44.
11834
+ * Available genres in an online osu! beatmap.
11687
11835
  */
11688
- ErrorFunction.ervInvImpGn = [
11689
- -5390429110190786e-19, -2.839875900472772e-7, 0.8994651148922914e-6,
11690
- 0.2293458592659209e-7, 0.2255614448635001e-9, 0.9478466275030226e-12,
11691
- 0.13588013010892486e-14, -3488903933999489e-37,
11692
- ];
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
+
11693
11854
  /**
11694
- * Polynomial coefficients for a denominator of erfInvImp
11695
- * calculation for erf^-1(z) in the interval [0.75, 1] with x greater than 44.
11855
+ * Available languages in an online osu! beatmap.
11696
11856
  */
11697
- ErrorFunction.ervInvImpGd = [
11698
- 1, 0.08457462340018994, 0.002820929847262647, 0.4682929219408942e-4,
11699
- 0.3999688121938621e-6, 0.1618092908879045e-8, 0.2315586083102596e-11,
11700
- ];
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
+ };
11701
11907
 
11702
11908
  /**
11703
- * Continuous Univariate Normal distribution, also known as Gaussian distribution.
11704
- *
11705
- * For details about this distribution, see {@link http://en.wikipedia.org/wiki/Normal_distribution Wikipedia - Normal distribution}.
11706
- *
11707
- * This class shares the same implementation as {@link https://numerics.mathdotnet.com/ Math.NET Numerics}.
11909
+ * The base of API request builders.
11708
11910
  */
11709
- class NormalDistribution {
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
+ }
11710
11928
  /**
11711
- * Computes the cumulative distribution function (CDF) of the distribution at x, i.e. P(X ≤ x).
11712
- *
11713
- * @param mean The mean (μ) of the normal distribution.
11714
- * @param stdDev The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
11715
- * @param x The location at which to compute the cumulative distribution function.
11716
- * @returns The cumulative distribution at {@link x}.
11929
+ * The base URL of this builder.
11717
11930
  */
11718
- static cdf(mean, stdDev, x) {
11719
- if (stdDev < 0) {
11720
- throw new RangeError("Invalid parametrization for the distribution.");
11721
- }
11722
- if (mean === x && stdDev === 0) {
11723
- return 0;
11724
- }
11725
- return 0.5 * ErrorFunction.erfc((mean - x) / (stdDev * Math.SQRT2));
11931
+ get baseURL() {
11932
+ return this.host + this.endpoint;
11726
11933
  }
11727
11934
  /**
11728
- * Computes the probability density of the distribution (PDF) at x, i.e. ∂P(X ≤ x)/∂x.
11729
- *
11730
- * In MATLAB, this is known as `normpdf`.
11935
+ * Sets the API endpoint.
11731
11936
  *
11732
- * @param mean The mean (μ) of the normal distribution.
11733
- * @param stdDev The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
11734
- * @param x The location at which to compute the density.
11735
- * @returns The density at {@link x}.
11937
+ * @param endpoint The endpoint to set.
11736
11938
  */
11737
- static pdf(mean, stdDev, x) {
11738
- if (stdDev < 0) {
11739
- throw new RangeError("Invalid parametrization for the distribution.");
11740
- }
11741
- const d = (x - mean) / stdDev;
11742
- return Math.exp(-0.5 * d * d) / (stdDev * Math.sqrt(2 * Math.PI));
11939
+ setEndpoint(endpoint) {
11940
+ this.endpoint = endpoint;
11941
+ return this;
11743
11942
  }
11744
11943
  /**
11745
- * Computes the inverse of the cumulative distribution function (InvCDF) for the distribution
11746
- * at the given probability. This is also known as the quantile or percent point function.
11944
+ * Sets if this builder includes the API key in the request URL.
11747
11945
  *
11748
- * @param mean The mean (μ) of the normal distribution.
11749
- * @param stdDev The standard deviation (σ) of the normal distribution. Range: σ ≥ 0.
11750
- * @param p The location at which to compute the inverse cumulative density.
11751
- * @returns The inverse cumulative density at `p`.
11946
+ * @param requireAPIkey Whether or not to include the API key in the request URL.
11752
11947
  */
11753
- static invCDF(mean, stdDev, p) {
11754
- if (stdDev < 0) {
11755
- throw new RangeError("Invalid parametrization for the distribution.");
11756
- }
11757
- return mean - stdDev * Math.SQRT2 * ErrorFunction.erfcInv(2 * p);
11948
+ setRequireAPIkey(requireAPIkey) {
11949
+ this.requiresAPIkey = requireAPIkey;
11950
+ return this;
11758
11951
  }
11759
- }
11760
-
11761
- /**
11762
- * Approximation of the {@link https://en.wikipedia.org/wiki/Poisson_binomial_distribution Poisson binomial distribution}, which can be
11763
- * updated iteratively.
11764
- *
11765
- * For the approximation method, see "Refined Normal Approximation (RNA)" from:
11766
- *
11767
- * {@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}.
11768
- *
11769
- * This has been verified against a reference implementation provided by the authors in the R package "poibin",
11770
- * which can be viewed {@link https://rdrr.io/cran/poibin/man/poibin-package.html here}.
11771
- */
11772
- class IterativePoissonBinomial {
11773
- constructor() {
11774
- this.mu = 0;
11775
- this.var = 0;
11776
- this.gamma = 0;
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;
11777
11967
  }
11778
11968
  /**
11779
- * Adds a new trial with the provided probability of success to the distribution.
11969
+ * Sends a request to the API using built parameters.
11780
11970
  *
11781
- * @param p The probability of success for the new trial.
11971
+ * If the request fails, it will be redone 5 times.
11782
11972
  */
11783
- addProbability(p) {
11784
- this.mu += p;
11785
- this.var += p * (1 - p);
11786
- this.gamma += p * (1 - p) * (1 - 2 * p);
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
+ });
11787
12000
  }
11788
12001
  /**
11789
- * Adds multiple trials with the same probability of success to the distribution.
12002
+ * Adds a parameter to the builder.
11790
12003
  *
11791
- * @param p The probability of success for the new trials.
11792
- * @param count The number of trials to add.
12004
+ * @param param The parameter to add.
12005
+ * @param value The value to add for the parameter.
11793
12006
  */
11794
- addBinnedProbabilities(p, count) {
11795
- this.mu += p * count;
11796
- this.var += p * (1 - p) * count;
11797
- this.gamma += p * (1 - p) * (1 - 2 * p) * count;
12007
+ addParameter(param, value) {
12008
+ this.params.set(param, value.toString());
12009
+ return this;
11798
12010
  }
11799
12011
  /**
11800
- * Computes the value of the cumulative distribution function for this distribution.
12012
+ * Removes a parameter from the builder.
11801
12013
  *
11802
- * @param count The argument of the CDF to sample the distribution for. In the discrete case (when it is a whole number),
11803
- * this corresponds to the number of successful Bernoulli trials to query the CDF for.
11804
- * @returns The value of CDF at {@link count}. In the discrete case, this corresponds to the probability that at most
11805
- * {@link count} Bernoulli trials ended in a success.
11806
- */
11807
- cdf(count) {
11808
- if (this.var === 0) {
11809
- return this.mu <= count ? 1 : 0;
11810
- }
11811
- const sigma = Math.sqrt(this.var);
11812
- const v = this.gamma / (6 * Math.pow(sigma, 3));
11813
- const k = (count + 0.5 - this.mu) / sigma;
11814
- const result = NormalDistribution.cdf(0, 1, k) +
11815
- v * (1 - k * k) * NormalDistribution.pdf(0, 1, k);
11816
- return MathUtils.clamp(result, 0, 1);
11817
- }
11818
- /**
11819
- * Resets the distribution to an empty state.
12014
+ * @param param The parameter to remove.
11820
12015
  */
11821
- reset() {
11822
- this.mu = 0;
11823
- this.var = 0;
11824
- this.gamma = 0;
12016
+ removeParameter(param) {
12017
+ this.params.delete(param);
12018
+ return this;
11825
12019
  }
11826
12020
  }
11827
12021
 
11828
12022
  /**
11829
- * Ranking status of a beatmap.
12023
+ * An API request builder for osu!droid.
11830
12024
  */
11831
- exports.RankedStatus = void 0;
11832
- (function (RankedStatus) {
11833
- RankedStatus[RankedStatus["graveyard"] = -2] = "graveyard";
11834
- RankedStatus[RankedStatus["wip"] = -1] = "wip";
11835
- RankedStatus[RankedStatus["pending"] = 0] = "pending";
11836
- RankedStatus[RankedStatus["ranked"] = 1] = "ranked";
11837
- RankedStatus[RankedStatus["approved"] = 2] = "approved";
11838
- RankedStatus[RankedStatus["qualified"] = 3] = "qualified";
11839
- RankedStatus[RankedStatus["loved"] = 4] = "loved";
11840
- })(exports.RankedStatus || (exports.RankedStatus = {}));
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 = "";
11841
12056
 
11842
12057
  /**
11843
12058
  * An API request builder for osu!standard.
@@ -12250,96 +12465,107 @@ class MapInfo {
12250
12465
  }
12251
12466
 
12252
12467
  /**
12253
- * Represents the "old" `ModNightCore`.
12254
- *
12255
- * This `Mod` is used solely for difficulty calculation of replays with version 3 or older. The reason behind this is a
12256
- * bug that was patched in replay version 4, where all audio that did not have 44100Hz frequency would slow down or
12257
- * speed up depending on the frequency of the audio.
12258
- *
12259
- * The equation for the playback rate with respect to the audio frequency (in Hz) was:
12260
- *
12261
- * ```
12262
- * playback_rate = 44100 * 1.5 / audio_frequency
12263
- * ```
12264
- *
12265
- * For example, if the audio's frequency is 48000Hz, the audio would play at `44100 * 1.5 / 48000 = 1.378125` playback
12266
- * rate.
12267
- *
12268
- * This `Mod` assumes that the audio frequency is 48000Hz and applies the same equation to calculate the playback rate.
12269
- * The frequency was chosen after sampling many audio files that were affected by this bug, and it seemed that 48000Hz
12270
- * was the most common frequency used in those files.
12271
- *
12272
- * Realistically, it is possible to obtain the audio frequency in the game during gameplay loading (and therefore would
12273
- * result in the correct playback rate), but this would require additional work and the current solution is deemed
12274
- * sufficient for the purpose it serves.
12275
- */
12276
- class ModOldNightCore extends ModNightCore {
12277
- constructor() {
12278
- super();
12279
- this.trackRateMultiplier.value = (44.1 * 1.5) / 48;
12280
- }
12281
- get droidScoreMultiplier() {
12282
- return 1.12;
12283
- }
12284
- }
12285
-
12286
- /**
12287
- * Approximation of the {@link https://en.wikipedia.org/wiki/Poisson_binomial_distribution Poisson binomial distribution}.
12288
- *
12289
- * For the approximation method, see "Refined Normal Approximation (RNA)" from:
12290
- *
12291
- * {@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}.
12292
- *
12293
- * This has been verified against a reference implementation provided by the authors in the R package "poibin",
12294
- * which can be viewed {@link https://rdrr.io/cran/poibin/man/poibin-package.html here}.
12468
+ * An accuracy calculator that calculates accuracy based on given parameters.
12295
12469
  */
12296
- class PoissonBinomial {
12470
+ class Accuracy {
12297
12471
  /**
12298
- * Creates a new Poisson binomial distribution based on N trials with the provided list or bins of
12299
- * difficulties, skill, and method for getting the miss probabilities.
12472
+ * Calculates accuracy based on given parameters.
12300
12473
  *
12301
- * @param difficulties The list or bins of difficulties.
12302
- * @param skill The skill level to get the miss probabilities with.
12303
- * @param hitProbability The method for converting difficulties and skill into miss probabilities.
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.
12304
12479
  */
12305
- constructor(difficulties, skill, hitProbability) {
12306
- this.mu = 0;
12307
- let variance = 0;
12308
- let gamma = 0;
12309
- for (const d of difficulties) {
12310
- if (d instanceof Bin) {
12311
- const p = 1 - hitProbability(skill, d.difficulty);
12312
- this.mu += p * d.noteCount;
12313
- variance += p * (1 - p) * d.noteCount;
12314
- gamma += p * (1 - p) * (1 - 2 * p) * d.noteCount;
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);
12315
12493
  }
12316
- else {
12317
- const p = 1 - hitProbability(skill, d);
12318
- this.mu += p;
12319
- variance += p * (1 - p);
12320
- gamma += p * (1 - p) * (1 - 2 * p);
12494
+ hitcount = n300 + this.n100 + this.n50 + this.nmiss;
12495
+ if (hitcount > nobjects) {
12496
+ n300 -= Math.min(n300, hitcount - nobjects);
12321
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;
12322
12537
  }
12323
- this.sigma = Math.sqrt(variance);
12324
- this.v = gamma / (6 * Math.pow(this.sigma, 3));
12325
12538
  }
12326
12539
  /**
12327
- * Computes the value of the cumulative distribution function for this distribution.
12540
+ * Calculates the accuracy value (0.0 - 1.0).
12328
12541
  *
12329
- * @param count The argument of the CDF to sample the distribution for. In the discrete case (when it is a whole number),
12330
- * this corresponds to the number of successful Bernoulli trials to query the CDF for.
12331
- * @returns The value of CDF at {@link count}. In the discrete case, this corresponds to the probability that at most
12332
- * {@link count} Bernoulli trials ended in a success.
12542
+ * @param nobjects The amount of objects in the beatmap. If `n300` was not specified in the constructor, this is required.
12333
12543
  */
12334
- cdf(count) {
12335
- if (this.sigma === 0) {
12336
- return 1;
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;
12337
12551
  }
12338
- const k = (count + 0.5 - this.mu) / this.sigma;
12339
- // See equation (14) of the cited paper.
12340
- const result = NormalDistribution.cdf(0, 1, k) +
12341
- this.v * (1 - k * k) * NormalDistribution.pdf(0, 1, k);
12342
- return MathUtils.clamp(result, 0, 1);
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);
12343
12569
  }
12344
12570
  }
12345
12571
 
@@ -12375,6 +12601,7 @@ exports.CommandTimelineGroup = CommandTimelineGroup;
12375
12601
  exports.CommandTrigger = CommandTrigger;
12376
12602
  exports.ControlPointManager = ControlPointManager;
12377
12603
  exports.DecimalModSetting = DecimalModSetting;
12604
+ exports.DifficultyAdjustModSetting = DifficultyAdjustModSetting;
12378
12605
  exports.DifficultyControlPoint = DifficultyControlPoint;
12379
12606
  exports.DifficultyControlPointManager = DifficultyControlPointManager;
12380
12607
  exports.DroidAPIRequestBuilder = DroidAPIRequestBuilder;
@@ -12478,6 +12705,7 @@ exports.StoryboardSprite = StoryboardSprite;
12478
12705
  exports.TimedHitSampleInfo = TimedHitSampleInfo;
12479
12706
  exports.TimingControlPoint = TimingControlPoint;
12480
12707
  exports.TimingControlPointManager = TimingControlPointManager;
12708
+ exports.UnadjustedOsuHitWindow = UnadjustedOsuHitWindow;
12481
12709
  exports.Utils = Utils;
12482
12710
  exports.Vector2 = Vector2;
12483
12711
  exports.Vector4 = Vector4;