@rian8337/osu-base 4.0.0-beta.26 → 4.0.0-beta.28

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
@@ -7700,7 +7700,7 @@ class Mod {
7700
7700
  * Whether this `Mod`s can be applied to a track's playback rate.
7701
7701
  */
7702
7702
  isApplicableToTrackRate() {
7703
- return "trackRateMultiplier" in this;
7703
+ return "applyToRate" in this;
7704
7704
  }
7705
7705
  }
7706
7706
 
@@ -7755,7 +7755,9 @@ class ModDoubleTime extends Mod {
7755
7755
  this.pcRanked = true;
7756
7756
  this.pcScoreMultiplier = 1.12;
7757
7757
  this.bitwise = 1 << 6;
7758
- this.trackRateMultiplier = 1.5;
7758
+ }
7759
+ applyToRate(rate) {
7760
+ return rate * 1.5;
7759
7761
  }
7760
7762
  }
7761
7763
 
@@ -7824,7 +7826,9 @@ class ModHalfTime extends Mod {
7824
7826
  this.pcRanked = true;
7825
7827
  this.pcScoreMultiplier = 0.3;
7826
7828
  this.bitwise = 1 << 8;
7827
- this.trackRateMultiplier = 0.75;
7829
+ }
7830
+ applyToRate(rate) {
7831
+ return rate * 0.75;
7828
7832
  }
7829
7833
  }
7830
7834
 
@@ -7943,7 +7947,9 @@ class ModNightCore extends Mod {
7943
7947
  this.pcRanked = true;
7944
7948
  this.pcScoreMultiplier = 1.12;
7945
7949
  this.bitwise = 1 << 9;
7946
- this.trackRateMultiplier = 1.5;
7950
+ }
7951
+ applyToRate(rate, oldStatistics) {
7952
+ return rate * (oldStatistics ? 1.39 : 1.5);
7947
7953
  }
7948
7954
  }
7949
7955
 
@@ -8119,6 +8125,9 @@ class ModSpeedUp extends Mod {
8119
8125
  this.isDroidLegacyMod = true;
8120
8126
  this.trackRateMultiplier = 1.25;
8121
8127
  }
8128
+ applyToRate(rate) {
8129
+ return rate * 1.25;
8130
+ }
8122
8131
  }
8123
8132
 
8124
8133
  /**
@@ -8280,30 +8289,58 @@ class ModUtil {
8280
8289
  * @param mode The game mode to apply the `Mod`s for.
8281
8290
  * @param mods The selected `Mod`s.
8282
8291
  * @param customSpeedMultiplier The custom speed multiplier to apply.
8292
+ * @param withRateChange Whether to apply rate changes.
8293
+ * @param oldStatistics Whether to enforce old statistics. Some `Mod`s behave differently with this flag.
8283
8294
  */
8284
- static applyModsToBeatmapDifficulty(difficulty, mode, mods, customSpeedMultiplier = 1) {
8295
+ static applyModsToBeatmapDifficulty(difficulty, mode, mods, customSpeedMultiplier = 1, withRateChange = false, oldStatistics = false) {
8285
8296
  for (const mod of mods) {
8286
8297
  if (mod.isApplicableToDifficulty()) {
8287
8298
  mod.applyToDifficulty(mode, difficulty);
8288
8299
  }
8289
8300
  }
8301
+ let rate = 1;
8290
8302
  for (const mod of mods) {
8291
8303
  if (mod.isApplicableToDifficultyWithSettings()) {
8292
8304
  mod.applyToDifficultyWithSettings(mode, difficulty, mods, customSpeedMultiplier);
8293
8305
  }
8306
+ if (mod.isApplicableToTrackRate()) {
8307
+ rate = mod.applyToRate(rate, oldStatistics);
8308
+ }
8309
+ }
8310
+ if (!withRateChange) {
8311
+ return;
8312
+ }
8313
+ // Apply rate adjustments
8314
+ const preempt = BeatmapDifficulty.difficultyRange(difficulty.ar, HitObject.preemptMax, HitObject.preemptMid, HitObject.preemptMin) / rate;
8315
+ difficulty.ar = BeatmapDifficulty.inverseDifficultyRange(preempt, HitObject.preemptMax, HitObject.preemptMin, HitObject.preemptMin);
8316
+ switch (mode) {
8317
+ case exports.Modes.droid: {
8318
+ const isPrecise = mods.some((m) => m instanceof ModPrecise);
8319
+ const hitWindow = new DroidHitWindow(difficulty.od);
8320
+ const greatWindow = hitWindow.hitWindowFor300(isPrecise) / rate;
8321
+ difficulty.od = DroidHitWindow.hitWindow300ToOD(greatWindow, isPrecise);
8322
+ break;
8323
+ }
8324
+ case exports.Modes.osu: {
8325
+ const hitWindow = new OsuHitWindow(difficulty.od);
8326
+ const greatWindow = hitWindow.hitWindowFor300() / rate;
8327
+ difficulty.od = OsuHitWindow.hitWindow300ToOD(greatWindow);
8328
+ break;
8329
+ }
8294
8330
  }
8295
8331
  }
8296
8332
  /**
8297
8333
  * Calculates the rate for the track with the selected `Mod`s.
8298
8334
  *
8299
8335
  * @param mods The list of selected `Mod`s.
8336
+ * @param oldStatistics Whether to enforce old statistics. Some `Mod`s behave differently with this flag.
8300
8337
  * @returns The rate with `Mod`s.
8301
8338
  */
8302
- static calculateRateWithMods(mods) {
8339
+ static calculateRateWithMods(mods, oldStatistics) {
8303
8340
  let rate = 1;
8304
8341
  for (const mod of mods) {
8305
8342
  if (mod.isApplicableToTrackRate()) {
8306
- rate *= mod.trackRateMultiplier;
8343
+ rate = mod.applyToRate(rate, oldStatistics);
8307
8344
  }
8308
8345
  }
8309
8346
  return rate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rian8337/osu-base",
3
- "version": "4.0.0-beta.26",
3
+ "version": "4.0.0-beta.28",
4
4
  "description": "Base module for all osu! related modules.",
5
5
  "keywords": [
6
6
  "osu",
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "1c353ee9455d80a5ca8358762f107899d64f1d5e"
45
+ "gitHead": "c442670959e9f766fab6d2e6238d7bb0e40ef869"
46
46
  }
@@ -888,9 +888,13 @@ interface IModApplicableToOsu {
888
888
  */
889
889
  interface IModApplicableToTrackRate {
890
890
  /**
891
- * The multiplier to apply to the track's playback rate.
891
+ * Returns the playback rate with this `Mod` applied.
892
+ *
893
+ * @param rate The playback rate before applying this `Mod`.
894
+ * @param oldStatistics Whether to enforce old statistics. Some `Mod`s behave differently with this flag.
895
+ * For example, `ModNightCore` would apply a 1.39 rate multiplier instead of 1.5 with this flag.
892
896
  */
893
- readonly trackRateMultiplier: number;
897
+ applyToRate(rate: number, oldStatistics?: boolean): number;
894
898
  }
895
899
 
896
900
  /**
@@ -3774,7 +3778,7 @@ declare class ModDoubleTime extends Mod implements IModApplicableToDroid, IModAp
3774
3778
  readonly pcRanked = true;
3775
3779
  readonly pcScoreMultiplier = 1.12;
3776
3780
  readonly bitwise: number;
3777
- readonly trackRateMultiplier = 1.5;
3781
+ applyToRate(rate: number): number;
3778
3782
  }
3779
3783
 
3780
3784
  /**
@@ -3821,7 +3825,7 @@ declare class ModHalfTime extends Mod implements IModApplicableToDroid, IModAppl
3821
3825
  readonly pcRanked = true;
3822
3826
  readonly pcScoreMultiplier = 0.3;
3823
3827
  readonly bitwise: number;
3824
- readonly trackRateMultiplier = 0.75;
3828
+ applyToRate(rate: number): number;
3825
3829
  }
3826
3830
 
3827
3831
  /**
@@ -3875,7 +3879,7 @@ declare class ModNightCore extends Mod implements IModApplicableToDroid, IModApp
3875
3879
  readonly pcRanked = true;
3876
3880
  readonly pcScoreMultiplier = 1.12;
3877
3881
  readonly bitwise: number;
3878
- readonly trackRateMultiplier = 1.5;
3882
+ applyToRate(rate: number, oldStatistics?: boolean): number;
3879
3883
  }
3880
3884
 
3881
3885
  /**
@@ -3989,6 +3993,7 @@ declare class ModSpeedUp extends Mod implements IModApplicableToDroid, IModAppli
3989
3993
  readonly droidString = "b";
3990
3994
  readonly isDroidLegacyMod = true;
3991
3995
  readonly trackRateMultiplier = 1.25;
3996
+ applyToRate(rate: number): number;
3992
3997
  }
3993
3998
 
3994
3999
  /**
@@ -4124,15 +4129,18 @@ declare abstract class ModUtil {
4124
4129
  * @param mode The game mode to apply the `Mod`s for.
4125
4130
  * @param mods The selected `Mod`s.
4126
4131
  * @param customSpeedMultiplier The custom speed multiplier to apply.
4132
+ * @param withRateChange Whether to apply rate changes.
4133
+ * @param oldStatistics Whether to enforce old statistics. Some `Mod`s behave differently with this flag.
4127
4134
  */
4128
- static applyModsToBeatmapDifficulty(difficulty: BeatmapDifficulty, mode: Modes, mods: Mod[], customSpeedMultiplier?: number): void;
4135
+ static applyModsToBeatmapDifficulty(difficulty: BeatmapDifficulty, mode: Modes, mods: Mod[], customSpeedMultiplier?: number, withRateChange?: boolean, oldStatistics?: boolean): void;
4129
4136
  /**
4130
4137
  * Calculates the rate for the track with the selected `Mod`s.
4131
4138
  *
4132
4139
  * @param mods The list of selected `Mod`s.
4140
+ * @param oldStatistics Whether to enforce old statistics. Some `Mod`s behave differently with this flag.
4133
4141
  * @returns The rate with `Mod`s.
4134
4142
  */
4135
- static calculateRateWithMods(mods: Iterable<Mod>): number;
4143
+ static calculateRateWithMods(mods: Iterable<Mod>, oldStatistics?: boolean): number;
4136
4144
  /**
4137
4145
  * Processes parsing options.
4138
4146
  *