@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.56 → 4.0.0-beta.58

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
@@ -7,7 +7,7 @@ var osuBase = require('@rian8337/osu-base');
7
7
  */
8
8
  class DifficultyAttributes {
9
9
  constructor(cacheableAttributes) {
10
- this.mods = [];
10
+ this.mods = new osuBase.ModMap();
11
11
  this.starRating = 0;
12
12
  this.maxCombo = 0;
13
13
  this.aimDifficulty = 0;
@@ -47,7 +47,7 @@ class DifficultyAttributes {
47
47
  * @returns The cacheable attributes.
48
48
  */
49
49
  toCacheableAttributes() {
50
- return Object.assign(Object.assign({}, this), { mods: osuBase.ModUtil.serializeMods(this.mods) });
50
+ return Object.assign(Object.assign({}, this), { mods: this.mods.serializeMods() });
51
51
  }
52
52
  /**
53
53
  * Returns a string representation of the difficulty attributes.
@@ -79,7 +79,7 @@ class DifficultyCalculator {
79
79
  osuBase.ModAutopilot,
80
80
  ]);
81
81
  }
82
- calculate(beatmap, mods = []) {
82
+ calculate(beatmap, mods) {
83
83
  const playableBeatmap = beatmap instanceof osuBase.PlayableBeatmap
84
84
  ? beatmap
85
85
  : this.createPlayableBeatmap(beatmap, mods);
@@ -92,7 +92,7 @@ class DifficultyCalculator {
92
92
  }
93
93
  return this.createDifficultyAttributes(playableBeatmap, skills, objects);
94
94
  }
95
- calculateStrainPeaks(beatmap, mods = []) {
95
+ calculateStrainPeaks(beatmap, mods) {
96
96
  const playableBeatmap = beatmap instanceof osuBase.PlayableBeatmap
97
97
  ? beatmap
98
98
  : this.createPlayableBeatmap(beatmap, mods);
@@ -283,7 +283,7 @@ class DifficultyHitObject {
283
283
  }
284
284
  const fadeInStartTime = this.object.startTime - this.object.timePreempt;
285
285
  const fadeInDuration = this.object.timeFadeIn;
286
- if (mods.some((m) => m instanceof osuBase.ModHidden)) {
286
+ if (mods.has(osuBase.ModHidden)) {
287
287
  const fadeOutStartTime = fadeInStartTime + fadeInDuration;
288
288
  const fadeOutDuration = this.object.timePreempt * osuBase.ModHidden.fadeOutDurationMultiplier;
289
289
  return Math.min(osuBase.MathUtils.clamp((time - fadeInStartTime) / fadeInDuration, 0, 1), 1 -
@@ -568,8 +568,7 @@ class DroidDifficultyHitObject extends DifficultyHitObject {
568
568
  }
569
569
  opacityAt(time, mods) {
570
570
  // Traceable hides the primary piece of a hit circle (that is, its body), so consider it as fully invisible.
571
- if (this.object instanceof osuBase.Circle &&
572
- mods.some((m) => m instanceof osuBase.ModTraceable)) {
571
+ if (this.object instanceof osuBase.Circle && mods.has(osuBase.ModTraceable)) {
573
572
  return 0;
574
573
  }
575
574
  return super.opacityAt(time, mods);
@@ -1179,10 +1178,10 @@ class DroidFlashlightEvaluator {
1179
1178
  }
1180
1179
  result = Math.pow(smallDistNerf * result, 2);
1181
1180
  // Additional bonus for Hidden due to there being no approach circles.
1182
- if (mods.some((m) => m instanceof osuBase.ModHidden)) {
1181
+ if (mods.has(osuBase.ModHidden)) {
1183
1182
  result *= 1 + this.hiddenBonus;
1184
1183
  }
1185
- else if (mods.some((m) => m instanceof osuBase.ModTraceable)) {
1184
+ else if (mods.has(osuBase.ModTraceable)) {
1186
1185
  // Additional bonus for Traceable due to there being no primary or secondary object pieces.
1187
1186
  if (current.object instanceof osuBase.Circle) {
1188
1187
  // Additional bonus for hit circles due to there being no circle piece, which is the primary piece.
@@ -1466,7 +1465,7 @@ class DroidRhythm extends DroidSkill {
1466
1465
  this.starsPerDouble = 1.75;
1467
1466
  this.currentRhythmStrain = 0;
1468
1467
  this.currentRhythmMultiplier = 1;
1469
- this.useSliderAccuracy = mods.some((m) => m instanceof osuBase.ModScoreV2);
1468
+ this.useSliderAccuracy = mods.has(osuBase.ModScoreV2);
1470
1469
  }
1471
1470
  strainValueAt(current) {
1472
1471
  this.currentRhythmMultiplier =
@@ -1648,10 +1647,10 @@ class DroidVisualEvaluator {
1648
1647
  // Start with base density and give global bonus for Hidden.
1649
1648
  // Add density caps for sanity.
1650
1649
  let strain;
1651
- if (mods.some((m) => m instanceof osuBase.ModHidden)) {
1650
+ if (mods.has(osuBase.ModHidden)) {
1652
1651
  strain = Math.min(30, Math.pow(current.noteDensity, 3));
1653
1652
  }
1654
- else if (mods.some((m) => m instanceof osuBase.ModTraceable)) {
1653
+ else if (mods.has(osuBase.ModTraceable)) {
1655
1654
  // Give more bonus for hit circles due to there being no circle piece.
1656
1655
  if (current.object instanceof osuBase.Circle) {
1657
1656
  strain = Math.min(25, Math.pow(current.noteDensity, 2.5));
@@ -1811,7 +1810,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1811
1810
  }
1812
1811
  createDifficultyAttributes(beatmap, skills, objects) {
1813
1812
  const attributes = new ExtendedDroidDifficultyAttributes();
1814
- attributes.mods = beatmap.mods.slice();
1813
+ attributes.mods = beatmap.mods;
1815
1814
  attributes.maxCombo = beatmap.maxCombo;
1816
1815
  attributes.clockRate = beatmap.speedMultiplier;
1817
1816
  attributes.hitCircleCount = beatmap.hitObjects.circles;
@@ -1822,14 +1821,14 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1822
1821
  this.populateRhythmAttributes(attributes, skills);
1823
1822
  this.populateFlashlightAttributes(attributes, skills);
1824
1823
  this.populateVisualAttributes(attributes, skills);
1825
- if (attributes.mods.some((m) => m instanceof osuBase.ModRelax)) {
1824
+ if (beatmap.mods.has(osuBase.ModRelax)) {
1826
1825
  attributes.aimDifficulty *= 0.9;
1827
1826
  attributes.tapDifficulty = 0;
1828
1827
  attributes.rhythmDifficulty = 0;
1829
1828
  attributes.flashlightDifficulty *= 0.7;
1830
1829
  attributes.visualDifficulty = 0;
1831
1830
  }
1832
- else if (attributes.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
1831
+ else if (beatmap.mods.has(osuBase.ModAutopilot)) {
1833
1832
  attributes.aimDifficulty = 0;
1834
1833
  attributes.flashlightDifficulty *= 0.3;
1835
1834
  attributes.visualDifficulty *= 0.8;
@@ -1854,7 +1853,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1854
1853
  attributes.starRating = 0;
1855
1854
  }
1856
1855
  let greatWindow;
1857
- if (attributes.mods.some((m) => m instanceof osuBase.ModPrecise)) {
1856
+ if (attributes.mods.has(osuBase.ModPrecise)) {
1858
1857
  greatWindow = new osuBase.PreciseDroidHitWindow(beatmap.difficulty.od)
1859
1858
  .greatWindow;
1860
1859
  }
@@ -1882,11 +1881,11 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1882
1881
  createSkills(beatmap) {
1883
1882
  const { mods } = beatmap;
1884
1883
  const skills = [];
1885
- if (!mods.some((m) => m instanceof osuBase.ModAutopilot)) {
1884
+ if (!mods.has(osuBase.ModAutopilot)) {
1886
1885
  skills.push(new DroidAim(mods, true));
1887
1886
  skills.push(new DroidAim(mods, false));
1888
1887
  }
1889
- if (!mods.some((m) => m instanceof osuBase.ModRelax)) {
1888
+ if (!mods.has(osuBase.ModRelax)) {
1890
1889
  // Tap and visual skills depend on rhythm skill, so we put it first
1891
1890
  skills.push(new DroidRhythm(mods));
1892
1891
  skills.push(new DroidTap(mods, true));
@@ -1894,7 +1893,7 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1894
1893
  skills.push(new DroidVisual(mods, true));
1895
1894
  skills.push(new DroidVisual(mods, false));
1896
1895
  }
1897
- if (mods.some((m) => m instanceof osuBase.ModFlashlight)) {
1896
+ if (mods.has(osuBase.ModFlashlight)) {
1898
1897
  skills.push(new DroidFlashlight(mods, true));
1899
1898
  skills.push(new DroidFlashlight(mods, false));
1900
1899
  }
@@ -2164,15 +2163,15 @@ class PerformanceCalculator {
2164
2163
  });
2165
2164
  }
2166
2165
  this.effectiveMissCount = this.calculateEffectiveMissCount(combo, maxCombo);
2167
- if (this.mods.some((m) => m instanceof osuBase.ModNoFail)) {
2166
+ if (this.mods.has(osuBase.ModNoFail)) {
2168
2167
  this.finalMultiplier *= Math.max(0.9, 1 - 0.02 * this.effectiveMissCount);
2169
2168
  }
2170
- if (this.mods.some((m) => m instanceof osuBase.ModSpunOut)) {
2169
+ if (this.mods.has(osuBase.ModSpunOut)) {
2171
2170
  this.finalMultiplier *=
2172
2171
  1 -
2173
2172
  Math.pow(this.difficultyAttributes.spinnerCount / this.totalHits, 0.85);
2174
2173
  }
2175
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
2174
+ if (this.mods.has(osuBase.ModRelax)) {
2176
2175
  // Graph: https://www.desmos.com/calculator/bc9eybdthb
2177
2176
  // We use OD13.3 as maximum since it's the value at which great hit window becomes 0.
2178
2177
  const n100Multiplier = Math.max(0, this.difficultyAttributes.overallDifficulty > 0
@@ -2497,12 +2496,11 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2497
2496
  * Calculates the accuracy performance value of the beatmap.
2498
2497
  */
2499
2498
  calculateAccuracyValue() {
2500
- if (this.mods.some((m) => m instanceof osuBase.ModRelax) ||
2501
- this.totalSuccessfulHits === 0) {
2499
+ if (this.mods.has(osuBase.ModRelax) || this.totalSuccessfulHits === 0) {
2502
2500
  return 0;
2503
2501
  }
2504
2502
  let accuracyValue = 650 * Math.exp(-0.1 * this._deviation);
2505
- const ncircles = this.mods.some((m) => m instanceof osuBase.ModScoreV2)
2503
+ const ncircles = this.mods.has(osuBase.ModScoreV2)
2506
2504
  ? this.totalHits - this.difficultyAttributes.spinnerCount
2507
2505
  : this.difficultyAttributes.hitCircleCount;
2508
2506
  // Bonus for many hitcircles - it's harder to keep good accuracy up for longer.
@@ -2514,7 +2512,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2514
2512
  Math.exp(-(this.difficultyAttributes.rhythmDifficulty - 1) / 2));
2515
2513
  // Penalize accuracy pp after the first miss.
2516
2514
  accuracyValue *= Math.pow(0.97, Math.max(0, this.effectiveMissCount - 1));
2517
- if (this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
2515
+ if (this.mods.has(osuBase.ModFlashlight)) {
2518
2516
  accuracyValue *= 1.02;
2519
2517
  }
2520
2518
  return accuracyValue;
@@ -2523,7 +2521,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2523
2521
  * Calculates the flashlight performance value of the beatmap.
2524
2522
  */
2525
2523
  calculateFlashlightValue() {
2526
- if (!this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
2524
+ if (!this.mods.has(osuBase.ModFlashlight)) {
2527
2525
  return 0;
2528
2526
  }
2529
2527
  let flashlightValue = Math.pow(this.difficultyAttributes.flashlightDifficulty, 1.6) * 25;
@@ -2746,7 +2744,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2746
2744
  }
2747
2745
  getConvertedHitWindow() {
2748
2746
  const hitWindow300 = new osuBase.OsuHitWindow(this.difficultyAttributes.overallDifficulty).greatWindow;
2749
- if (this.mods.some((m) => m instanceof osuBase.ModPrecise)) {
2747
+ if (this.mods.has(osuBase.ModPrecise)) {
2750
2748
  return new osuBase.PreciseDroidHitWindow(osuBase.PreciseDroidHitWindow.greatWindowToOD(hitWindow300 * this.difficultyAttributes.clockRate));
2751
2749
  }
2752
2750
  else {
@@ -2769,37 +2767,6 @@ class DroidPerformanceCalculator extends PerformanceCalculator {
2769
2767
  }
2770
2768
  }
2771
2769
 
2772
- /**
2773
- * Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
2774
- * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
2775
- */
2776
- class OsuSkill extends StrainSkill {
2777
- difficultyValue() {
2778
- const strains = this.strainPeaks.slice().sort((a, b) => b - a);
2779
- if (this.reducedSectionCount > 0) {
2780
- // We are reducing the highest strains first to account for extreme difficulty spikes.
2781
- for (let i = 0; i < Math.min(strains.length, this.reducedSectionCount); ++i) {
2782
- const scale = Math.log10(osuBase.Interpolation.lerp(1, 10, osuBase.MathUtils.clamp(i / this.reducedSectionCount, 0, 1)));
2783
- strains[i] *= osuBase.Interpolation.lerp(this.reducedSectionBaseline, 1, scale);
2784
- }
2785
- strains.sort((a, b) => b - a);
2786
- }
2787
- // Difficulty is the weighted sum of the highest strains from every section.
2788
- // We're sorting from highest to lowest strain.
2789
- this.difficulty = 0;
2790
- let weight = 1;
2791
- for (const strain of strains) {
2792
- const addition = strain * weight;
2793
- if (this.difficulty + addition === this.difficulty) {
2794
- break;
2795
- }
2796
- this.difficulty += addition;
2797
- weight *= this.decayWeight;
2798
- }
2799
- return this.difficulty;
2800
- }
2801
- }
2802
-
2803
2770
  /**
2804
2771
  * Represents an osu!standard hit object with difficulty calculation values.
2805
2772
  */
@@ -2966,6 +2933,37 @@ OsuAimEvaluator.sliderMultiplier = 1.35;
2966
2933
  OsuAimEvaluator.velocityChangeMultiplier = 0.75;
2967
2934
  OsuAimEvaluator.wiggleMultiplier = 1.02;
2968
2935
 
2936
+ /**
2937
+ * Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
2938
+ * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
2939
+ */
2940
+ class OsuSkill extends StrainSkill {
2941
+ difficultyValue() {
2942
+ const strains = this.strainPeaks.slice().sort((a, b) => b - a);
2943
+ if (this.reducedSectionCount > 0) {
2944
+ // We are reducing the highest strains first to account for extreme difficulty spikes.
2945
+ for (let i = 0; i < Math.min(strains.length, this.reducedSectionCount); ++i) {
2946
+ const scale = Math.log10(osuBase.Interpolation.lerp(1, 10, osuBase.MathUtils.clamp(i / this.reducedSectionCount, 0, 1)));
2947
+ strains[i] *= osuBase.Interpolation.lerp(this.reducedSectionBaseline, 1, scale);
2948
+ }
2949
+ strains.sort((a, b) => b - a);
2950
+ }
2951
+ // Difficulty is the weighted sum of the highest strains from every section.
2952
+ // We're sorting from highest to lowest strain.
2953
+ this.difficulty = 0;
2954
+ let weight = 1;
2955
+ for (const strain of strains) {
2956
+ const addition = strain * weight;
2957
+ if (this.difficulty + addition === this.difficulty) {
2958
+ break;
2959
+ }
2960
+ this.difficulty += addition;
2961
+ weight *= this.decayWeight;
2962
+ }
2963
+ return this.difficulty;
2964
+ }
2965
+ }
2966
+
2969
2967
  /**
2970
2968
  * Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
2971
2969
  */
@@ -3107,7 +3105,7 @@ class OsuFlashlightEvaluator {
3107
3105
  }
3108
3106
  result = Math.pow(smallDistNerf * result, 2);
3109
3107
  // Additional bonus for Hidden due to there being no approach circles.
3110
- if (mods.some((m) => m instanceof osuBase.ModHidden)) {
3108
+ if (mods.has(osuBase.ModHidden)) {
3111
3109
  result *= 1 + this.hiddenBonus;
3112
3110
  }
3113
3111
  // Nerf patterns with repeated angles.
@@ -3356,7 +3354,7 @@ class OsuSpeedEvaluator {
3356
3354
  // Max distance bonus is 1 * `distance_multiplier` at single_spacing_threshold
3357
3355
  let distanceBonus = Math.pow(distance / this.SINGLE_SPACING_THRESHOLD, 3.95) *
3358
3356
  this.DISTANCE_MULTIPLIER;
3359
- if (mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3357
+ if (mods.has(osuBase.ModAutopilot)) {
3360
3358
  distanceBonus = 0;
3361
3359
  }
3362
3360
  // Base difficulty with all bonuses
@@ -3446,7 +3444,7 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3446
3444
  }
3447
3445
  createDifficultyAttributes(beatmap, skills) {
3448
3446
  const attributes = new OsuDifficultyAttributes();
3449
- attributes.mods = beatmap.mods.slice();
3447
+ attributes.mods = beatmap.mods;
3450
3448
  attributes.maxCombo = beatmap.maxCombo;
3451
3449
  attributes.clockRate = beatmap.speedMultiplier;
3452
3450
  attributes.hitCircleCount = beatmap.hitObjects.circles;
@@ -3455,12 +3453,12 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3455
3453
  this.populateAimAttributes(attributes, skills);
3456
3454
  this.populateSpeedAttributes(attributes, skills);
3457
3455
  this.populateFlashlightAttributes(attributes, skills);
3458
- if (attributes.mods.some((m) => m instanceof osuBase.ModRelax)) {
3456
+ if (attributes.mods.has(osuBase.ModRelax)) {
3459
3457
  attributes.aimDifficulty *= 0.9;
3460
3458
  attributes.speedDifficulty = 0;
3461
3459
  attributes.flashlightDifficulty *= 0.7;
3462
3460
  }
3463
- else if (attributes.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3461
+ else if (attributes.mods.has(osuBase.ModAutopilot)) {
3464
3462
  attributes.aimDifficulty = 0;
3465
3463
  attributes.speedDifficulty *= 0.5;
3466
3464
  attributes.flashlightDifficulty *= 0.4;
@@ -3507,14 +3505,14 @@ class OsuDifficultyCalculator extends DifficultyCalculator {
3507
3505
  createSkills(beatmap) {
3508
3506
  const { mods } = beatmap;
3509
3507
  const skills = [];
3510
- if (!mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3508
+ if (!mods.has(osuBase.ModAutopilot)) {
3511
3509
  skills.push(new OsuAim(mods, true));
3512
3510
  skills.push(new OsuAim(mods, false));
3513
3511
  }
3514
- if (!mods.some((m) => m instanceof osuBase.ModRelax)) {
3512
+ if (!mods.has(osuBase.ModRelax)) {
3515
3513
  skills.push(new OsuSpeed(mods));
3516
3514
  }
3517
- if (mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3515
+ if (mods.has(osuBase.ModFlashlight)) {
3518
3516
  skills.push(new OsuFlashlight(mods));
3519
3517
  }
3520
3518
  return skills;
@@ -3615,7 +3613,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3615
3613
  * Calculates the aim performance value of the beatmap.
3616
3614
  */
3617
3615
  calculateAimValue() {
3618
- if (this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3616
+ if (this.mods.has(osuBase.ModAutopilot)) {
3619
3617
  return 0;
3620
3618
  }
3621
3619
  let aimValue = this.baseValue(this.difficultyAttributes.aimDifficulty);
@@ -3635,7 +3633,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3635
3633
  }
3636
3634
  aimValue *= this.calculateStrainBasedMissPenalty(this.difficultyAttributes.aimDifficultStrainCount);
3637
3635
  const calculatedAR = this.difficultyAttributes.approachRate;
3638
- if (!this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3636
+ if (!this.mods.has(osuBase.ModRelax)) {
3639
3637
  // AR scaling
3640
3638
  let arFactor = 0;
3641
3639
  if (calculatedAR > 10.33) {
@@ -3648,7 +3646,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3648
3646
  aimValue *= 1 + arFactor * lengthBonus;
3649
3647
  }
3650
3648
  // We want to give more reward for lower AR when it comes to aim and HD. This nerfs high AR and buffs lower AR.
3651
- if (this.mods.some((m) => m instanceof osuBase.ModHidden || m instanceof osuBase.ModTraceable)) {
3649
+ if (this.mods.has(osuBase.ModHidden) || this.mods.has(osuBase.ModTraceable)) {
3652
3650
  aimValue *= 1 + 0.04 * (12 - calculatedAR);
3653
3651
  }
3654
3652
  // Scale the aim value with slider factor to nerf very likely dropped sliderends.
@@ -3664,7 +3662,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3664
3662
  * Calculates the speed performance value of the beatmap.
3665
3663
  */
3666
3664
  calculateSpeedValue() {
3667
- if (this.mods.some((m) => m instanceof osuBase.ModRelax) ||
3665
+ if (this.mods.has(osuBase.ModRelax) ||
3668
3666
  this.speedDeviation === Number.POSITIVE_INFINITY) {
3669
3667
  return 0;
3670
3668
  }
@@ -3678,12 +3676,11 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3678
3676
  speedValue *= this.calculateStrainBasedMissPenalty(this.difficultyAttributes.speedDifficultStrainCount);
3679
3677
  // AR scaling
3680
3678
  const calculatedAR = this.difficultyAttributes.approachRate;
3681
- if (calculatedAR > 10.33 &&
3682
- !this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3679
+ if (calculatedAR > 10.33 && !this.mods.has(osuBase.ModAutopilot)) {
3683
3680
  // Buff for longer maps with high AR.
3684
3681
  speedValue *= 1 + 0.3 * (calculatedAR - 10.33) * lengthBonus;
3685
3682
  }
3686
- if (this.mods.some((m) => m instanceof osuBase.ModHidden || m instanceof osuBase.ModTraceable)) {
3683
+ if (this.mods.has(osuBase.ModHidden) || this.mods.has(osuBase.ModTraceable)) {
3687
3684
  speedValue *= 1 + 0.04 * (12 - calculatedAR);
3688
3685
  }
3689
3686
  // Calculate accuracy assuming the worst case scenario.
@@ -3715,10 +3712,10 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3715
3712
  * Calculates the accuracy performance value of the beatmap.
3716
3713
  */
3717
3714
  calculateAccuracyValue() {
3718
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3715
+ if (this.mods.has(osuBase.ModRelax)) {
3719
3716
  return 0;
3720
3717
  }
3721
- const ncircles = this.mods.some((m) => m instanceof osuBase.ModScoreV2)
3718
+ const ncircles = this.mods.has(osuBase.ModScoreV2)
3722
3719
  ? this.totalHits - this.difficultyAttributes.spinnerCount
3723
3720
  : this.difficultyAttributes.hitCircleCount;
3724
3721
  if (ncircles === 0) {
@@ -3733,10 +3730,10 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3733
3730
  2.83;
3734
3731
  // Bonus for many hitcircles - it's harder to keep good accuracy up for longer
3735
3732
  accuracyValue *= Math.min(1.15, Math.pow(ncircles / 1000, 0.3));
3736
- if (this.mods.some((m) => m instanceof osuBase.ModHidden || m instanceof osuBase.ModTraceable)) {
3733
+ if (this.mods.has(osuBase.ModHidden) || this.mods.has(osuBase.ModTraceable)) {
3737
3734
  accuracyValue *= 1.08;
3738
3735
  }
3739
- if (this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3736
+ if (this.mods.has(osuBase.ModFlashlight)) {
3740
3737
  accuracyValue *= 1.02;
3741
3738
  }
3742
3739
  return accuracyValue;
@@ -3745,7 +3742,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
3745
3742
  * Calculates the flashlight performance value of the beatmap.
3746
3743
  */
3747
3744
  calculateFlashlightValue() {
3748
- if (!this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3745
+ if (!this.mods.has(osuBase.ModFlashlight)) {
3749
3746
  return 0;
3750
3747
  }
3751
3748
  let flashlightValue = Math.pow(this.difficultyAttributes.flashlightDifficulty, 2) * 25;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rian8337/osu-rebalance-difficulty-calculator",
3
- "version": "4.0.0-beta.56",
3
+ "version": "4.0.0-beta.58",
4
4
  "description": "A module for calculating osu!standard beatmap difficulty and performance value with respect to the latest osu!lazer difficulty and performance algorithm.",
5
5
  "keywords": [
6
6
  "osu",
@@ -33,10 +33,10 @@
33
33
  "url": "https://github.com/Rian8337/osu-droid-module/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@rian8337/osu-base": "^4.0.0-beta.56"
36
+ "@rian8337/osu-base": "^4.0.0-beta.58"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "330ca82968253d60fd3cb8ed0d769718028a8688"
41
+ "gitHead": "4a5f36a02a668f15fa22b558eeeeb13237105212"
42
42
  }
@@ -1,4 +1,4 @@
1
- import { Mod, SerializedMod, PlaceableHitObject, Modes, PlayableBeatmap, Beatmap, DroidPlayableBeatmap, Accuracy, OsuPlayableBeatmap } from '@rian8337/osu-base';
1
+ import { ModMap, SerializedMod, PlaceableHitObject, Modes, PlayableBeatmap, Mod, Beatmap, DroidPlayableBeatmap, Accuracy, OsuPlayableBeatmap } from '@rian8337/osu-base';
2
2
 
3
3
  /**
4
4
  * Holds data that can be used to calculate performance points.
@@ -7,7 +7,7 @@ interface IDifficultyAttributes {
7
7
  /**
8
8
  * The mods which were applied to the beatmap.
9
9
  */
10
- mods: Mod[];
10
+ mods: ModMap;
11
11
  /**
12
12
  * The combined star rating of all skills.
13
13
  */
@@ -73,7 +73,7 @@ interface IDifficultyAttributes {
73
73
  /**
74
74
  * Represents difficulty attributes that can be cached.
75
75
  */
76
- type CacheableDifficultyAttributes<T extends IDifficultyAttributes> = Omit<T, "mods"> & {
76
+ type CacheableDifficultyAttributes<T extends IDifficultyAttributes> = Omit<T, "mods" | "toCacheableAttributes"> & {
77
77
  /**
78
78
  * The mods which were applied to the beatmap.
79
79
  */
@@ -84,7 +84,7 @@ type CacheableDifficultyAttributes<T extends IDifficultyAttributes> = Omit<T, "m
84
84
  * Holds data that can be used to calculate performance points.
85
85
  */
86
86
  declare abstract class DifficultyAttributes implements IDifficultyAttributes {
87
- mods: Mod[];
87
+ mods: ModMap;
88
88
  starRating: number;
89
89
  maxCombo: number;
90
90
  aimDifficulty: number;
@@ -104,7 +104,7 @@ declare abstract class DifficultyAttributes implements IDifficultyAttributes {
104
104
  *
105
105
  * @returns The cacheable attributes.
106
106
  */
107
- toCacheableAttributes(): CacheableDifficultyAttributes<IDifficultyAttributes>;
107
+ toCacheableAttributes(): CacheableDifficultyAttributes<this>;
108
108
  /**
109
109
  * Returns a string representation of the difficulty attributes.
110
110
  */
@@ -262,7 +262,7 @@ declare abstract class DifficultyHitObject {
262
262
  * @param mods The mods used.
263
263
  * @returns The opacity of the hitobject at the given time.
264
264
  */
265
- opacityAt(time: number, mods: readonly Mod[]): number;
265
+ opacityAt(time: number, mods: ModMap): number;
266
266
  /**
267
267
  * How possible is it to doubletap this object together with the next one and get perfect
268
268
  * judgement in range from 0 to 1.
@@ -283,8 +283,8 @@ declare abstract class Skill {
283
283
  /**
284
284
  * The mods that this skill processes.
285
285
  */
286
- protected readonly mods: readonly Mod[];
287
- constructor(mods: readonly Mod[]);
286
+ protected readonly mods: ModMap;
287
+ constructor(mods: ModMap);
288
288
  /**
289
289
  * Calculates the strain value of a hitobject and stores the value in it.
290
290
  * This value is affected by previously processed objects.
@@ -435,7 +435,7 @@ declare abstract class DifficultyCalculator<TBeatmap extends PlayableBeatmap, TH
435
435
  * @param mods The `Mod`s to apply to the beatmap. Defaults to No Mod.
436
436
  * @returns A `DifficultyAttributes` object describing the difficulty of the `Beatmap`.
437
437
  */
438
- calculate(beatmap: Beatmap, mods?: Mod[]): TAttributes;
438
+ calculate(beatmap: Beatmap, mods?: ModMap): TAttributes;
439
439
  /**
440
440
  * Obtains the strain peaks of a `PlayableBeatmap`.
441
441
  *
@@ -450,7 +450,7 @@ declare abstract class DifficultyCalculator<TBeatmap extends PlayableBeatmap, TH
450
450
  * @param mods The `Mod`s to apply to the beatmap. Defaults to No Mod.
451
451
  * @returns The strain peaks of the `Beatmap`.
452
452
  */
453
- calculateStrainPeaks(beatmap: Beatmap, mods: Mod[]): StrainPeaks;
453
+ calculateStrainPeaks(beatmap: Beatmap, mods?: ModMap): StrainPeaks;
454
454
  /**
455
455
  * Creates the `Skill`s to calculate the difficulty of a `PlayableBeatmap`.
456
456
  *
@@ -487,7 +487,7 @@ declare abstract class DifficultyCalculator<TBeatmap extends PlayableBeatmap, TH
487
487
  * @param mods The `Mod`s to apply to the `Beatmap`.
488
488
  * @returns The `PlayableBeatmap`.
489
489
  */
490
- protected abstract createPlayableBeatmap(beatmap: Beatmap, mods: Mod[]): TBeatmap;
490
+ protected abstract createPlayableBeatmap(beatmap: Beatmap, mods?: ModMap): TBeatmap;
491
491
  /**
492
492
  * Calculates the base rating of a `Skill`.
493
493
  *
@@ -523,27 +523,6 @@ interface DifficultSlider {
523
523
  readonly difficultyRating: number;
524
524
  }
525
525
 
526
- /**
527
- * Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
528
- * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
529
- */
530
- declare abstract class DroidSkill extends StrainSkill {
531
- /**
532
- * The bonus multiplier that is given for a sequence of notes of equal difficulty.
533
- */
534
- protected abstract readonly starsPerDouble: number;
535
- process(current: DifficultyHitObject): void;
536
- difficultyValue(): number;
537
- /**
538
- * Gets the strain of a hitobject.
539
- *
540
- * @param current The hitobject to get the strain from.
541
- * @returns The strain of the hitobject.
542
- */
543
- protected abstract getObjectStrain(current: DifficultyHitObject): number;
544
- protected calculateCurrentSectionStart(current: DifficultyHitObject): number;
545
- }
546
-
547
526
  /**
548
527
  * Represents an osu!droid hit object with difficulty calculation values.
549
528
  */
@@ -607,7 +586,7 @@ declare class DroidDifficultyHitObject extends DifficultyHitObject {
607
586
  */
608
587
  constructor(object: PlaceableHitObject, lastObject: PlaceableHitObject | null, lastLastObject: PlaceableHitObject | null, difficultyHitObjects: readonly DifficultyHitObject[], clockRate: number, index: number);
609
588
  computeProperties(clockRate: number, hitObjects: readonly PlaceableHitObject[]): void;
610
- opacityAt(time: number, mods: readonly Mod[]): number;
589
+ opacityAt(time: number, mods: ModMap): number;
611
590
  previous(backwardsIndex: number): this | null;
612
591
  next(forwardsIndex: number): this | null;
613
592
  /**
@@ -627,6 +606,27 @@ declare class DroidDifficultyHitObject extends DifficultyHitObject {
627
606
  private applyToOverlappingFactor;
628
607
  }
629
608
 
609
+ /**
610
+ * Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
611
+ * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
612
+ */
613
+ declare abstract class DroidSkill extends StrainSkill {
614
+ /**
615
+ * The bonus multiplier that is given for a sequence of notes of equal difficulty.
616
+ */
617
+ protected abstract readonly starsPerDouble: number;
618
+ process(current: DifficultyHitObject): void;
619
+ difficultyValue(): number;
620
+ /**
621
+ * Gets the strain of a hitobject.
622
+ *
623
+ * @param current The hitobject to get the strain from.
624
+ * @returns The strain of the hitobject.
625
+ */
626
+ protected abstract getObjectStrain(current: DifficultyHitObject): number;
627
+ protected calculateCurrentSectionStart(current: DifficultyHitObject): number;
628
+ }
629
+
630
630
  /**
631
631
  * Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
632
632
  */
@@ -639,7 +639,7 @@ declare class DroidAim extends DroidSkill {
639
639
  private currentAimStrain;
640
640
  private readonly sliderStrains;
641
641
  readonly withSliders: boolean;
642
- constructor(mods: readonly Mod[], withSliders: boolean);
642
+ constructor(mods: ModMap, withSliders: boolean);
643
643
  /**
644
644
  * Obtains the amount of sliders that are considered difficult in terms of relative strain.
645
645
  */
@@ -833,7 +833,7 @@ declare class DroidDifficultyCalculator extends DifficultyCalculator<DroidPlayab
833
833
  constructor();
834
834
  retainDifficultyAdjustmentMods(mods: Mod[]): Mod[];
835
835
  protected createDifficultyAttributes(beatmap: DroidPlayableBeatmap, skills: Skill[], objects: DroidDifficultyHitObject[]): ExtendedDroidDifficultyAttributes;
836
- protected createPlayableBeatmap(beatmap: Beatmap, mods: Mod[]): DroidPlayableBeatmap;
836
+ protected createPlayableBeatmap(beatmap: Beatmap, mods?: ModMap): DroidPlayableBeatmap;
837
837
  protected createDifficultyHitObjects(beatmap: DroidPlayableBeatmap): DroidDifficultyHitObject[];
838
838
  protected createSkills(beatmap: DroidPlayableBeatmap): DroidSkill[];
839
839
  protected createStrainPeakSkills(beatmap: DroidPlayableBeatmap): StrainSkill[];
@@ -855,7 +855,7 @@ declare class DroidFlashlight extends DroidSkill {
855
855
  private readonly skillMultiplier;
856
856
  private currentFlashlightStrain;
857
857
  readonly withSliders: boolean;
858
- constructor(mods: readonly Mod[], withSliders: boolean);
858
+ constructor(mods: ModMap, withSliders: boolean);
859
859
  protected strainValueAt(current: DroidDifficultyHitObject): number;
860
860
  protected calculateInitialStrain(time: number, current: DifficultyHitObject): number;
861
861
  protected getObjectStrain(): number;
@@ -887,7 +887,7 @@ declare abstract class DroidFlashlightEvaluator {
887
887
  * @param mods The mods used.
888
888
  * @param withSliders Whether to take slider difficulty into account.
889
889
  */
890
- static evaluateDifficultyOf(current: DroidDifficultyHitObject, mods: readonly Mod[], withSliders: boolean): number;
890
+ static evaluateDifficultyOf(current: DroidDifficultyHitObject, mods: ModMap, withSliders: boolean): number;
891
891
  }
892
892
 
893
893
  /**
@@ -943,7 +943,7 @@ declare abstract class PerformanceCalculator<T extends IDifficultyAttributes> {
943
943
  /**
944
944
  * The mods that were used.
945
945
  */
946
- protected readonly mods: Mod[];
946
+ protected readonly mods: ModMap;
947
947
  /**
948
948
  * The global multiplier to be applied to the final performance value.
949
949
  *
@@ -1032,7 +1032,7 @@ declare abstract class PerformanceCalculator<T extends IDifficultyAttributes> {
1032
1032
  /**
1033
1033
  * A performance points calculator that calculates performance points for osu!droid gamemode.
1034
1034
  */
1035
- declare class DroidPerformanceCalculator extends PerformanceCalculator<DroidDifficultyAttributes> {
1035
+ declare class DroidPerformanceCalculator extends PerformanceCalculator<IDroidDifficultyAttributes> {
1036
1036
  /**
1037
1037
  * The aim performance value.
1038
1038
  */
@@ -1198,7 +1198,7 @@ declare class DroidRhythm extends DroidSkill {
1198
1198
  private readonly useSliderAccuracy;
1199
1199
  private currentRhythmStrain;
1200
1200
  private currentRhythmMultiplier;
1201
- constructor(mods: readonly Mod[]);
1201
+ constructor(mods: ModMap);
1202
1202
  protected strainValueAt(current: DroidDifficultyHitObject): number;
1203
1203
  protected calculateInitialStrain(time: number, current: DroidDifficultyHitObject): number;
1204
1204
  protected getObjectStrain(): number;
@@ -1241,7 +1241,7 @@ declare class DroidTap extends DroidSkill {
1241
1241
  get objectDeltaTimes(): readonly number[];
1242
1242
  readonly considerCheesability: boolean;
1243
1243
  private readonly strainTimeCap?;
1244
- constructor(mods: readonly Mod[], considerCheesability: boolean, strainTimeCap?: number);
1244
+ constructor(mods: ModMap, considerCheesability: boolean, strainTimeCap?: number);
1245
1245
  /**
1246
1246
  * The amount of notes that are relevant to the difficulty.
1247
1247
  */
@@ -1291,7 +1291,7 @@ declare class DroidVisual extends DroidSkill {
1291
1291
  private currentRhythmMultiplier;
1292
1292
  private readonly skillMultiplier;
1293
1293
  readonly withSliders: boolean;
1294
- constructor(mods: readonly Mod[], withSliders: boolean);
1294
+ constructor(mods: ModMap, withSliders: boolean);
1295
1295
  protected strainValueAt(current: DroidDifficultyHitObject): number;
1296
1296
  protected calculateInitialStrain(time: number, current: DroidDifficultyHitObject): number;
1297
1297
  protected getObjectStrain(): number;
@@ -1317,7 +1317,7 @@ declare abstract class DroidVisualEvaluator {
1317
1317
  * @param mods The mods used.
1318
1318
  * @param withSliders Whether to take slider difficulty into account.
1319
1319
  */
1320
- static evaluateDifficultyOf(current: DroidDifficultyHitObject, mods: readonly Mod[], withSliders: boolean): number;
1320
+ static evaluateDifficultyOf(current: DroidDifficultyHitObject, mods: ModMap, withSliders: boolean): number;
1321
1321
  }
1322
1322
 
1323
1323
  /**
@@ -1340,18 +1340,6 @@ interface IOsuDifficultyAttributes extends IDifficultyAttributes {
1340
1340
  speedDifficultStrainCount: number;
1341
1341
  }
1342
1342
 
1343
- /**
1344
- * Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
1345
- * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
1346
- */
1347
- declare abstract class OsuSkill extends StrainSkill {
1348
- /**
1349
- * The weight by which each strain value decays.
1350
- */
1351
- protected abstract readonly decayWeight: number;
1352
- difficultyValue(): number;
1353
- }
1354
-
1355
1343
  /**
1356
1344
  * Represents an osu!standard hit object with difficulty calculation values.
1357
1345
  */
@@ -1369,6 +1357,18 @@ declare class OsuDifficultyHitObject extends DifficultyHitObject {
1369
1357
  protected get scalingFactor(): number;
1370
1358
  }
1371
1359
 
1360
+ /**
1361
+ * Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
1362
+ * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
1363
+ */
1364
+ declare abstract class OsuSkill extends StrainSkill {
1365
+ /**
1366
+ * The weight by which each strain value decays.
1367
+ */
1368
+ protected abstract readonly decayWeight: number;
1369
+ difficultyValue(): number;
1370
+ }
1371
+
1372
1372
  /**
1373
1373
  * Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
1374
1374
  */
@@ -1381,7 +1381,7 @@ declare class OsuAim extends OsuSkill {
1381
1381
  private readonly skillMultiplier;
1382
1382
  private readonly sliderStrains;
1383
1383
  readonly withSliders: boolean;
1384
- constructor(mods: readonly Mod[], withSliders: boolean);
1384
+ constructor(mods: ModMap, withSliders: boolean);
1385
1385
  /**
1386
1386
  * Obtains the amount of sliders that are considered difficult in terms of relative strain.
1387
1387
  */
@@ -1438,7 +1438,7 @@ declare class OsuDifficultyCalculator extends DifficultyCalculator<OsuPlayableBe
1438
1438
  constructor();
1439
1439
  retainDifficultyAdjustmentMods(mods: Mod[]): Mod[];
1440
1440
  protected createDifficultyAttributes(beatmap: OsuPlayableBeatmap, skills: Skill[]): OsuDifficultyAttributes;
1441
- protected createPlayableBeatmap(beatmap: Beatmap, mods: Mod[]): OsuPlayableBeatmap;
1441
+ protected createPlayableBeatmap(beatmap: Beatmap, mods?: ModMap): OsuPlayableBeatmap;
1442
1442
  protected createDifficultyHitObjects(beatmap: OsuPlayableBeatmap): OsuDifficultyHitObject[];
1443
1443
  protected createSkills(beatmap: OsuPlayableBeatmap): OsuSkill[];
1444
1444
  protected createStrainPeakSkills(beatmap: OsuPlayableBeatmap): StrainSkill[];
@@ -1484,13 +1484,13 @@ declare abstract class OsuFlashlightEvaluator {
1484
1484
  * @param current The current object.
1485
1485
  * @param mods The mods used.
1486
1486
  */
1487
- static evaluateDifficultyOf(current: OsuDifficultyHitObject, mods: readonly Mod[]): number;
1487
+ static evaluateDifficultyOf(current: OsuDifficultyHitObject, mods: ModMap): number;
1488
1488
  }
1489
1489
 
1490
1490
  /**
1491
1491
  * A performance points calculator that calculates performance points for osu!standard gamemode.
1492
1492
  */
1493
- declare class OsuPerformanceCalculator extends PerformanceCalculator<OsuDifficultyAttributes> {
1493
+ declare class OsuPerformanceCalculator extends PerformanceCalculator<IOsuDifficultyAttributes> {
1494
1494
  /**
1495
1495
  * The aim performance value.
1496
1496
  */
@@ -1620,7 +1620,7 @@ declare abstract class OsuSpeedEvaluator {
1620
1620
  * @param current The current object.
1621
1621
  * @param mods The mods applied.
1622
1622
  */
1623
- static evaluateDifficultyOf(current: OsuDifficultyHitObject, mods: readonly Mod[]): number;
1623
+ static evaluateDifficultyOf(current: OsuDifficultyHitObject, mods: ModMap): number;
1624
1624
  }
1625
1625
 
1626
1626
  export { type CacheableDifficultyAttributes, type DifficultSlider, DifficultyAttributes, DifficultyCalculator, DifficultyHitObject, DroidAim, DroidAimEvaluator, DroidDifficultyAttributes, DroidDifficultyCalculator, DroidDifficultyHitObject, DroidFlashlight, DroidFlashlightEvaluator, DroidPerformanceCalculator, DroidRhythm, DroidRhythmEvaluator, DroidTap, DroidTapEvaluator, DroidVisual, DroidVisualEvaluator, ExtendedDroidDifficultyAttributes, type HighStrainSection, type IDifficultyAttributes, type IDroidDifficultyAttributes, type IExtendedDroidDifficultyAttributes, type IOsuDifficultyAttributes, OsuAim, OsuAimEvaluator, OsuDifficultyAttributes, OsuDifficultyCalculator, OsuDifficultyHitObject, OsuFlashlight, OsuFlashlightEvaluator, OsuPerformanceCalculator, OsuRhythmEvaluator, OsuSpeed, OsuSpeedEvaluator, type PerformanceCalculationOptions, PerformanceCalculator, type StrainPeaks };