@rian8337/osu-rebalance-difficulty-calculator 2.0.0-alpha.28 → 2.0.0-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,6 +4,32 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var osuBase = require('@rian8337/osu-base');
6
6
 
7
+ /**
8
+ * An evaluator for calculating aim skill.
9
+ *
10
+ * This class should be considered an "evaluating" class and not persisted.
11
+ */
12
+ class AimEvaluator {
13
+ static wideAngleMultiplier = 1.5;
14
+ static acuteAngleMultiplier = 2;
15
+ static sliderMultiplier = 1.5;
16
+ static velocityChangeMultiplier = 0.75;
17
+ /**
18
+ * Calculates the bonus of wide angles.
19
+ */
20
+ static calculateWideAngleBonus(angle) {
21
+ return Math.pow(Math.sin((3 / 4) *
22
+ (Math.min((5 / 6) * Math.PI, Math.max(Math.PI / 6, angle)) -
23
+ Math.PI / 6)), 2);
24
+ }
25
+ /**
26
+ * Calculates the bonus of acute angles.
27
+ */
28
+ static calculateAcuteAngleBonus(angle) {
29
+ return 1 - this.calculateWideAngleBonus(angle);
30
+ }
31
+ }
32
+
7
33
  /**
8
34
  * Represents an osu!standard hit object with difficulty calculation values.
9
35
  */
@@ -12,6 +38,20 @@ class DifficultyHitObject {
12
38
  * The underlying hitobject.
13
39
  */
14
40
  object;
41
+ /**
42
+ * The index of this hitobject in the list of all hitobjects.
43
+ *
44
+ * This is one less than the actual index of the hitobject in the beatmap.
45
+ */
46
+ index = 0;
47
+ /**
48
+ * The preempt time of the hitobject.
49
+ */
50
+ timePreempt = 600;
51
+ /**
52
+ * The fade in time of the hitobject.
53
+ */
54
+ timeFadeIn = 450;
15
55
  /**
16
56
  * The aim strain generated by the hitobject if sliders are considered.
17
57
  */
@@ -103,7 +143,7 @@ class DifficultyHitObject {
103
143
  /**
104
144
  * The note density of the hitobject.
105
145
  */
106
- noteDensity = 0;
146
+ noteDensity = 1;
107
147
  /**
108
148
  * The overlapping factor of the hitobject.
109
149
  *
@@ -114,11 +154,64 @@ class DifficultyHitObject {
114
154
  * Adjusted velocity of the hitobject, taking speed multiplier into account.
115
155
  */
116
156
  velocity = 0;
157
+ hitObjects;
117
158
  /**
118
159
  * @param object The underlying hitobject.
160
+ * @param hitObjects All difficulty hitobjects in the processed beatmap.
119
161
  */
120
- constructor(object) {
162
+ constructor(object, hitObjects) {
121
163
  this.object = object;
164
+ this.hitObjects = hitObjects;
165
+ }
166
+ /**
167
+ * Gets the difficulty hitobject at a specific index with respect to the current
168
+ * difficulty hitobject's index.
169
+ *
170
+ * Will return `null` if the index is out of range.
171
+ *
172
+ * @param backwardsIndex The index to move backwards for.
173
+ * @returns The difficulty hitobject at the index with respect to the current
174
+ * difficulty hitobject's index, `null` if the index is out of range.
175
+ */
176
+ previous(backwardsIndex) {
177
+ return this.hitObjects[this.index - backwardsIndex] ?? null;
178
+ }
179
+ /**
180
+ * Gets the difficulty hitobject at a specific index with respect to the current
181
+ * difficulty hitobject's index.
182
+ *
183
+ * Will return `null` if the index is out of range.
184
+ *
185
+ * @param forwardsIndex The index to move forwards for.
186
+ * @returns The difficulty hitobject at the index with respect to the current
187
+ * difficulty hitobject's index, `null` if the index is out of range.
188
+ */
189
+ next(forwardsIndex) {
190
+ return this.hitObjects[this.index + forwardsIndex + 2] ?? null;
191
+ }
192
+ /**
193
+ * Calculates the opacity of the hitobject at a given time.
194
+ *
195
+ * @param time The time to calculate the hitobject's opacity at.
196
+ * @param isHidden Whether Hidden mod is used.
197
+ * @returns The opacity of the hitobject at the given time.
198
+ */
199
+ opacityAt(time, isHidden) {
200
+ if (time > this.object.startTime) {
201
+ // Consider a hitobject as being invisible when its start time is passed.
202
+ // In reality the hitobject will be visible beyond its start time up until its hittable window has passed,
203
+ // but this is an approximation and such a case is unlikely to be hit where this function is used.
204
+ return 0;
205
+ }
206
+ const fadeInStartTime = this.object.startTime - this.timePreempt;
207
+ const fadeInDuration = this.timeFadeIn;
208
+ if (isHidden) {
209
+ const fadeOutStartTime = fadeInStartTime + fadeInDuration;
210
+ const fadeOutDuration = this.timePreempt * osuBase.ModHidden.fadeOutDurationMultiplier;
211
+ return Math.min(osuBase.MathUtils.clamp((time - fadeInStartTime) / fadeInDuration, 0, 1), 1 -
212
+ osuBase.MathUtils.clamp((time - fadeOutStartTime) / fadeOutDuration, 0, 1));
213
+ }
214
+ return osuBase.MathUtils.clamp((time - fadeInStartTime) / fadeInDuration, 0, 1);
122
215
  }
123
216
  }
124
217
 
@@ -157,8 +250,21 @@ class DifficultyHitObjectCreator {
157
250
  const scalingFactor = this.getScalingFactor(params.objects[0].radius);
158
251
  const difficultyObjects = [];
159
252
  for (let i = 0; i < params.objects.length; ++i) {
160
- const object = new DifficultyHitObject(params.objects[i]);
253
+ const object = new DifficultyHitObject(params.objects[i], difficultyObjects);
254
+ object.index = difficultyObjects.length - 1;
161
255
  object.object.scale = scale;
256
+ object.timePreempt = params.preempt;
257
+ // Preempt time can go below 450ms. Normally, this is achieved via the DT mod or a
258
+ // custom speed multiplier which uniformly speeds up all animations game wide regardless of AR.
259
+ //
260
+ // This uniform speedup is hard to match 1:1, however we can at least make AR>10 (via mods)
261
+ // feel good by extending the upper linear function above.
262
+ //
263
+ // Note that this doesn't exactly match the AR>10 visuals as they're classically known, but it feels good.
264
+ // This adjustment is necessary for AR>10, otherwise timePreempt can become smaller
265
+ // leading to hitcircles not fully fading in.
266
+ object.timeFadeIn =
267
+ 400 * Math.min(1, object.timePreempt / osuBase.MapStats.arToMS(10));
162
268
  if (object.object instanceof osuBase.Slider) {
163
269
  object.velocity =
164
270
  object.object.velocity * params.speedMultiplier;
@@ -182,6 +288,11 @@ class DifficultyHitObjectCreator {
182
288
  params.speedMultiplier;
183
289
  // Cap to 25ms to prevent difficulty calculation breaking from simultaneous objects.
184
290
  object.strainTime = Math.max(this.minDeltaTime, object.deltaTime);
291
+ if (object.object instanceof osuBase.Spinner ||
292
+ lastObject.object instanceof osuBase.Spinner) {
293
+ difficultyObjects.push(object);
294
+ continue;
295
+ }
185
296
  const visibleObjects = params.objects
186
297
  .filter((o) => o.startTime / params.speedMultiplier >=
187
298
  object.startTime &&
@@ -189,12 +300,6 @@ class DifficultyHitObjectCreator {
189
300
  object.endTime + params.preempt)
190
301
  // The current object will be included, so we need to exclude it.
191
302
  .slice(1);
192
- object.noteDensity = 1;
193
- if (object.object instanceof osuBase.Spinner ||
194
- lastObject.object instanceof osuBase.Spinner) {
195
- difficultyObjects.push(object);
196
- continue;
197
- }
198
303
  for (const hitObject of visibleObjects) {
199
304
  // Calculate delta time assuming the current object is a circle.
200
305
  let deltaTime = Math.abs(hitObject.startTime / params.speedMultiplier -
@@ -284,9 +389,7 @@ class DifficultyHitObjectCreator {
284
389
  if (this.mode === osuBase.modes.droid) {
285
390
  slider.tail.startTime += osuBase.Slider.legacyLastTickOffset;
286
391
  slider.tail.endTime += osuBase.Slider.legacyLastTickOffset;
287
- slider.nestedHitObjects.sort((a, b) => {
288
- return a.startTime - b.startTime;
289
- });
392
+ slider.nestedHitObjects.sort((a, b) => a.startTime - b.startTime);
290
393
  // Temporary lazy end position until a real result can be derived.
291
394
  slider.lazyEndPosition = slider.stackedPosition;
292
395
  // Stop here if the slider has too short duration due to float number limitation.
@@ -398,178 +501,54 @@ class DifficultyHitObjectCreator {
398
501
  }
399
502
 
400
503
  /**
401
- * A bare minimal abstract skill for fully custom skill implementations.
402
- */
403
- class Skill {
404
- /**
405
- * The hitobjects that were processed previously. They can affect the strain values of the following objects.
406
- *
407
- * The latest hitobject is at index 0.
408
- */
409
- previous = [];
410
- /**
411
- * Number of previous hitobjects to keep inside the `previous` array.
412
- */
413
- historyLength = 2;
414
- /**
415
- * The mods that this skill processes.
416
- */
417
- mods;
418
- constructor(mods) {
419
- this.mods = mods;
420
- }
421
- processInternal(current) {
422
- while (this.previous.length > this.historyLength) {
423
- this.previous.pop();
424
- }
425
- this.process(current);
426
- this.previous.unshift(current);
427
- }
428
- }
429
-
430
- /**
431
- * Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
432
- * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
504
+ * An evaluator for calculating osu!droid Aim skill.
433
505
  */
434
- class StrainSkill extends Skill {
435
- /**
436
- * The strain of currently calculated hitobject.
437
- */
438
- currentStrain = 0;
439
- /**
440
- * The current section's strain peak.
441
- */
442
- currentSectionPeak = 0;
443
- /**
444
- * Strain peaks are stored here.
445
- */
446
- strainPeaks = [];
447
- sectionLength = 400;
448
- currentSectionEnd = 0;
449
- process(current) {
450
- // The first object doesn't generate a strain, so we begin with an incremented section end
451
- if (this.previous.length === 0) {
452
- this.currentSectionEnd =
453
- Math.ceil(current.startTime / this.sectionLength) *
454
- this.sectionLength;
455
- }
456
- while (current.startTime > this.currentSectionEnd) {
457
- this.saveCurrentPeak();
458
- this.startNewSectionFrom(this.currentSectionEnd);
459
- this.currentSectionEnd += this.sectionLength;
460
- }
461
- this.currentStrain = this.strainValueAt(current);
462
- this.saveToHitObject(current);
463
- this.currentSectionPeak = Math.max(this.currentStrain, this.currentSectionPeak);
464
- }
465
- /**
466
- * Saves the current peak strain level to the list of strain peaks, which will be used to calculate an overall difficulty.
467
- */
468
- saveCurrentPeak() {
469
- this.strainPeaks.push(this.currentSectionPeak);
470
- }
471
- /**
472
- * Sets the initial strain level for a new section.
473
- *
474
- * @param offset The beginning of the new section in milliseconds, adjusted by speed multiplier.
475
- */
476
- startNewSectionFrom(offset) {
477
- // The maximum strain of the new section is not zero by default, strain decays as usual regardless of section boundaries.
478
- // This means we need to capture the strain level at the beginning of the new section, and use that as the initial peak level.
479
- this.currentSectionPeak =
480
- this.currentStrain *
481
- this.strainDecay(offset - this.previous[0].startTime);
482
- }
483
- /**
484
- * Calculates strain decay for a specified time frame.
485
- *
486
- * @param ms The time frame to calculate.
487
- */
488
- strainDecay(ms) {
489
- return Math.pow(this.strainDecayBase, ms / 1000);
490
- }
491
- }
492
-
493
- /**
494
- * Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
495
- * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
496
- */
497
- class DroidSkill extends StrainSkill {
498
- difficultyValue() {
499
- const sortedStrains = this.strainPeaks
500
- .slice()
501
- .sort((a, b) => {
502
- return b - a;
503
- });
504
- // We are reducing the highest strains first to account for extreme difficulty spikes.
505
- for (let i = 0; i < Math.min(sortedStrains.length, this.reducedSectionCount); ++i) {
506
- const scale = Math.log10(osuBase.Interpolation.lerp(1, 10, osuBase.MathUtils.clamp(i / this.reducedSectionCount, 0, 1)));
507
- sortedStrains[i] *= osuBase.Interpolation.lerp(this.reducedSectionBaseline, 1, scale);
508
- }
509
- // Math here preserves the property that two notes of equal difficulty x, we have their summed difficulty = x * starsPerDouble.
510
- // This also applies to two sets of notes with equal difficulty.
511
- return Math.pow(sortedStrains.reduce((a, v) => {
512
- if (v === 0) {
513
- return a;
514
- }
515
- return a + Math.pow(v, 1 / Math.log2(this.starsPerDouble));
516
- }, 0), Math.log2(this.starsPerDouble));
517
- }
518
- }
519
-
520
- /**
521
- * Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
522
- */
523
- class DroidAim extends DroidSkill {
524
- skillMultiplier = 23.25;
525
- strainDecayBase = 0.15;
526
- reducedSectionCount = 10;
527
- reducedSectionBaseline = 0.75;
528
- starsPerDouble = 1.05;
506
+ class DroidAimEvaluator extends AimEvaluator {
529
507
  /**
530
508
  * Spacing threshold for a single hitobject spacing.
531
509
  */
532
- SINGLE_SPACING_THRESHOLD = 175;
510
+ static SINGLE_SPACING_THRESHOLD = 175;
533
511
  // ~200 1/2 BPM jumps
534
- minSpeedBonus = 150;
535
- wideAngleMultiplier = 1.5;
536
- acuteAngleMultiplier = 2;
537
- sliderMultiplier = 1.5;
538
- velocityChangeMultiplier = 0.75;
539
- withSliders;
540
- constructor(mods, withSliders) {
541
- super(mods);
542
- this.withSliders = withSliders;
543
- }
512
+ static minSpeedBonus = 150;
544
513
  /**
545
- * @param current The hitobject to calculate.
514
+ * Evaluates the difficulty of aiming the current object, based on:
515
+ *
516
+ * - cursor velocity to the current object,
517
+ * - angle difficulty,
518
+ * - sharp velocity increases,
519
+ * - and slider difficulty.
520
+ *
521
+ * @param current The current object.
522
+ * @param withSliders Whether to take slider difficulty into account.
546
523
  */
547
- strainValueOf(current) {
524
+ static evaluateDifficultyOf(current, withSliders) {
525
+ const last = current.previous(0);
548
526
  if (current.object instanceof osuBase.Spinner ||
549
527
  // Exclude overlapping objects that can be tapped at once.
550
- (osuBase.Precision.almostEqualsNumber(current.deltaTime, 0, 1) &&
551
- (this.previous[0]?.object instanceof osuBase.Slider
552
- ? Math.min(this.previous[0].object.stackedEndPosition.getDistance(current.object.stackedPosition), this.previous[0].object.lazyEndPosition.getDistance(current.object.stackedPosition))
553
- : this.previous[0]?.object.stackedEndPosition.getDistance(current.object.stackedPosition)) <=
528
+ (current.deltaTime < 5 &&
529
+ ((last?.object instanceof osuBase.Slider
530
+ ? Math.min(last.object.stackedEndPosition.getDistance(current.object.stackedPosition), last.object.lazyEndPosition.getDistance(current.object.stackedPosition))
531
+ : last?.object.stackedEndPosition.getDistance(current.object.stackedPosition)) ?? Number.POSITIVE_INFINITY) <=
554
532
  2 * current.object.radius)) {
555
533
  return 0;
556
534
  }
557
- return this.aimStrainOf(current) + this.movementStrainOf(current);
535
+ return (this.aimStrainOf(current, withSliders) +
536
+ this.movementStrainOf(current));
558
537
  }
559
538
  /**
560
539
  * Calculates the aim strain of a hitobject.
561
540
  */
562
- aimStrainOf(current) {
563
- if (this.previous.length <= 1 ||
564
- this.previous[0].object instanceof osuBase.Spinner) {
541
+ static aimStrainOf(current, withSliders) {
542
+ if (current.index <= 1 ||
543
+ current.previous(0)?.object instanceof osuBase.Spinner) {
565
544
  return 0;
566
545
  }
567
- const last = this.previous[0];
568
- const lastLast = this.previous[1];
546
+ const last = current.previous(0);
547
+ const lastLast = current.previous(1);
569
548
  // Calculate the velocity to the current hitobject, which starts with a base distance / time assuming the last object is a hitcircle.
570
549
  let currentVelocity = current.lazyJumpDistance / current.strainTime;
571
550
  // But if the last object is a slider, then we extend the travel velocity through the slider into the current object.
572
- if (last.object instanceof osuBase.Slider && this.withSliders) {
551
+ if (last.object instanceof osuBase.Slider && withSliders) {
573
552
  // Calculate the slider velocity from slider head to slider end.
574
553
  const travelVelocity = last.travelDistance / last.travelTime;
575
554
  // Calculate the movement velocity from slider end to current object.
@@ -581,7 +560,7 @@ class DroidAim extends DroidSkill {
581
560
  }
582
561
  // As above, do the same for the previous hitobject.
583
562
  let prevVelocity = last.lazyJumpDistance / last.strainTime;
584
- if (lastLast.object instanceof osuBase.Slider && this.withSliders) {
563
+ if (lastLast.object instanceof osuBase.Slider && withSliders) {
585
564
  const travelVelocity = lastLast.travelDistance / lastLast.travelTime;
586
565
  const movementVelocity = last.minimumJumpTime !== 0
587
566
  ? last.minimumJumpDistance / last.minimumJumpTime
@@ -670,7 +649,7 @@ class DroidAim extends DroidSkill {
670
649
  strain += Math.max(acuteAngleBonus * this.acuteAngleMultiplier, wideAngleBonus * this.wideAngleMultiplier +
671
650
  velocityChangeBonus * this.velocityChangeMultiplier);
672
651
  // Add in additional slider velocity bonus.
673
- if (this.withSliders) {
652
+ if (withSliders) {
674
653
  strain += sliderBonus * this.sliderMultiplier;
675
654
  }
676
655
  return strain;
@@ -678,27 +657,154 @@ class DroidAim extends DroidSkill {
678
657
  /**
679
658
  * Calculates the movement strain of a hitobject.
680
659
  */
681
- movementStrainOf(current) {
660
+ static movementStrainOf(current) {
682
661
  let speedBonus = 1;
683
662
  if (current.strainTime < this.minSpeedBonus) {
684
663
  speedBonus +=
685
664
  0.75 *
686
665
  Math.pow((this.minSpeedBonus - current.strainTime) / 45, 2);
687
666
  }
688
- const travelDistance = this.previous[0]?.travelDistance ?? 0;
667
+ const travelDistance = current.previous(0)?.travelDistance ?? 0;
689
668
  const distance = Math.min(this.SINGLE_SPACING_THRESHOLD, travelDistance + current.minimumJumpDistance);
690
669
  return ((50 *
691
670
  speedBonus *
692
671
  Math.pow(distance / this.SINGLE_SPACING_THRESHOLD, 5)) /
693
672
  current.strainTime);
694
673
  }
674
+ }
675
+
676
+ /**
677
+ * A bare minimal abstract skill for fully custom skill implementations.
678
+ */
679
+ class Skill {
680
+ /**
681
+ * The mods that this skill processes.
682
+ */
683
+ mods;
684
+ constructor(mods) {
685
+ this.mods = mods;
686
+ }
687
+ }
688
+
689
+ /**
690
+ * Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
691
+ * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
692
+ */
693
+ class StrainSkill extends Skill {
694
+ /**
695
+ * The strain of currently calculated hitobject.
696
+ */
697
+ currentStrain = 0;
698
+ /**
699
+ * The current section's strain peak.
700
+ */
701
+ currentSectionPeak = 0;
702
+ /**
703
+ * Strain peaks are stored here.
704
+ */
705
+ strainPeaks = [];
706
+ sectionLength = 400;
707
+ currentSectionEnd = 0;
708
+ isFirstObject = true;
709
+ /**
710
+ * Calculates the strain value of a hitobject and stores the value in it. This value is affected by previously processed objects.
711
+ *
712
+ * @param current The hitobject to process.
713
+ */
714
+ process(current) {
715
+ // The first object doesn't generate a strain, so we begin with an incremented section end
716
+ if (this.isFirstObject) {
717
+ this.currentSectionEnd =
718
+ Math.ceil(current.startTime / this.sectionLength) *
719
+ this.sectionLength;
720
+ this.isFirstObject = false;
721
+ }
722
+ while (current.startTime > this.currentSectionEnd) {
723
+ this.saveCurrentPeak();
724
+ this.startNewSectionFrom(this.currentSectionEnd, current);
725
+ this.currentSectionEnd += this.sectionLength;
726
+ }
727
+ // Ignore the first hitobject.
728
+ this.currentStrain = this.strainValueAt(current);
729
+ this.saveToHitObject(current);
730
+ this.currentSectionPeak = Math.max(this.currentStrain, this.currentSectionPeak);
731
+ }
732
+ /**
733
+ * Saves the current peak strain level to the list of strain peaks, which will be used to calculate an overall difficulty.
734
+ */
735
+ saveCurrentPeak() {
736
+ this.strainPeaks.push(this.currentSectionPeak);
737
+ }
738
+ /**
739
+ * Calculates strain decay for a specified time frame.
740
+ *
741
+ * @param ms The time frame to calculate.
742
+ */
743
+ strainDecay(ms) {
744
+ return Math.pow(this.strainDecayBase, ms / 1000);
745
+ }
746
+ /**
747
+ * Sets the initial strain level for a new section.
748
+ *
749
+ * @param offset The beginning of the new section in milliseconds, adjusted by speed multiplier.
750
+ * @param current The current hitobject.
751
+ */
752
+ startNewSectionFrom(offset, current) {
753
+ // The maximum strain of the new section is not zero by default, strain decays as usual regardless of section boundaries.
754
+ // This means we need to capture the strain level at the beginning of the new section, and use that as the initial peak level.
755
+ this.currentSectionPeak =
756
+ this.currentStrain *
757
+ this.strainDecay(offset - current.previous(0).startTime);
758
+ }
759
+ }
760
+
761
+ /**
762
+ * Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
763
+ * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
764
+ */
765
+ class DroidSkill extends StrainSkill {
766
+ difficultyValue() {
767
+ const sortedStrains = this.strainPeaks
768
+ .slice()
769
+ .sort((a, b) => b - a);
770
+ // We are reducing the highest strains first to account for extreme difficulty spikes.
771
+ for (let i = 0; i < Math.min(sortedStrains.length, this.reducedSectionCount); ++i) {
772
+ const scale = Math.log10(osuBase.Interpolation.lerp(1, 10, osuBase.MathUtils.clamp(i / this.reducedSectionCount, 0, 1)));
773
+ sortedStrains[i] *= osuBase.Interpolation.lerp(this.reducedSectionBaseline, 1, scale);
774
+ }
775
+ // Math here preserves the property that two notes of equal difficulty x, we have their summed difficulty = x * starsPerDouble.
776
+ // This also applies to two sets of notes with equal difficulty.
777
+ return Math.pow(sortedStrains.reduce((a, v) => {
778
+ if (v <= 0) {
779
+ return a;
780
+ }
781
+ return a + Math.pow(v, 1 / Math.log2(this.starsPerDouble));
782
+ }, 0), Math.log2(this.starsPerDouble));
783
+ }
784
+ }
785
+
786
+ /**
787
+ * Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
788
+ */
789
+ class DroidAim extends DroidSkill {
790
+ skillMultiplier = 23.25;
791
+ strainDecayBase = 0.15;
792
+ reducedSectionCount = 10;
793
+ reducedSectionBaseline = 0.75;
794
+ starsPerDouble = 1.05;
795
+ withSliders;
796
+ constructor(mods, withSliders) {
797
+ super(mods);
798
+ this.withSliders = withSliders;
799
+ }
695
800
  /**
696
801
  * @param current The hitobject to calculate.
697
802
  */
698
803
  strainValueAt(current) {
699
804
  this.currentStrain *= this.strainDecay(current.deltaTime);
700
805
  this.currentStrain +=
701
- this.strainValueOf(current) * this.skillMultiplier;
806
+ DroidAimEvaluator.evaluateDifficultyOf(current, this.withSliders) *
807
+ this.skillMultiplier;
702
808
  return this.currentStrain;
703
809
  }
704
810
  /**
@@ -712,39 +818,40 @@ class DroidAim extends DroidSkill {
712
818
  current.aimStrainWithoutSliders = this.currentStrain;
713
819
  }
714
820
  }
715
- /**
716
- * Calculates the bonus of wide angles.
717
- */
718
- calculateWideAngleBonus(angle) {
719
- return Math.pow(Math.sin((3 / 4) *
720
- (Math.min((5 / 6) * Math.PI, Math.max(Math.PI / 6, angle)) -
721
- Math.PI / 6)), 2);
722
- }
723
- /**
724
- * Calculates the bonus of acute angles.
725
- */
726
- calculateAcuteAngleBonus(angle) {
727
- return 1 - this.calculateWideAngleBonus(angle);
728
- }
729
821
  }
730
822
 
731
823
  /**
732
- * Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
824
+ * An evaluator for calculating flashlight skill.
825
+ *
826
+ * This class should be considered an "evaluating" class and not persisted.
733
827
  */
734
- class DroidFlashlight extends DroidSkill {
735
- historyLength = 10;
736
- skillMultiplier = 0.15;
737
- strainDecayBase = 0.15;
738
- reducedSectionCount = 10;
739
- reducedSectionBaseline = 0.75;
740
- starsPerDouble = 1.05;
741
- strainValueOf(current) {
828
+ class FlashlightEvaluator {
829
+ static maxOpacityBonus = 0.4;
830
+ static hiddenBonus = 0.2;
831
+ }
832
+
833
+ /**
834
+ * An evaluator for calculating osu!droid Flashlight skill.
835
+ */
836
+ class DroidFlashlightEvaluator extends FlashlightEvaluator {
837
+ /**
838
+ * Evaluates the difficulty of memorizing and hitting the current object, based on:
839
+ *
840
+ * - distance between the previous and the current object,
841
+ * - the visual opacity of the current object,
842
+ * - and whether Hidden mod is enabled.
843
+ *
844
+ * @param current The current object.
845
+ * @param isHiddenMod Whether the Hidden mod is enabled.
846
+ */
847
+ static evaluateDifficultyOf(current, isHiddenMod) {
848
+ const actualLast = current.previous(0);
742
849
  if (current.object instanceof osuBase.Spinner ||
743
850
  // Exclude overlapping objects that can be tapped at once.
744
- (osuBase.Precision.almostEqualsNumber(current.deltaTime, 0, 1) &&
745
- (this.previous[0]?.object instanceof osuBase.Slider
746
- ? Math.min(this.previous[0].object.stackedEndPosition.getDistance(current.object.stackedPosition), this.previous[0].object.lazyEndPosition.getDistance(current.object.stackedPosition))
747
- : this.previous[0]?.object.stackedEndPosition.getDistance(current.object.stackedPosition)) <=
851
+ (current.deltaTime < 5 &&
852
+ ((actualLast?.object instanceof osuBase.Slider
853
+ ? Math.min(actualLast.object.stackedEndPosition.getDistance(current.object.stackedPosition), actualLast.object.lazyEndPosition.getDistance(current.object.stackedPosition))
854
+ : actualLast?.object.stackedEndPosition.getDistance(current.object.stackedPosition)) ?? Number.POSITIVE_INFINITY) <=
748
855
  2 * current.object.radius)) {
749
856
  return 0;
750
857
  }
@@ -753,11 +860,11 @@ class DroidFlashlight extends DroidSkill {
753
860
  let cumulativeStrainTime = 0;
754
861
  let result = 0;
755
862
  let last = current;
756
- for (let i = 0; i < this.previous.length; ++i) {
757
- const currentObject = this.previous[i];
863
+ for (let i = 0; i < Math.min(current.index, 10); ++i) {
864
+ const currentObject = current.previous(i);
758
865
  if (!(currentObject.object instanceof osuBase.Spinner) &&
759
866
  // Exclude overlapping objects that can be tapped at once.
760
- !osuBase.Precision.almostEqualsNumber(currentObject.deltaTime, 0, 1)) {
867
+ currentObject.deltaTime >= 5) {
761
868
  const jumpDistance = current.object.stackedPosition.subtract(currentObject.object.endPosition).length;
762
869
  cumulativeStrainTime += last.strainTime;
763
870
  // We want to nerf objects that can be easily seen within the Flashlight circle radius.
@@ -766,21 +873,46 @@ class DroidFlashlight extends DroidSkill {
766
873
  }
767
874
  // We also want to nerf stacks so that only the first object of the stack is accounted for.
768
875
  const stackNerf = Math.min(1, currentObject.lazyJumpDistance / scalingFactor / 25);
876
+ // Bonus based on how visible the object is.
877
+ const opacityBonus = 1 +
878
+ this.maxOpacityBonus *
879
+ (1.0 -
880
+ current.opacityAt(currentObject.startTime, isHiddenMod));
769
881
  result +=
770
- (stackNerf * scalingFactor * jumpDistance) /
882
+ (stackNerf * opacityBonus * scalingFactor * jumpDistance) /
771
883
  cumulativeStrainTime;
772
884
  }
773
885
  last = currentObject;
774
886
  }
887
+ // Additional bonus for Hidden due to there being no approach circles.
888
+ if (isHiddenMod) {
889
+ result *= 1 + this.hiddenBonus;
890
+ }
775
891
  return Math.pow(smallDistNerf * result, 2);
776
892
  }
893
+ }
894
+
895
+ /**
896
+ * Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
897
+ */
898
+ class DroidFlashlight extends DroidSkill {
899
+ skillMultiplier = 0.1;
900
+ strainDecayBase = 0.15;
901
+ reducedSectionCount = 10;
902
+ reducedSectionBaseline = 0.75;
903
+ starsPerDouble = 1.05;
904
+ isHidden;
905
+ constructor(mods) {
906
+ super(mods);
907
+ this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
908
+ }
777
909
  /**
778
910
  * @param current The hitobject to calculate.
779
911
  */
780
912
  strainValueAt(current) {
781
913
  this.currentStrain *= this.strainDecay(current.deltaTime);
782
914
  this.currentStrain +=
783
- this.strainValueOf(current) * this.skillMultiplier;
915
+ DroidFlashlightEvaluator.evaluateDifficultyOf(current, this.isHidden) * this.skillMultiplier;
784
916
  return this.currentStrain;
785
917
  }
786
918
  saveToHitObject(current) {
@@ -788,6 +920,60 @@ class DroidFlashlight extends DroidSkill {
788
920
  }
789
921
  }
790
922
 
923
+ /**
924
+ * An evaluator for calculating speed or tap skill.
925
+ *
926
+ * This class should be considered an "evaluating" class and not persisted.
927
+ */
928
+ class SpeedEvaluator {
929
+ // ~200 1/4 BPM streams
930
+ static minSpeedBonus = 75;
931
+ }
932
+
933
+ /**
934
+ * An evaluator for calculating osu!droid tap skill.
935
+ */
936
+ class DroidTapEvaluator extends SpeedEvaluator {
937
+ /**
938
+ * Evaluates the difficulty of tapping the current object, based on:
939
+ *
940
+ * - time between pressing the previous and current object,
941
+ * - distance between those objects,
942
+ * - and how easily they can be cheesed.
943
+ *
944
+ * @param current The current object.
945
+ * @param greatWindow The great hit window of the current object.
946
+ * @param considerCheesability Whether to consider cheesability.
947
+ */
948
+ static evaluateDifficultyOf(current, greatWindow, considerCheesability) {
949
+ if (current.object instanceof osuBase.Spinner ||
950
+ // Exclude overlapping objects that can be tapped at once.
951
+ current.deltaTime < 5) {
952
+ return 0;
953
+ }
954
+ const prev = current.previous(0);
955
+ let strainTime = current.strainTime;
956
+ if (considerCheesability) {
957
+ const greatWindowFull = greatWindow * 2;
958
+ // Aim to nerf cheesy rhythms (very fast consecutive doubles with large deltatimes between).
959
+ if (prev &&
960
+ strainTime < greatWindowFull &&
961
+ prev.strainTime > strainTime) {
962
+ strainTime = osuBase.Interpolation.lerp(prev.strainTime, strainTime, strainTime / greatWindowFull);
963
+ }
964
+ // Cap deltatime to the OD 300 hitwindow.
965
+ // 0.58 is derived from making sure 260 BPM 1/4 OD5 streams aren't nerfed harshly, whilst 0.91 limits the effect of the cap.
966
+ strainTime /= osuBase.MathUtils.clamp(strainTime / greatWindowFull / 0.58, 0.91, 1);
967
+ }
968
+ let speedBonus = 1;
969
+ if (strainTime < this.minSpeedBonus) {
970
+ speedBonus +=
971
+ 0.75 * Math.pow((this.minSpeedBonus - strainTime) / 40, 2);
972
+ }
973
+ return speedBonus / strainTime;
974
+ }
975
+ }
976
+
791
977
  /**
792
978
  * Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
793
979
  */
@@ -801,65 +987,25 @@ class DroidTap extends DroidSkill {
801
987
  minSpeedBonus = 75;
802
988
  currentTapStrain = 0;
803
989
  currentOriginalTapStrain = 0;
804
- hitWindow;
990
+ greatWindow;
805
991
  constructor(mods, overallDifficulty) {
806
992
  super(mods);
807
- this.hitWindow = new osuBase.OsuHitWindow(overallDifficulty);
993
+ this.greatWindow = new osuBase.OsuHitWindow(overallDifficulty).hitWindowFor300();
808
994
  }
809
995
  /**
810
996
  * @param current The hitobject to calculate.
811
997
  */
812
- strainValueOf(current) {
813
- if (current.object instanceof osuBase.Spinner ||
814
- // Exclude overlapping objects that can be tapped at once.
815
- osuBase.Precision.almostEqualsNumber(current.deltaTime, 0, 1)) {
816
- return 0;
817
- }
818
- let strainTime = current.strainTime;
819
- const greatWindowFull = this.hitWindow.hitWindowFor300() * 2;
820
- // Aim to nerf cheesy rhythms (very fast consecutive doubles with large deltatimes between).
821
- if (this.previous[0] &&
822
- strainTime < greatWindowFull &&
823
- this.previous[0].strainTime > strainTime) {
824
- strainTime = osuBase.Interpolation.lerp(this.previous[0].strainTime, strainTime, strainTime / greatWindowFull);
825
- }
826
- // Cap deltatime to the OD 300 hitwindow.
827
- // 0.58 is derived from making sure 260 BPM 1/4 OD5 streams aren't nerfed harshly, whilst 0.91 limits the effect of the cap.
828
- strainTime /= osuBase.MathUtils.clamp(strainTime / greatWindowFull / 0.58, 0.91, 1);
829
- let speedBonus = 1;
830
- if (strainTime < this.minSpeedBonus) {
831
- speedBonus +=
832
- 0.75 * Math.pow((this.minSpeedBonus - strainTime) / 40, 2);
833
- }
834
- let originalSpeedBonus = 1;
835
- if (current.strainTime < this.minSpeedBonus) {
836
- originalSpeedBonus +=
837
- 0.75 *
838
- Math.pow((this.minSpeedBonus - current.strainTime) / 40, 2);
839
- }
998
+ strainValueAt(current) {
840
999
  const decay = this.strainDecay(current.deltaTime);
841
1000
  this.currentTapStrain *= decay;
842
1001
  this.currentTapStrain +=
843
- this.tapStrainOf(speedBonus, strainTime) * this.skillMultiplier;
1002
+ DroidTapEvaluator.evaluateDifficultyOf(current, this.greatWindow, true) * this.skillMultiplier;
844
1003
  this.currentOriginalTapStrain *= decay;
845
1004
  this.currentOriginalTapStrain +=
846
- this.tapStrainOf(originalSpeedBonus, current.strainTime) *
847
- this.skillMultiplier;
1005
+ DroidTapEvaluator.evaluateDifficultyOf(current, this.greatWindow, false) * this.skillMultiplier;
848
1006
  this.currentOriginalTapStrain *= current.rhythmMultiplier;
849
1007
  return this.currentTapStrain * current.rhythmMultiplier;
850
1008
  }
851
- /**
852
- * Calculates the tap strain of a hitobject given a specific speed bonus and strain time.
853
- */
854
- tapStrainOf(speedBonus, strainTime) {
855
- return speedBonus / strainTime;
856
- }
857
- /**
858
- * @param current The hitobject to calculate.
859
- */
860
- strainValueAt(current) {
861
- return this.strainValueOf(current);
862
- }
863
1009
  /**
864
1010
  * @param current The hitobject to save to.
865
1011
  */
@@ -969,7 +1115,7 @@ class StarRating {
969
1115
  calculateSkills(...skills) {
970
1116
  this.objects.slice(1).forEach((h, i) => {
971
1117
  skills.forEach((skill) => {
972
- skill.processInternal(h);
1118
+ skill.process(h);
973
1119
  if (i === this.objects.length - 2) {
974
1120
  // Don't forget to save the last strain peak, which would otherwise be ignored.
975
1121
  skill.saveCurrentPeak();
@@ -996,33 +1142,29 @@ class StarRating {
996
1142
  }
997
1143
 
998
1144
  /**
999
- * Represents the skill required to properly follow a beatmap's rhythm.
1145
+ * An evaluator for calculating rhythm skill.
1146
+ *
1147
+ * This class should be considered an "evaluating" class and not persisted.
1000
1148
  */
1001
- class DroidRhythm extends DroidSkill {
1002
- historyLength = 32;
1003
- skillMultiplier = 1;
1004
- reducedSectionCount = 5;
1005
- reducedSectionBaseline = 0.75;
1006
- strainDecayBase = 0.3;
1007
- starsPerDouble = 1.75;
1008
- rhythmMultiplier;
1009
- historyTimeMax = 5000; // 5 seconds of calculateRhythmBonus max.
1010
- currentRhythm = 1;
1011
- hitWindow;
1012
- constructor(mods, overallDifficulty) {
1013
- super(mods);
1014
- this.hitWindow = new osuBase.OsuHitWindow(overallDifficulty);
1015
- const odScaling = Math.pow(this.hitWindow.overallDifficulty, 2) / 400;
1016
- this.rhythmMultiplier =
1017
- 0.75 +
1018
- (this.hitWindow.overallDifficulty >= 0 ? odScaling : -odScaling);
1019
- }
1149
+ class RhythmEvaluator {
1150
+ static historyTimeMax = 5000; // 5 seconds of calculateRhythmBonus max.
1151
+ }
1152
+
1153
+ /**
1154
+ * An evaluator for calculating osu!droid Rhythm skill.
1155
+ */
1156
+ class DroidRhythmEvaluator extends RhythmEvaluator {
1020
1157
  /**
1021
- * Calculates a rhythm multiplier for the difficulty of the tap associated with historic data of the current object.
1158
+ * Calculates a rhythm multiplier for the difficulty of the tap associated
1159
+ * with historic data of the current object.
1160
+ *
1161
+ * @param current The current object.
1162
+ * @param greatWindow The great hit window of the current object.
1022
1163
  */
1023
- calculateRhythmBonus(current) {
1164
+ static evaluateDifficultyOf(current, greatWindow) {
1024
1165
  if (current.object instanceof osuBase.Spinner ||
1025
- osuBase.Precision.almostEqualsNumber(current.deltaTime, 0, 1)) {
1166
+ // Exclude overlapping objects that can be tapped at once.
1167
+ current.deltaTime < 5) {
1026
1168
  return 1;
1027
1169
  }
1028
1170
  let previousIslandSize = 0;
@@ -1032,8 +1174,18 @@ class DroidRhythm extends DroidSkill {
1032
1174
  let startRatio = 0;
1033
1175
  let firstDeltaSwitch = false;
1034
1176
  let rhythmStart = 0;
1177
+ const historicalNoteCount = Math.min(current.index, 32);
1035
1178
  // Exclude overlapping objects that can be tapped at once.
1036
- const validPrevious = this.previous.filter((v) => !osuBase.Precision.almostEqualsNumber(v.deltaTime, 0, 1));
1179
+ const validPrevious = [];
1180
+ for (let i = 0; i < historicalNoteCount; ++i) {
1181
+ const object = current.previous(i);
1182
+ if (!object) {
1183
+ break;
1184
+ }
1185
+ if (object.deltaTime >= 5) {
1186
+ validPrevious.push(object);
1187
+ }
1188
+ }
1037
1189
  while (rhythmStart < validPrevious.length - 2 &&
1038
1190
  current.startTime - validPrevious[rhythmStart].startTime <
1039
1191
  this.historyTimeMax) {
@@ -1054,9 +1206,8 @@ class DroidRhythm extends DroidSkill {
1054
1206
  Math.min(0.5, Math.pow(Math.sin(Math.PI /
1055
1207
  (Math.min(prevDelta, currentDelta) /
1056
1208
  Math.max(prevDelta, currentDelta))), 2));
1057
- const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) -
1058
- this.hitWindow.hitWindowFor300() * 0.4) /
1059
- (this.hitWindow.hitWindowFor300() * 0.4));
1209
+ const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - greatWindow * 0.4) /
1210
+ (greatWindow * 0.4));
1060
1211
  let effectiveRatio = windowPenalty * currentRatio;
1061
1212
  if (firstDeltaSwitch) {
1062
1213
  if (prevDelta <= 1.25 * currentDelta &&
@@ -1114,10 +1265,39 @@ class DroidRhythm extends DroidSkill {
1114
1265
  islandSize = 1;
1115
1266
  }
1116
1267
  }
1117
- return Math.sqrt(4 + rhythmComplexitySum * this.rhythmMultiplier) / 2;
1268
+ return (Math.sqrt(4 +
1269
+ rhythmComplexitySum *
1270
+ this.calculateRhythmMultiplier(greatWindow)) / 2);
1271
+ }
1272
+ /**
1273
+ * Calculates the rhythm multiplier of a given hit window.
1274
+ *
1275
+ * @param greatWindow The great hit window.
1276
+ */
1277
+ static calculateRhythmMultiplier(greatWindow) {
1278
+ const od = osuBase.OsuHitWindow.hitWindow300ToOD(greatWindow);
1279
+ const odScaling = Math.pow(od, 2) / 400;
1280
+ return 0.75 + (od >= 0 ? odScaling : -odScaling);
1281
+ }
1282
+ }
1283
+
1284
+ /**
1285
+ * Represents the skill required to properly follow a beatmap's rhythm.
1286
+ */
1287
+ class DroidRhythm extends DroidSkill {
1288
+ skillMultiplier = 1;
1289
+ reducedSectionCount = 5;
1290
+ reducedSectionBaseline = 0.75;
1291
+ strainDecayBase = 0.3;
1292
+ starsPerDouble = 1.75;
1293
+ currentRhythm = 1;
1294
+ hitWindow;
1295
+ constructor(mods, overallDifficulty) {
1296
+ super(mods);
1297
+ this.hitWindow = new osuBase.OsuHitWindow(overallDifficulty);
1118
1298
  }
1119
1299
  strainValueAt(current) {
1120
- this.currentRhythm = this.calculateRhythmBonus(current);
1300
+ this.currentRhythm = DroidRhythmEvaluator.evaluateDifficultyOf(current, this.hitWindow.hitWindowFor300());
1121
1301
  this.currentStrain *= this.strainDecay(current.deltaTime);
1122
1302
  this.currentStrain += this.currentRhythm - 1;
1123
1303
  return this.currentStrain;
@@ -1129,32 +1309,30 @@ class DroidRhythm extends DroidSkill {
1129
1309
  }
1130
1310
 
1131
1311
  /**
1132
- * Represents the skill required to read every object in the map.
1312
+ * An evaluator for calculating osu!droid Rhythm skill.
1133
1313
  */
1134
- class DroidVisual extends DroidSkill {
1135
- historyLength = 4;
1136
- starsPerDouble = 1.025;
1137
- reducedSectionCount = 10;
1138
- reducedSectionBaseline = 0.75;
1139
- skillMultiplier = 20;
1140
- strainDecayBase = 0.1;
1141
- preempt;
1142
- isHidden;
1143
- constructor(mods, preempt) {
1144
- super(mods);
1145
- this.preempt = preempt;
1146
- this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
1147
- }
1314
+ class DroidVisualEvaluator {
1148
1315
  /**
1149
- * @param current The hitobject to calculate.
1316
+ * Evaluates the difficulty of reading the current object, based on:
1317
+ *
1318
+ * - note density of the current object,
1319
+ * - overlapping factor of the current object,
1320
+ * - the preempt time of the current object,
1321
+ * - the velocity of the current object if it's a slider,
1322
+ * - past objects' velocity if they are sliders,
1323
+ * - and whether the Hidden mod is enabled.
1324
+ *
1325
+ * @param current The current object.
1326
+ * @param isHiddenMod Whether the Hidden mod is enabled.
1150
1327
  */
1151
- strainValueOf(current) {
1328
+ static evaluateDifficultyOf(current, isHiddenMod) {
1329
+ const last = current.previous(0);
1152
1330
  if (current.object instanceof osuBase.Spinner ||
1153
1331
  // Exclude overlapping objects that can be tapped at once.
1154
- (osuBase.Precision.almostEqualsNumber(current.deltaTime, 0, 1) &&
1155
- (this.previous[0]?.object instanceof osuBase.Slider
1156
- ? Math.min(this.previous[0].object.stackedEndPosition.getDistance(current.object.stackedPosition), this.previous[0].object.lazyEndPosition.getDistance(current.object.stackedPosition))
1157
- : this.previous[0]?.object.stackedEndPosition.getDistance(current.object.stackedPosition)) <=
1332
+ (current.deltaTime < 5 &&
1333
+ ((last?.object instanceof osuBase.Slider
1334
+ ? Math.min(last.object.stackedEndPosition.getDistance(current.object.stackedPosition), last.object.lazyEndPosition.getDistance(current.object.stackedPosition))
1335
+ : last?.object.stackedEndPosition.getDistance(current.object.stackedPosition)) ?? Number.POSITIVE_INFINITY) <=
1158
1336
  2 * current.object.radius)) {
1159
1337
  return 0;
1160
1338
  }
@@ -1163,15 +1341,15 @@ class DroidVisual extends DroidSkill {
1163
1341
  let strain = Math.min(20, Math.pow(current.noteDensity, 2)) /
1164
1342
  10 /
1165
1343
  (1 + current.overlappingFactor);
1166
- if (this.isHidden) {
1344
+ if (isHiddenMod) {
1167
1345
  strain +=
1168
1346
  Math.min(25, Math.pow(current.noteDensity, 1.25)) /
1169
1347
  10 /
1170
1348
  (1 + current.overlappingFactor / 1.25);
1171
1349
  }
1172
1350
  // Give bonus for AR higher than 10.33.
1173
- if (this.preempt < 400) {
1174
- strain += Math.pow(400 - this.preempt, 1.3) / 135;
1351
+ if (current.timePreempt < 400) {
1352
+ strain += Math.pow(400 - current.timePreempt, 1.3) / 135;
1175
1353
  }
1176
1354
  if (current.object instanceof osuBase.Slider) {
1177
1355
  const scalingFactor = 50 / current.object.radius;
@@ -1183,12 +1361,12 @@ class DroidVisual extends DroidSkill {
1183
1361
  Math.min(1, current.travelDistance / scalingFactor / 125);
1184
1362
  let cumulativeStrainTime = 0;
1185
1363
  // Reward for velocity changes based on last few sliders.
1186
- for (let i = 0; i < this.previous.length; ++i) {
1187
- const last = this.previous[i];
1364
+ for (let i = 0; i < Math.min(current.index, 4); ++i) {
1365
+ const last = current.previous(i);
1188
1366
  cumulativeStrainTime += last.strainTime;
1189
1367
  if (!(last.object instanceof osuBase.Slider) ||
1190
1368
  // Exclude overlapping objects that can be tapped at once.
1191
- (osuBase.Precision.almostEqualsNumber(current.deltaTime, 0, 1) &&
1369
+ (last.deltaTime < 5 &&
1192
1370
  Math.min(last.object.stackedEndPosition.getDistance(current.object.stackedPosition), last.object.lazyEndPosition.getDistance(current.object.stackedPosition)) <=
1193
1371
  2 * current.object.radius)) {
1194
1372
  continue;
@@ -1204,10 +1382,27 @@ class DroidVisual extends DroidSkill {
1204
1382
  }
1205
1383
  return strain;
1206
1384
  }
1385
+ }
1386
+
1387
+ /**
1388
+ * Represents the skill required to read every object in the map.
1389
+ */
1390
+ class DroidVisual extends DroidSkill {
1391
+ starsPerDouble = 1.025;
1392
+ reducedSectionCount = 10;
1393
+ reducedSectionBaseline = 0.75;
1394
+ skillMultiplier = 20;
1395
+ strainDecayBase = 0.1;
1396
+ isHidden;
1397
+ constructor(mods) {
1398
+ super(mods);
1399
+ this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
1400
+ }
1207
1401
  strainValueAt(current) {
1208
1402
  this.currentStrain *= this.strainDecay(current.deltaTime);
1209
1403
  this.currentStrain +=
1210
- this.strainValueOf(current) * this.skillMultiplier;
1404
+ DroidVisualEvaluator.evaluateDifficultyOf(current, this.isHidden) *
1405
+ this.skillMultiplier;
1211
1406
  return this.currentStrain * (1 + (current.rhythmMultiplier - 1) / 5);
1212
1407
  }
1213
1408
  saveToHitObject(current) {
@@ -1312,7 +1507,7 @@ class DroidStarRating extends StarRating {
1312
1507
  * Calculates the visual star rating of the beatmap and stores it in this instance.
1313
1508
  */
1314
1509
  calculateVisual() {
1315
- const visualSkill = new DroidVisual(this.mods, osuBase.MapStats.arToMS(this.stats.ar));
1510
+ const visualSkill = new DroidVisual(this.mods);
1316
1511
  this.calculateSkills(visualSkill);
1317
1512
  this.postCalculateVisual(visualSkill);
1318
1513
  }
@@ -1387,7 +1582,7 @@ class DroidStarRating extends StarRating {
1387
1582
  new DroidRhythm(this.mods, this.stats.od),
1388
1583
  new DroidTap(this.mods, this.stats.od),
1389
1584
  new DroidFlashlight(this.mods),
1390
- new DroidVisual(this.mods, osuBase.MapStats.arToMS(this.stats.ar)),
1585
+ new DroidVisual(this.mods),
1391
1586
  ];
1392
1587
  }
1393
1588
  /**
@@ -1740,10 +1935,6 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
1740
1935
  const objectCount = this.stars.objects.length;
1741
1936
  this.flashlight =
1742
1937
  Math.pow(Math.pow(this.stars.flashlight, 0.8), 2) * 25;
1743
- // Add an additional bonus for HDFL.
1744
- if (this.stars.mods.some((m) => m instanceof osuBase.ModHidden)) {
1745
- this.flashlight *= 1.3;
1746
- }
1747
1938
  // Combo scaling
1748
1939
  this.flashlight *= this.comboPenalty;
1749
1940
  if (this.effectiveMissCount > 0) {
@@ -1816,9 +2007,7 @@ class OsuSkill extends StrainSkill {
1816
2007
  difficultyValue() {
1817
2008
  const sortedStrains = this.strainPeaks
1818
2009
  .slice()
1819
- .sort((a, b) => {
1820
- return b - a;
1821
- });
2010
+ .sort((a, b) => b - a);
1822
2011
  // We are reducing the highest strains first to account for extreme difficulty spikes.
1823
2012
  for (let i = 0; i < Math.min(sortedStrains.length, this.reducedSectionCount); ++i) {
1824
2013
  const scale = Math.log10(osuBase.Interpolation.lerp(1, 10, osuBase.MathUtils.clamp(i / this.reducedSectionCount, 0, 1)));
@@ -1826,9 +2015,7 @@ class OsuSkill extends StrainSkill {
1826
2015
  }
1827
2016
  // Difficulty is the weighted sum of the highest strains from every section.
1828
2017
  // We're sorting from highest to lowest strain.
1829
- sortedStrains.sort((a, b) => {
1830
- return b - a;
1831
- });
2018
+ sortedStrains.sort((a, b) => b - a);
1832
2019
  let difficulty = 0;
1833
2020
  let weight = 1;
1834
2021
  for (const strain of sortedStrains) {
@@ -1844,39 +2031,32 @@ class OsuSkill extends StrainSkill {
1844
2031
  }
1845
2032
 
1846
2033
  /**
1847
- * Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
2034
+ * An evaluator for calculating osu!standard Aim skill.
1848
2035
  */
1849
- class OsuAim extends OsuSkill {
1850
- skillMultiplier = 23.25;
1851
- strainDecayBase = 0.15;
1852
- reducedSectionCount = 10;
1853
- reducedSectionBaseline = 0.75;
1854
- difficultyMultiplier = 1.06;
1855
- decayWeight = 0.9;
1856
- wideAngleMultiplier = 1.5;
1857
- acuteAngleMultiplier = 2;
1858
- sliderMultiplier = 1.5;
1859
- velocityChangeMultiplier = 0.75;
1860
- withSliders;
1861
- constructor(mods, withSliders) {
1862
- super(mods);
1863
- this.withSliders = withSliders;
1864
- }
2036
+ class OsuAimEvaluator extends AimEvaluator {
1865
2037
  /**
1866
- * @param current The hitobject to calculate.
2038
+ * Evaluates the difficulty of aiming the current object, based on:
2039
+ *
2040
+ * - cursor velocity to the current object,
2041
+ * - angle difficulty,
2042
+ * - sharp velocity increases,
2043
+ * - and slider difficulty.
2044
+ *
2045
+ * @param current The current object.
2046
+ * @param withSliders Whether to take slider difficulty into account.
1867
2047
  */
1868
- strainValueOf(current) {
2048
+ static evaluateDifficultyOf(current, withSliders) {
2049
+ const last = current.previous(0);
1869
2050
  if (current.object instanceof osuBase.Spinner ||
1870
- this.previous.length <= 1 ||
1871
- this.previous[0].object instanceof osuBase.Spinner) {
2051
+ current.index <= 1 ||
2052
+ last?.object instanceof osuBase.Spinner) {
1872
2053
  return 0;
1873
2054
  }
1874
- const last = this.previous[0];
1875
- const lastLast = this.previous[1];
2055
+ const lastLast = current.previous(1);
1876
2056
  // Calculate the velocity to the current hitobject, which starts with a base distance / time assuming the last object is a hitcircle.
1877
2057
  let currentVelocity = current.lazyJumpDistance / current.strainTime;
1878
2058
  // But if the last object is a slider, then we extend the travel velocity through the slider into the current object.
1879
- if (last.object instanceof osuBase.Slider && this.withSliders) {
2059
+ if (last.object instanceof osuBase.Slider && withSliders) {
1880
2060
  // Calculate the slider velocity from slider head to slider end.
1881
2061
  const travelVelocity = last.travelDistance / last.travelTime;
1882
2062
  // Calculate the movement velocity from slider end to current object.
@@ -1886,7 +2066,7 @@ class OsuAim extends OsuSkill {
1886
2066
  }
1887
2067
  // As above, do the same for the previous hitobject.
1888
2068
  let prevVelocity = last.lazyJumpDistance / last.strainTime;
1889
- if (lastLast.object instanceof osuBase.Slider && this.withSliders) {
2069
+ if (lastLast.object instanceof osuBase.Slider && withSliders) {
1890
2070
  const travelVelocity = lastLast.travelDistance / lastLast.travelTime;
1891
2071
  const movementVelocity = last.minimumJumpDistance / last.minimumJumpTime;
1892
2072
  prevVelocity = Math.max(prevVelocity, movementVelocity + travelVelocity);
@@ -1973,18 +2153,36 @@ class OsuAim extends OsuSkill {
1973
2153
  strain += Math.max(acuteAngleBonus * this.acuteAngleMultiplier, wideAngleBonus * this.wideAngleMultiplier +
1974
2154
  velocityChangeBonus * this.velocityChangeMultiplier);
1975
2155
  // Add in additional slider velocity bonus.
1976
- if (this.withSliders) {
2156
+ if (withSliders) {
1977
2157
  strain += sliderBonus * this.sliderMultiplier;
1978
2158
  }
1979
2159
  return strain;
1980
2160
  }
2161
+ }
2162
+
2163
+ /**
2164
+ * Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
2165
+ */
2166
+ class OsuAim extends OsuSkill {
2167
+ skillMultiplier = 23.25;
2168
+ strainDecayBase = 0.15;
2169
+ reducedSectionCount = 10;
2170
+ reducedSectionBaseline = 0.75;
2171
+ difficultyMultiplier = 1.06;
2172
+ decayWeight = 0.9;
2173
+ withSliders;
2174
+ constructor(mods, withSliders) {
2175
+ super(mods);
2176
+ this.withSliders = withSliders;
2177
+ }
1981
2178
  /**
1982
2179
  * @param current The hitobject to calculate.
1983
2180
  */
1984
2181
  strainValueAt(current) {
1985
2182
  this.currentStrain *= this.strainDecay(current.deltaTime);
1986
2183
  this.currentStrain +=
1987
- this.strainValueOf(current) * this.skillMultiplier;
2184
+ OsuAimEvaluator.evaluateDifficultyOf(current, this.withSliders) *
2185
+ this.skillMultiplier;
1988
2186
  return this.currentStrain;
1989
2187
  }
1990
2188
  /**
@@ -1998,63 +2196,39 @@ class OsuAim extends OsuSkill {
1998
2196
  current.aimStrainWithoutSliders = this.currentStrain;
1999
2197
  }
2000
2198
  }
2001
- /**
2002
- * Calculates the bonus of wide angles.
2003
- */
2004
- calculateWideAngleBonus(angle) {
2005
- return Math.pow(Math.sin((3 / 4) *
2006
- (Math.min((5 / 6) * Math.PI, Math.max(Math.PI / 6, angle)) -
2007
- Math.PI / 6)), 2);
2008
- }
2009
- /**
2010
- * Calculates the bonus of acute angles.
2011
- */
2012
- calculateAcuteAngleBonus(angle) {
2013
- return 1 - this.calculateWideAngleBonus(angle);
2014
- }
2015
2199
  }
2016
2200
 
2017
2201
  /**
2018
- * Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
2202
+ * An evaluator for calculating osu!standard speed skill.
2019
2203
  */
2020
- class OsuSpeed extends OsuSkill {
2204
+ class OsuSpeedEvaluator extends SpeedEvaluator {
2021
2205
  /**
2022
2206
  * Spacing threshold for a single hitobject spacing.
2023
2207
  */
2024
- SINGLE_SPACING_THRESHOLD = 125;
2025
- historyLength = 32;
2026
- skillMultiplier = 1375;
2027
- strainDecayBase = 0.3;
2028
- reducedSectionCount = 5;
2029
- reducedSectionBaseline = 0.75;
2030
- difficultyMultiplier = 1.04;
2031
- decayWeight = 0.9;
2032
- rhythmMultiplier = 0.75;
2033
- historyTimeMax = 5000; // 5 seconds of calculateRhythmBonus max.
2034
- currentSpeedStrain = 0;
2035
- currentRhythm = 0;
2036
- // ~200 1/4 BPM streams
2037
- minSpeedBonus = 75;
2038
- greatWindow;
2039
- constructor(mods, greatWindow) {
2040
- super(mods);
2041
- this.greatWindow = greatWindow;
2042
- }
2208
+ static SINGLE_SPACING_THRESHOLD = 125;
2043
2209
  /**
2044
- * @param current The hitobject to calculate.
2210
+ * Evaluates the difficulty of tapping the current object, based on:
2211
+ *
2212
+ * - time between pressing the previous and current object,
2213
+ * - distance between those objects,
2214
+ * - and how easily they can be cheesed.
2215
+ *
2216
+ * @param current The current object.
2217
+ * @param greatWindow The great hit window of the current object.
2045
2218
  */
2046
- strainValueOf(current) {
2219
+ static evaluateDifficultyOf(current, greatWindow) {
2047
2220
  if (current.object instanceof osuBase.Spinner) {
2048
2221
  return 0;
2049
2222
  }
2223
+ const prev = current.previous(0);
2050
2224
  let strainTime = current.strainTime;
2051
- const greatWindowFull = this.greatWindow * 2;
2225
+ const greatWindowFull = greatWindow * 2;
2052
2226
  const speedWindowRatio = strainTime / greatWindowFull;
2053
2227
  // Aim to nerf cheesy rhythms (very fast consecutive doubles with large deltatimes between).
2054
- if (this.previous[0] &&
2228
+ if (prev &&
2055
2229
  strainTime < greatWindowFull &&
2056
- this.previous[0].strainTime > strainTime) {
2057
- strainTime = osuBase.Interpolation.lerp(this.previous[0].strainTime, strainTime, speedWindowRatio);
2230
+ prev.strainTime > strainTime) {
2231
+ strainTime = osuBase.Interpolation.lerp(prev.strainTime, strainTime, speedWindowRatio);
2058
2232
  }
2059
2233
  // Cap deltatime to the OD 300 hitwindow.
2060
2234
  // 0.93 is derived from making sure 260 BPM 1/4 OD8 streams aren't nerfed harshly, whilst 0.92 limits the effect of the cap.
@@ -2064,27 +2238,28 @@ class OsuSpeed extends OsuSkill {
2064
2238
  speedBonus +=
2065
2239
  0.75 * Math.pow((this.minSpeedBonus - strainTime) / 40, 2);
2066
2240
  }
2067
- const travelDistance = this.previous[0]?.travelDistance ?? 0;
2241
+ const travelDistance = prev?.travelDistance ?? 0;
2068
2242
  const distance = Math.min(this.SINGLE_SPACING_THRESHOLD, travelDistance + current.minimumJumpDistance);
2069
2243
  return ((speedBonus +
2070
2244
  speedBonus *
2071
2245
  Math.pow(distance / this.SINGLE_SPACING_THRESHOLD, 3.5)) /
2072
2246
  strainTime);
2073
2247
  }
2248
+ }
2249
+
2250
+ /**
2251
+ * An evaluator for calculating osu!standard Rhythm skill.
2252
+ */
2253
+ class OsuRhythmEvaluator extends RhythmEvaluator {
2254
+ static rhythmMultiplier = 0.75;
2074
2255
  /**
2075
- * @param current The hitobject to calculate.
2076
- */
2077
- strainValueAt(current) {
2078
- this.currentSpeedStrain *= this.strainDecay(current.deltaTime);
2079
- this.currentSpeedStrain +=
2080
- this.strainValueOf(current) * this.skillMultiplier;
2081
- this.currentRhythm = this.calculateRhythmBonus(current);
2082
- return this.currentSpeedStrain * this.currentRhythm;
2083
- }
2084
- /**
2085
- * Calculates a rhythm multiplier for the difficulty of the tap associated with historic data of the current object.
2256
+ * Calculates a rhythm multiplier for the difficulty of the tap associated
2257
+ * with historic data of the current object.
2258
+ *
2259
+ * @param current The current object.
2260
+ * @param greatWindow The great hit window of the current object.
2086
2261
  */
2087
- calculateRhythmBonus(current) {
2262
+ static evaluateDifficultyOf(current, greatWindow) {
2088
2263
  if (current.object instanceof osuBase.Spinner) {
2089
2264
  return 0;
2090
2265
  }
@@ -2094,29 +2269,33 @@ class OsuSpeed extends OsuSkill {
2094
2269
  // Store the ratio of the current start of an island to buff for tighter rhythms.
2095
2270
  let startRatio = 0;
2096
2271
  let firstDeltaSwitch = false;
2272
+ const historicalNoteCount = Math.min(current.index, 32);
2097
2273
  let rhythmStart = 0;
2098
- while (rhythmStart < this.previous.length - 2 &&
2099
- current.startTime - this.previous[rhythmStart].startTime <
2274
+ while (rhythmStart < historicalNoteCount - 2 &&
2275
+ current.startTime - current.previous(rhythmStart).startTime <
2100
2276
  this.historyTimeMax) {
2101
2277
  ++rhythmStart;
2102
2278
  }
2103
2279
  for (let i = rhythmStart; i > 0; --i) {
2280
+ const currentObject = current.previous(i - 1);
2281
+ const prevObject = current.previous(i);
2282
+ const lastObject = current.previous(i + 1);
2104
2283
  // Scale note 0 to 1 from history to now.
2105
2284
  let currentHistoricalDecay = (this.historyTimeMax -
2106
- (current.startTime - this.previous[i - 1].startTime)) /
2285
+ (current.startTime - currentObject.startTime)) /
2107
2286
  this.historyTimeMax;
2108
2287
  // Either we're limited by time or limited by object count.
2109
- currentHistoricalDecay = Math.min(currentHistoricalDecay, (this.previous.length - i) / this.previous.length);
2110
- const currentDelta = this.previous[i - 1].strainTime;
2111
- const prevDelta = this.previous[i].strainTime;
2112
- const lastDelta = this.previous[i + 1].strainTime;
2288
+ currentHistoricalDecay = Math.min(currentHistoricalDecay, (historicalNoteCount - i) / historicalNoteCount);
2289
+ const currentDelta = currentObject.strainTime;
2290
+ const prevDelta = prevObject.strainTime;
2291
+ const lastDelta = lastObject.strainTime;
2113
2292
  const currentRatio = 1 +
2114
2293
  6 *
2115
2294
  Math.min(0.5, Math.pow(Math.sin(Math.PI /
2116
2295
  (Math.min(prevDelta, currentDelta) /
2117
2296
  Math.max(prevDelta, currentDelta))), 2));
2118
- const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - this.greatWindow * 0.6) /
2119
- (this.greatWindow * 0.6));
2297
+ const windowPenalty = Math.min(1, Math.max(0, Math.abs(prevDelta - currentDelta) - greatWindow * 0.6) /
2298
+ (greatWindow * 0.6));
2120
2299
  let effectiveRatio = windowPenalty * currentRatio;
2121
2300
  if (firstDeltaSwitch) {
2122
2301
  if (prevDelta <= 1.25 * currentDelta &&
@@ -2127,11 +2306,11 @@ class OsuSpeed extends OsuSkill {
2127
2306
  }
2128
2307
  }
2129
2308
  else {
2130
- if (this.previous[i - 1].object instanceof osuBase.Slider) {
2309
+ if (currentObject.object instanceof osuBase.Slider) {
2131
2310
  // BPM change is into slider, this is easy acc window.
2132
2311
  effectiveRatio /= 8;
2133
2312
  }
2134
- if (this.previous[i].object instanceof osuBase.Slider) {
2313
+ if (prevObject.object instanceof osuBase.Slider) {
2135
2314
  // BPM change was from a slider, this is typically easier than circle -> circle.
2136
2315
  effectiveRatio /= 4;
2137
2316
  }
@@ -2176,6 +2355,38 @@ class OsuSpeed extends OsuSkill {
2176
2355
  }
2177
2356
  return Math.sqrt(4 + rhythmComplexitySum * this.rhythmMultiplier) / 2;
2178
2357
  }
2358
+ }
2359
+
2360
+ /**
2361
+ * Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
2362
+ */
2363
+ class OsuSpeed extends OsuSkill {
2364
+ skillMultiplier = 1375;
2365
+ strainDecayBase = 0.3;
2366
+ reducedSectionCount = 5;
2367
+ reducedSectionBaseline = 0.75;
2368
+ difficultyMultiplier = 1.04;
2369
+ decayWeight = 0.9;
2370
+ currentSpeedStrain = 0;
2371
+ currentRhythm = 0;
2372
+ // ~200 1/4 BPM streams
2373
+ minSpeedBonus = 75;
2374
+ greatWindow;
2375
+ constructor(mods, greatWindow) {
2376
+ super(mods);
2377
+ this.greatWindow = greatWindow;
2378
+ }
2379
+ /**
2380
+ * @param current The hitobject to calculate.
2381
+ */
2382
+ strainValueAt(current) {
2383
+ this.currentSpeedStrain *= this.strainDecay(current.deltaTime);
2384
+ this.currentSpeedStrain +=
2385
+ OsuSpeedEvaluator.evaluateDifficultyOf(current, this.greatWindow) *
2386
+ this.skillMultiplier;
2387
+ this.currentRhythm = OsuRhythmEvaluator.evaluateDifficultyOf(current, this.greatWindow);
2388
+ return this.currentSpeedStrain * this.currentRhythm;
2389
+ }
2179
2390
  /**
2180
2391
  * @param current The hitobject to save to.
2181
2392
  */
@@ -2186,17 +2397,20 @@ class OsuSpeed extends OsuSkill {
2186
2397
  }
2187
2398
 
2188
2399
  /**
2189
- * Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
2400
+ * An evaluator for calculating osu!standard Flashlight skill.
2190
2401
  */
2191
- class OsuFlashlight extends OsuSkill {
2192
- historyLength = 10;
2193
- skillMultiplier = 0.07;
2194
- strainDecayBase = 0.15;
2195
- reducedSectionCount = 10;
2196
- reducedSectionBaseline = 0.75;
2197
- difficultyMultiplier = 1.06;
2198
- decayWeight = 1;
2199
- strainValueOf(current) {
2402
+ class OsuFlashlightEvaluator extends FlashlightEvaluator {
2403
+ /**
2404
+ * Evaluates the difficulty of memorizing and hitting the current object, based on:
2405
+ *
2406
+ * - distance between the previous and the current object,
2407
+ * - the visual opacity of the current object,
2408
+ * - and whether Hidden mod is enabled.
2409
+ *
2410
+ * @param current The current object.
2411
+ * @param isHiddenMod Whether the Hidden mod is enabled.
2412
+ */
2413
+ static evaluateDifficultyOf(current, isHiddenMod) {
2200
2414
  if (current.object instanceof osuBase.Spinner) {
2201
2415
  return 0;
2202
2416
  }
@@ -2205,8 +2419,8 @@ class OsuFlashlight extends OsuSkill {
2205
2419
  let cumulativeStrainTime = 0;
2206
2420
  let result = 0;
2207
2421
  let last = current;
2208
- for (let i = 0; i < this.previous.length; ++i) {
2209
- const currentObject = this.previous[i];
2422
+ for (let i = 0; i < Math.min(current.index, 10); ++i) {
2423
+ const currentObject = current.previous(i);
2210
2424
  if (!(currentObject.object instanceof osuBase.Spinner)) {
2211
2425
  const jumpDistance = current.object.stackedPosition.subtract(currentObject.object.endPosition).length;
2212
2426
  cumulativeStrainTime += last.strainTime;
@@ -2216,21 +2430,47 @@ class OsuFlashlight extends OsuSkill {
2216
2430
  }
2217
2431
  // We also want to nerf stacks so that only the first object of the stack is accounted for.
2218
2432
  const stackNerf = Math.min(1, currentObject.lazyJumpDistance / scalingFactor / 25);
2433
+ // Bonus based on how visible the object is.
2434
+ const opacityBonus = 1 +
2435
+ this.maxOpacityBonus *
2436
+ (1.0 -
2437
+ current.opacityAt(currentObject.startTime, isHiddenMod));
2219
2438
  result +=
2220
- (stackNerf * scalingFactor * jumpDistance) /
2439
+ (stackNerf * opacityBonus * scalingFactor * jumpDistance) /
2221
2440
  cumulativeStrainTime;
2222
2441
  }
2223
2442
  last = currentObject;
2224
2443
  }
2444
+ // Additional bonus for Hidden due to there being no approach circles.
2445
+ if (isHiddenMod) {
2446
+ result *= 1 + this.hiddenBonus;
2447
+ }
2225
2448
  return Math.pow(smallDistNerf * result, 2);
2226
2449
  }
2450
+ }
2451
+
2452
+ /**
2453
+ * Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
2454
+ */
2455
+ class OsuFlashlight extends OsuSkill {
2456
+ skillMultiplier = 0.05;
2457
+ strainDecayBase = 0.15;
2458
+ reducedSectionCount = 10;
2459
+ reducedSectionBaseline = 0.75;
2460
+ difficultyMultiplier = 1.06;
2461
+ decayWeight = 1;
2462
+ isHidden;
2463
+ constructor(mods) {
2464
+ super(mods);
2465
+ this.isHidden = mods.some((m) => m instanceof osuBase.ModHidden);
2466
+ }
2227
2467
  /**
2228
2468
  * @param current The hitobject to calculate.
2229
2469
  */
2230
2470
  strainValueAt(current) {
2231
2471
  this.currentStrain *= this.strainDecay(current.deltaTime);
2232
2472
  this.currentStrain +=
2233
- this.strainValueOf(current) * this.skillMultiplier;
2473
+ OsuFlashlightEvaluator.evaluateDifficultyOf(current, this.isHidden) * this.skillMultiplier;
2234
2474
  return this.currentStrain;
2235
2475
  }
2236
2476
  saveToHitObject(current) {
@@ -2608,10 +2848,6 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
2608
2848
  Math.pow(Math.pow(this.stars.flashlight, this.stars.mods.some((m) => m instanceof osuBase.ModTouchDevice)
2609
2849
  ? 0.8
2610
2850
  : 1), 2) * 25;
2611
- // Add an additional bonus for HDFL.
2612
- if (this.stars.mods.some((m) => m instanceof osuBase.ModHidden)) {
2613
- this.flashlight *= 1.3;
2614
- }
2615
2851
  // Combo scaling
2616
2852
  this.flashlight *= this.comboPenalty;
2617
2853
  if (this.effectiveMissCount > 0) {
@@ -2647,21 +2883,34 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
2647
2883
  }
2648
2884
  }
2649
2885
 
2886
+ exports.AimEvaluator = AimEvaluator;
2650
2887
  exports.DifficultyHitObject = DifficultyHitObject;
2651
2888
  exports.DifficultyHitObjectCreator = DifficultyHitObjectCreator;
2652
2889
  exports.DroidAim = DroidAim;
2890
+ exports.DroidAimEvaluator = DroidAimEvaluator;
2653
2891
  exports.DroidFlashlight = DroidFlashlight;
2892
+ exports.DroidFlashlightEvaluator = DroidFlashlightEvaluator;
2654
2893
  exports.DroidPerformanceCalculator = DroidPerformanceCalculator;
2655
2894
  exports.DroidRhythm = DroidRhythm;
2895
+ exports.DroidRhythmEvaluator = DroidRhythmEvaluator;
2656
2896
  exports.DroidStarRating = DroidStarRating;
2657
2897
  exports.DroidTap = DroidTap;
2898
+ exports.DroidTapEvaluator = DroidTapEvaluator;
2658
2899
  exports.DroidVisual = DroidVisual;
2900
+ exports.DroidVisualEvaluator = DroidVisualEvaluator;
2901
+ exports.FlashlightEvaluator = FlashlightEvaluator;
2659
2902
  exports.MapStars = MapStars;
2660
2903
  exports.OsuAim = OsuAim;
2904
+ exports.OsuAimEvaluator = OsuAimEvaluator;
2661
2905
  exports.OsuFlashlight = OsuFlashlight;
2906
+ exports.OsuFlashlightEvaluator = OsuFlashlightEvaluator;
2662
2907
  exports.OsuPerformanceCalculator = OsuPerformanceCalculator;
2908
+ exports.OsuRhythmEvaluator = OsuRhythmEvaluator;
2663
2909
  exports.OsuSpeed = OsuSpeed;
2910
+ exports.OsuSpeedEvaluator = OsuSpeedEvaluator;
2664
2911
  exports.OsuStarRating = OsuStarRating;
2665
2912
  exports.PerformanceCalculator = PerformanceCalculator;
2913
+ exports.RhythmEvaluator = RhythmEvaluator;
2914
+ exports.SpeedEvaluator = SpeedEvaluator;
2666
2915
  exports.StarRating = StarRating;
2667
2916
  //# sourceMappingURL=index.js.map