@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.94 → 4.0.0-beta.95

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
@@ -223,17 +223,8 @@ class Skill {
223
223
  get objectDifficulties() {
224
224
  return this._objectDifficulties;
225
225
  }
226
- /**
227
- * The start times of {@link DifficultyHitObject}s, populated by {@link Skill.process}.
228
- *
229
- * Indices correspond to {@link objectDifficulties}.
230
- */
231
- get objectTimes() {
232
- return this._objectTimes;
233
- }
234
226
  constructor(mods) {
235
227
  this._objectDifficulties = [];
236
- this._objectTimes = [];
237
228
  this.mods = mods;
238
229
  }
239
230
  /**
@@ -249,7 +240,6 @@ class Skill {
249
240
  const difficultyValue = this.processInternal(current);
250
241
  this.saveToHitObject(current, difficultyValue);
251
242
  this._objectDifficulties.push(difficultyValue);
252
- this._objectTimes.push(current.startTime);
253
243
  }
254
244
  /**
255
245
  * Saves the calculated difficulty to a {@link DifficultyHitObject}.
@@ -1015,6 +1005,7 @@ class DroidFlashlightEvaluator {
1015
1005
  * @param mods The mods used.
1016
1006
  */
1017
1007
  static evaluateDifficultyOf(current, mods) {
1008
+ var _a;
1018
1009
  if (current.object instanceof osuBase.Spinner ||
1019
1010
  // Exclude overlapping objects that can be tapped at once.
1020
1011
  current.isOverlapping(true)) {
@@ -1026,6 +1017,10 @@ class DroidFlashlightEvaluator {
1026
1017
  let result = 0;
1027
1018
  let last = current;
1028
1019
  let angleRepeatCount = 0;
1020
+ // Hidden's fade-out only affects opacity when the "only fade approach circles" setting is off.
1021
+ const opacityMods = ((_a = mods.get(osuBase.ModHidden)) === null || _a === void 0 ? void 0 : _a.onlyFadeApproachCircles.value)
1022
+ ? undefined
1023
+ : mods;
1029
1024
  for (let i = 0; i < Math.min(current.index, 10); ++i) {
1030
1025
  const currentObject = current.previous(i);
1031
1026
  cumulativeStrainTime += last.strainTime;
@@ -1043,7 +1038,7 @@ class DroidFlashlightEvaluator {
1043
1038
  const opacityBonus = 1 +
1044
1039
  this.maxOpacityBonus *
1045
1040
  (1 -
1046
- current.opacityAt(currentObject.object.startTime, mods));
1041
+ current.opacityAt(currentObject.object.startTime, opacityMods));
1047
1042
  result +=
1048
1043
  (stackNerf * opacityBonus * scalingFactor * jumpDistance) /
1049
1044
  cumulativeStrainTime;
@@ -1133,7 +1128,10 @@ class StrainSkill extends Skill {
1133
1128
  get peaks() {
1134
1129
  return this.strainPeaks
1135
1130
  .map((value, i) => ({ time: this.strainPeakTimes[i], value }))
1136
- .concat({ time: this.currentSectionEnd, value: this.currentSectionPeak });
1131
+ .concat({
1132
+ time: this.currentSectionEnd,
1133
+ value: this.currentSectionPeak,
1134
+ });
1137
1135
  }
1138
1136
  /**
1139
1137
  * Converts a difficulty value to a performance value.
@@ -1180,9 +1178,7 @@ class StrainSkill extends Skill {
1180
1178
  this.startNewSectionFrom(this.currentSectionEnd, current);
1181
1179
  this.currentSectionEnd += this.sectionLength;
1182
1180
  }
1183
- // Ignore the first hitobject.
1184
1181
  this.currentStrain = this.strainValueAt(current);
1185
- this.saveToHitObject(current, this.currentStrain);
1186
1182
  this.currentSectionPeak = Math.max(this.currentStrain, this.currentSectionPeak);
1187
1183
  return this.currentStrain;
1188
1184
  }
@@ -1321,6 +1317,7 @@ class HarmonicSkill extends Skill {
1321
1317
  constructor() {
1322
1318
  super(...arguments);
1323
1319
  this._noteWeightSum = 0;
1320
+ this._objectTimes = [];
1324
1321
  /**
1325
1322
  * Scaling factor applied as `x / (i + 1)`, where `x` is the skill's {@link harmonicScale} and `i`
1326
1323
  * is the index of the {@link DifficultyHitObject} being processed.
@@ -1343,6 +1340,14 @@ class HarmonicSkill extends Skill {
1343
1340
  get noteWeightSum() {
1344
1341
  return this._noteWeightSum;
1345
1342
  }
1343
+ /**
1344
+ * The start times of {@link DifficultyHitObject}s, populated by {@link HarmonicSkill.process}.
1345
+ *
1346
+ * Indices correspond to {@link objectDifficulties}.
1347
+ */
1348
+ get objectTimes() {
1349
+ return this._objectTimes;
1350
+ }
1346
1351
  get peaks() {
1347
1352
  return this.objectDifficulties.map((value, i) => ({
1348
1353
  time: this.objectTimes[i],
@@ -1408,6 +1413,13 @@ class HarmonicSkill extends Skill {
1408
1413
  applyDifficultyTransformation(difficulties) {
1409
1414
  // Do nothing by default.
1410
1415
  }
1416
+ process(current) {
1417
+ const previousLength = this.objectDifficulties.length;
1418
+ super.process(current);
1419
+ if (this.objectDifficulties.length > previousLength) {
1420
+ this._objectTimes.push(current.startTime);
1421
+ }
1422
+ }
1411
1423
  processInternal(current) {
1412
1424
  return this.objectDifficultyOf(current);
1413
1425
  }
@@ -2994,17 +3006,24 @@ class DroidDifficultyHitObject extends DifficultyHitObject {
2994
3006
  }
2995
3007
  }
2996
3008
 
3009
+ /**
3010
+ * Represents a group of consecutive objects with the same delta time.
3011
+ */
2997
3012
  class Island {
2998
- constructor(delta, deltaDifferenceEpsilon) {
3013
+ constructor(delta) {
3014
+ /**
3015
+ * Delta time of every object in this island.
3016
+ */
2999
3017
  this.delta = Number.MAX_SAFE_INTEGER;
3000
- this.deltaCount = 0;
3001
- if (deltaDifferenceEpsilon === undefined) {
3002
- this.deltaDifferenceEpsilon = delta;
3003
- }
3004
- else {
3005
- this.deltaDifferenceEpsilon = deltaDifferenceEpsilon;
3006
- this.addDelta(delta);
3007
- }
3018
+ /**
3019
+ * How long the island is.
3020
+ */
3021
+ this.deltaCount = 1;
3022
+ /**
3023
+ * How many times the island already occured.
3024
+ */
3025
+ this.occurrences = 1;
3026
+ this.delta = Math.max(Math.trunc(delta), DifficultyHitObject.minDeltaTime);
3008
3027
  }
3009
3028
  addDelta(delta) {
3010
3029
  if (this.delta === Number.MAX_SAFE_INTEGER) {
@@ -3012,27 +3031,20 @@ class Island {
3012
3031
  }
3013
3032
  ++this.deltaCount;
3014
3033
  }
3015
- isSimilarPolarity(other) {
3034
+ isSimilarPolarity(other, epsilon) {
3016
3035
  // Single delta islands should not be compared.
3017
3036
  if (this.deltaCount <= 1 || other.deltaCount <= 1) {
3018
3037
  return false;
3019
3038
  }
3020
- return (Math.abs(this.delta - other.delta) < this.deltaDifferenceEpsilon &&
3039
+ return (Math.abs(this.delta - other.delta) < epsilon &&
3021
3040
  this.deltaCount % 2 === other.deltaCount % 2);
3022
3041
  }
3023
- equals(other) {
3024
- return (Math.abs(this.delta - other.delta) < this.deltaDifferenceEpsilon &&
3042
+ almostEquals(other, epsilon) {
3043
+ return (Math.abs(this.delta - other.delta) < epsilon &&
3025
3044
  this.deltaCount === other.deltaCount);
3026
3045
  }
3027
3046
  }
3028
3047
 
3029
- class IslandCounter {
3030
- constructor(island, count) {
3031
- this.island = island;
3032
- this.count = count;
3033
- }
3034
- }
3035
-
3036
3048
  /**
3037
3049
  * An evaluator for calculating osu!droid Rhythm skill.
3038
3050
  */
@@ -3050,9 +3062,9 @@ class DroidRhythmEvaluator {
3050
3062
  }
3051
3063
  const deltaDifferenceEpsilon = current.hitWindowFor(osuBase.HitResult.Great) * 0.3;
3052
3064
  let rhythmComplexitySum = 0;
3053
- let island = new Island(deltaDifferenceEpsilon);
3054
- let previousIsland = new Island(deltaDifferenceEpsilon);
3055
- const islandCounts = [];
3065
+ let island = new Island(Number.MAX_SAFE_INTEGER);
3066
+ let previousIsland = new Island(Number.MAX_SAFE_INTEGER);
3067
+ const islands = [];
3056
3068
  // Store the ratio of the current start of an island to buff for tighter rhythms.
3057
3069
  let startRatio = 0;
3058
3070
  let firstDeltaSwitch = false;
@@ -3093,7 +3105,7 @@ class DroidRhythmEvaluator {
3093
3105
  const prevDelta = Math.max(prevObject.deltaTime, 1e-7);
3094
3106
  const lastDelta = Math.max(lastObject.deltaTime, 1e-7);
3095
3107
  if (island.delta == Number.MAX_SAFE_INTEGER) {
3096
- island = new Island(currentDelta, deltaDifferenceEpsilon);
3108
+ island = new Island(currentDelta);
3097
3109
  }
3098
3110
  // Calculate how much current delta difference deserves a rhythm bonus.
3099
3111
  // This function is meant to reduce rhythm bonus for deltas that are multiples of each other (i.e. 100 and 200).
@@ -3130,7 +3142,7 @@ class DroidRhythmEvaluator {
3130
3142
  effectiveRatio /= 2;
3131
3143
  }
3132
3144
  // Repeated island polarity (2 -> 4, 3 -> 5).
3133
- if (island.isSimilarPolarity(previousIsland)) {
3145
+ if (island.isSimilarPolarity(previousIsland, deltaDifferenceEpsilon)) {
3134
3146
  effectiveRatio /= 2;
3135
3147
  }
3136
3148
  // Previous increase happened a note ago.
@@ -3147,18 +3159,24 @@ class DroidRhythmEvaluator {
3147
3159
  if (isSpeedingUp) {
3148
3160
  effectiveRatio *= 0.65;
3149
3161
  }
3150
- const islandCount = islandCounts.find((x) => x.island.equals(island));
3151
- if (islandCount) {
3162
+ let found = false;
3163
+ for (const existingIsland of islands) {
3164
+ if (!existingIsland.almostEquals(island, deltaDifferenceEpsilon)) {
3165
+ continue;
3166
+ }
3152
3167
  // Only add island to island counts if they're going one after another.
3153
- if (previousIsland.equals(island)) {
3154
- ++islandCount.count;
3168
+ if (previousIsland.almostEquals(island, deltaDifferenceEpsilon)) {
3169
+ ++existingIsland.occurrences;
3155
3170
  }
3171
+ const power = osuBase.MathUtils.offsetLogistic(island.delta, 58.33, 0.24, 2.75);
3156
3172
  // Repeated island (ex: triplet -> triplet).
3157
3173
  // Graph: https://www.desmos.com/calculator/pj7an56zwf
3158
- effectiveRatio *= Math.min(3 / islandCount.count, Math.pow(1 / islandCount.count, osuBase.MathUtils.offsetLogistic(island.delta, 58.33, 0.24, 2.75)));
3174
+ effectiveRatio *= Math.min(3 / existingIsland.occurrences, Math.pow(1 / existingIsland.occurrences, power));
3175
+ found = true;
3176
+ break;
3159
3177
  }
3160
- else if (island.deltaCount > 0) {
3161
- islandCounts.push(new IslandCounter(island, 1));
3178
+ if (!found && island.deltaCount > 0) {
3179
+ islands.push(island);
3162
3180
  }
3163
3181
  // Scale down the difficulty if the object is doubletappable.
3164
3182
  effectiveRatio *=
@@ -3179,7 +3197,7 @@ class DroidRhythmEvaluator {
3179
3197
  // If we're speeding up, this stays as is and we keep counting island size.
3180
3198
  firstDeltaSwitch = false;
3181
3199
  }
3182
- island = new Island(currentDelta, deltaDifferenceEpsilon);
3200
+ island = new Island(currentDelta);
3183
3201
  }
3184
3202
  }
3185
3203
  else if (prevDelta > currentDelta + deltaDifferenceEpsilon) {
@@ -3197,7 +3215,7 @@ class DroidRhythmEvaluator {
3197
3215
  effectiveRatio *= 0.6;
3198
3216
  }
3199
3217
  startRatio = effectiveRatio;
3200
- island = new Island(currentDelta, deltaDifferenceEpsilon);
3218
+ island = new Island(currentDelta);
3201
3219
  }
3202
3220
  lastObject = prevObject;
3203
3221
  prevObject = currentObject;
@@ -3694,6 +3712,7 @@ class OsuFlashlightEvaluator {
3694
3712
  * @param mods The mods used.
3695
3713
  */
3696
3714
  static evaluateDifficultyOf(current, mods) {
3715
+ var _a;
3697
3716
  if (current.object instanceof osuBase.Spinner) {
3698
3717
  return 0;
3699
3718
  }
@@ -3703,6 +3722,10 @@ class OsuFlashlightEvaluator {
3703
3722
  let result = 0;
3704
3723
  let last = current;
3705
3724
  let angleRepeatCount = 0;
3725
+ // Hidden's fade-out only affects opacity when the "only fade approach circles" setting is off.
3726
+ const opacityMods = ((_a = mods.get(osuBase.ModHidden)) === null || _a === void 0 ? void 0 : _a.onlyFadeApproachCircles.value)
3727
+ ? undefined
3728
+ : mods;
3706
3729
  for (let i = 0; i < Math.min(current.index, 10); ++i) {
3707
3730
  const currentObject = current.previous(i);
3708
3731
  cumulativeStrainTime += last.strainTime;
@@ -3718,7 +3741,7 @@ class OsuFlashlightEvaluator {
3718
3741
  const opacityBonus = 1 +
3719
3742
  this.maxOpacityBonus *
3720
3743
  (1 -
3721
- current.opacityAt(currentObject.object.startTime, mods));
3744
+ current.opacityAt(currentObject.object.startTime, opacityMods));
3722
3745
  result +=
3723
3746
  (stackNerf * opacityBonus * scalingFactor * jumpDistance) /
3724
3747
  cumulativeStrainTime;
@@ -4300,9 +4323,9 @@ class OsuRhythmEvaluator {
4300
4323
  }
4301
4324
  const deltaDifferenceEpsilon = current.hitWindowFor(osuBase.HitResult.Great) * 0.3;
4302
4325
  let rhythmComplexitySum = 0;
4303
- let island = new Island(deltaDifferenceEpsilon);
4304
- let previousIsland = new Island(deltaDifferenceEpsilon);
4305
- const islandCounts = [];
4326
+ let island = new Island(Number.MAX_SAFE_INTEGER);
4327
+ let previousIsland = new Island(Number.MAX_SAFE_INTEGER);
4328
+ const islands = [];
4306
4329
  // Store the ratio of the current start of an island to buff for tighter rhythms.
4307
4330
  let startRatio = 0;
4308
4331
  let firstDeltaSwitch = false;
@@ -4332,7 +4355,7 @@ class OsuRhythmEvaluator {
4332
4355
  const prevDelta = Math.max(prevObject.deltaTime, 1e-7);
4333
4356
  const lastDelta = Math.max(lastObject.deltaTime, 1e-7);
4334
4357
  if (island.delta == Number.MAX_SAFE_INTEGER) {
4335
- island = new Island(currentDelta, deltaDifferenceEpsilon);
4358
+ island = new Island(currentDelta);
4336
4359
  }
4337
4360
  // Calculate how much current delta difference deserves a rhythm bonus
4338
4361
  // This function is meant to reduce rhythm bonus for deltas that are multiples of each other (i.e. 100 and 200)
@@ -4368,7 +4391,7 @@ class OsuRhythmEvaluator {
4368
4391
  effectiveRatio /= 2;
4369
4392
  }
4370
4393
  // Repeated island polarity (2 -> 4, 3 -> 5).
4371
- if (island.isSimilarPolarity(previousIsland)) {
4394
+ if (island.isSimilarPolarity(previousIsland, deltaDifferenceEpsilon)) {
4372
4395
  effectiveRatio /= 2;
4373
4396
  }
4374
4397
  // Previous increase happened a note ago.
@@ -4385,18 +4408,24 @@ class OsuRhythmEvaluator {
4385
4408
  if (isSpeedingUp) {
4386
4409
  effectiveRatio *= 0.65;
4387
4410
  }
4388
- const islandCount = islandCounts.find((x) => x.island.equals(island));
4389
- if (islandCount) {
4411
+ let found = false;
4412
+ for (const existingIsland of islands) {
4413
+ if (!existingIsland.almostEquals(island, deltaDifferenceEpsilon)) {
4414
+ continue;
4415
+ }
4390
4416
  // Only add island to island counts if they're going one after another.
4391
- if (previousIsland.equals(island)) {
4392
- ++islandCount.count;
4417
+ if (previousIsland.almostEquals(island, deltaDifferenceEpsilon)) {
4418
+ ++existingIsland.occurrences;
4393
4419
  }
4420
+ const power = osuBase.MathUtils.offsetLogistic(island.delta, 58.33, 0.24, 2.75);
4394
4421
  // Repeated island (ex: triplet -> triplet).
4395
4422
  // Graph: https://www.desmos.com/calculator/pj7an56zwf
4396
- effectiveRatio *= Math.min(3 / islandCount.count, Math.pow(1 / islandCount.count, osuBase.MathUtils.offsetLogistic(island.delta, 58.33, 0.24, 2.75)));
4423
+ effectiveRatio *= Math.min(3 / existingIsland.occurrences, Math.pow(1 / existingIsland.occurrences, power));
4424
+ found = true;
4425
+ break;
4397
4426
  }
4398
- else if (island.deltaCount > 0) {
4399
- islandCounts.push(new IslandCounter(island, 1));
4427
+ if (!found && island.deltaCount > 0) {
4428
+ islands.push(island);
4400
4429
  }
4401
4430
  // Scale down the difficulty if the object is doubletappable.
4402
4431
  effectiveRatio *=
@@ -4417,7 +4446,7 @@ class OsuRhythmEvaluator {
4417
4446
  // If we're speeding up, this stays as is and we keep counting island size.
4418
4447
  firstDeltaSwitch = false;
4419
4448
  }
4420
- island = new Island(currentDelta, deltaDifferenceEpsilon);
4449
+ island = new Island(currentDelta);
4421
4450
  }
4422
4451
  }
4423
4452
  else if (prevDelta > currentDelta + deltaDifferenceEpsilon) {
@@ -4435,7 +4464,7 @@ class OsuRhythmEvaluator {
4435
4464
  effectiveRatio *= 0.6;
4436
4465
  }
4437
4466
  startRatio = effectiveRatio;
4438
- island = new Island(currentDelta, deltaDifferenceEpsilon);
4467
+ island = new Island(currentDelta);
4439
4468
  }
4440
4469
  lastObject = prevObject;
4441
4470
  prevObject = currentObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rian8337/osu-rebalance-difficulty-calculator",
3
- "version": "4.0.0-beta.94",
3
+ "version": "4.0.0-beta.95",
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.91"
36
+ "@rian8337/osu-base": "4.0.0-beta.95"
37
37
  },
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "ab494480e1793b60e89b1e8b56c73b7a6995ff1f"
41
+ "gitHead": "b07790be9c9dd737170d2d576bf02298ec607ab9"
42
42
  }
@@ -415,17 +415,10 @@ declare abstract class Skill {
415
415
  */
416
416
  protected readonly mods: ModMap;
417
417
  private _objectDifficulties;
418
- private _objectTimes;
419
418
  /**
420
419
  * The difficulties of {@link DifficultyHitObject}s, populated by {@link Skill.process}.
421
420
  */
422
421
  protected get objectDifficulties(): readonly number[];
423
- /**
424
- * The start times of {@link DifficultyHitObject}s, populated by {@link Skill.process}.
425
- *
426
- * Indices correspond to {@link objectDifficulties}.
427
- */
428
- protected get objectTimes(): readonly number[];
429
422
  constructor(mods: ModMap);
430
423
  /**
431
424
  * Calculates the strain value of a hitobject and stores the value in it.
@@ -1797,12 +1790,19 @@ declare class DroidFlashlight extends DroidSkill {
1797
1790
  */
1798
1791
  declare abstract class HarmonicSkill extends Skill implements IHasPeakDifficulty {
1799
1792
  private _noteWeightSum;
1793
+ private _objectTimes;
1800
1794
  /**
1801
1795
  * The sum of note weights, calculated during summation.
1802
1796
  *
1803
1797
  * Required for any calculations that normalizes the difficulty value.
1804
1798
  */
1805
1799
  protected get noteWeightSum(): number;
1800
+ /**
1801
+ * The start times of {@link DifficultyHitObject}s, populated by {@link HarmonicSkill.process}.
1802
+ *
1803
+ * Indices correspond to {@link objectDifficulties}.
1804
+ */
1805
+ protected get objectTimes(): readonly number[];
1806
1806
  /**
1807
1807
  * Scaling factor applied as `x / (i + 1)`, where `x` is the skill's {@link harmonicScale} and `i`
1808
1808
  * is the index of the {@link DifficultyHitObject} being processed.
@@ -1833,6 +1833,7 @@ declare abstract class HarmonicSkill extends Skill implements IHasPeakDifficulty
1833
1833
  * @param difficulties The difficulties of {@link DifficultyHitObject}s to transform.
1834
1834
  */
1835
1835
  protected applyDifficultyTransformation(difficulties: number[]): void;
1836
+ process(current: DifficultyHitObject): void;
1836
1837
  protected processInternal(current: DifficultyHitObject): number;
1837
1838
  /**
1838
1839
  * Calculates the difficulty value of a {@link DifficultyHitObject}. This value is calculated with or without respect to previous objects.