@rian8337/osu-rebalance-difficulty-calculator 1.2.1 → 1.2.3

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.
@@ -66,9 +66,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator_1.PerformanceCalc
66
66
  const calculatedAR = this.mapStatistics.ar;
67
67
  this.aim = this.baseValue(Math.pow(this.stars.aim, 0.8));
68
68
  if (this.effectiveMissCount > 0) {
69
- this.aim *=
70
- 0.97 *
71
- Math.pow(1 - Math.pow(this.effectiveMissCount / objectCount, 0.775), this.effectiveMissCount);
69
+ this.aim *= this.calculateMissPenalty(this.stars.attributes.aimDifficultStrainCount);
72
70
  }
73
71
  // Combo scaling
74
72
  this.aim *= this.comboPenalty;
@@ -116,10 +114,7 @@ class DroidPerformanceCalculator extends PerformanceCalculator_1.PerformanceCalc
116
114
  const calculatedAR = this.mapStatistics.ar;
117
115
  this.tap = this.baseValue(this.stars.tap);
118
116
  if (this.effectiveMissCount > 0) {
119
- // Penalize misses by assessing # of misses relative to the total # of objects. Default a 3% reduction for any # of misses.
120
- this.tap *=
121
- 0.97 *
122
- Math.pow(1 - Math.pow(this.effectiveMissCount / objectCount, 0.775), Math.pow(this.effectiveMissCount, 0.875));
117
+ this.tap *= this.calculateMissPenalty(this.stars.attributes.speedDifficultStrainCount);
123
118
  }
124
119
  // Combo scaling
125
120
  this.tap *= this.comboPenalty;
@@ -241,5 +236,19 @@ class DroidPerformanceCalculator extends PerformanceCalculator_1.PerformanceCalc
241
236
  this.flashlight.toFixed(2) +
242
237
  " flashlight)");
243
238
  }
239
+ /**
240
+ * Calculates miss penalty.
241
+ *
242
+ * @param difficultStrainCount Difficult strain count from calculation.
243
+ * @returns The miss penalty.
244
+ */
245
+ calculateMissPenalty(difficultStrainCount) {
246
+ // Miss penalty assumes that a player will miss on the hardest parts of a map,
247
+ // so we use the amount of relatively difficult sections to adjust miss penalty
248
+ // to make it more punishing on maps with lower amount of hard sections.
249
+ return (0.97 /
250
+ (this.effectiveMissCount / (2 * Math.sqrt(difficultStrainCount)) +
251
+ 1));
252
+ }
244
253
  }
245
254
  exports.DroidPerformanceCalculator = DroidPerformanceCalculator;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DroidStarRating = void 0;
4
- const osu_base_1 = require("@rian8337/osu-base");
5
4
  const DroidAim_1 = require("./skills/DroidAim");
6
5
  const DroidTap_1 = require("./skills/DroidTap");
7
6
  const StarRating_1 = require("./base/StarRating");
8
7
  const DroidFlashlight_1 = require("./skills/DroidFlashlight");
8
+ const osu_base_1 = require("@rian8337/osu-base");
9
9
  const DroidRhythm_1 = require("./skills/DroidRhythm");
10
10
  /**
11
11
  * Difficulty calculator for osu!droid gamemode.
@@ -59,14 +59,7 @@ class DroidStarRating extends StarRating_1.StarRating {
59
59
  const aimSkill = new DroidAim_1.DroidAim(this.mods, true);
60
60
  const aimSkillWithoutSliders = new DroidAim_1.DroidAim(this.mods, false);
61
61
  this.calculateSkills(aimSkill, aimSkillWithoutSliders);
62
- this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
63
- this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
64
- this.aim = this.starValue(aimSkill.difficultyValue());
65
- if (this.aim) {
66
- this.attributes.sliderFactor =
67
- this.starValue(aimSkillWithoutSliders.difficultyValue()) /
68
- this.aim;
69
- }
62
+ this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
70
63
  }
71
64
  /**
72
65
  * Calculates the speed star rating of the beatmap and stores it in this instance.
@@ -74,13 +67,7 @@ class DroidStarRating extends StarRating_1.StarRating {
74
67
  calculateTap() {
75
68
  const tapSkill = new DroidTap_1.DroidTap(this.mods, this.stats.od);
76
69
  this.calculateSkills(tapSkill);
77
- this.strainPeaks.speed = tapSkill.strainPeaks;
78
- this.tap = this.starValue(tapSkill.difficultyValue());
79
- const objectStrains = this.objects.map((v) => v.tapStrain);
80
- const maxStrain = Math.max(...objectStrains);
81
- if (maxStrain) {
82
- this.attributes.speedNoteCount = objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
83
- }
70
+ this.postCalculateTap(tapSkill);
84
71
  }
85
72
  /**
86
73
  * Calculates the rhythm star rating of the beatmap and stores it in this instance.
@@ -88,7 +75,7 @@ class DroidStarRating extends StarRating_1.StarRating {
88
75
  calculateRhythm() {
89
76
  const rhythmSkill = new DroidRhythm_1.DroidRhythm(this.mods, this.stats.od);
90
77
  this.calculateSkills(rhythmSkill);
91
- this.rhythm = this.starValue(rhythmSkill.difficultyValue());
78
+ this.postCalculateRhythm(rhythmSkill);
92
79
  }
93
80
  /**
94
81
  * Calculates the flashlight star rating of the beatmap and stores it in this instance.
@@ -96,8 +83,7 @@ class DroidStarRating extends StarRating_1.StarRating {
96
83
  calculateFlashlight() {
97
84
  const flashlightSkill = new DroidFlashlight_1.DroidFlashlight(this.mods);
98
85
  this.calculateSkills(flashlightSkill);
99
- this.strainPeaks.flashlight = flashlightSkill.strainPeaks;
100
- this.flashlight = this.starValue(flashlightSkill.difficultyValue());
86
+ this.postCalculateFlashlight(flashlightSkill);
101
87
  }
102
88
  calculateTotal() {
103
89
  const aimPerformanceValue = this.basePerformanceValue(this.aim);
@@ -125,28 +111,17 @@ class DroidStarRating extends StarRating_1.StarRating {
125
111
  const rhythmSkill = skills[2];
126
112
  const tapSkill = skills[3];
127
113
  const flashlightSkill = skills[4];
128
- this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
129
- this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
130
- this.aim = this.starValue(aimSkill.difficultyValue());
131
- if (this.aim) {
132
- this.attributes.sliderFactor =
133
- this.starValue(aimSkillWithoutSliders.difficultyValue()) /
134
- this.aim;
135
- }
114
+ this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
136
115
  if (!isRelax) {
137
- this.strainPeaks.speed = tapSkill.strainPeaks;
138
- this.tap = this.starValue(tapSkill.difficultyValue());
116
+ this.postCalculateTap(tapSkill);
139
117
  }
140
- const objectStrains = this.objects.map((v) => v.tapStrain);
141
- const maxStrain = Math.max(...objectStrains);
142
- if (maxStrain) {
143
- this.attributes.speedNoteCount = objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
118
+ else {
119
+ this.calculateSpeedAttributes();
144
120
  }
145
121
  if (!isRelax) {
146
- this.rhythm = this.starValue(rhythmSkill.difficultyValue());
122
+ this.postCalculateRhythm(rhythmSkill);
147
123
  }
148
- this.strainPeaks.flashlight = flashlightSkill.strainPeaks;
149
- this.flashlight = this.starValue(flashlightSkill.difficultyValue());
124
+ this.postCalculateFlashlight(flashlightSkill);
150
125
  this.calculateTotal();
151
126
  }
152
127
  /**
@@ -177,5 +152,64 @@ class DroidStarRating extends StarRating_1.StarRating {
177
152
  new DroidFlashlight_1.DroidFlashlight(this.mods),
178
153
  ];
179
154
  }
155
+ /**
156
+ * Called after aim skill calculation.
157
+ *
158
+ * @param aimSkill The aim skill that considers sliders.
159
+ * @param aimSkillWithoutSliders The aim skill that doesn't consider sliders.
160
+ */
161
+ postCalculateAim(aimSkill, aimSkillWithoutSliders) {
162
+ this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
163
+ this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
164
+ this.aim = this.starValue(aimSkill.difficultyValue());
165
+ if (this.aim) {
166
+ this.attributes.sliderFactor =
167
+ this.starValue(aimSkillWithoutSliders.difficultyValue()) /
168
+ this.aim;
169
+ }
170
+ const objectStrains = this.objects.map((v) => v.aimStrainWithSliders);
171
+ const maxStrain = Math.max(...objectStrains);
172
+ if (maxStrain) {
173
+ this.attributes.aimDifficultStrainCount = objectStrains.reduce((a, v) => a + Math.pow(v / maxStrain, 4), 0);
174
+ }
175
+ }
176
+ /**
177
+ * Called after tap skill calculation.
178
+ *
179
+ * @param tapSkill The tap skill.
180
+ */
181
+ postCalculateTap(tapSkill) {
182
+ this.strainPeaks.speed = tapSkill.strainPeaks;
183
+ this.tap = this.starValue(tapSkill.difficultyValue());
184
+ this.calculateSpeedAttributes();
185
+ }
186
+ /**
187
+ * Calculates speed-related attributes.
188
+ */
189
+ calculateSpeedAttributes() {
190
+ const objectStrains = this.objects.map((v) => v.tapStrain);
191
+ const maxStrain = Math.max(...objectStrains);
192
+ if (maxStrain) {
193
+ this.attributes.speedNoteCount = objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
194
+ this.attributes.speedDifficultStrainCount = objectStrains.reduce((a, v) => a + Math.pow(v / maxStrain, 4), 0);
195
+ }
196
+ }
197
+ /**
198
+ * Called after rhythm skill calculation.
199
+ *
200
+ * @param rhythmSkill The rhythm skill.
201
+ */
202
+ postCalculateRhythm(rhythmSkill) {
203
+ this.rhythm = this.starValue(rhythmSkill.difficultyValue());
204
+ }
205
+ /**
206
+ * Called after flashlight skill calculation.
207
+ *
208
+ * @param flashlightSkill The flashlight skill.
209
+ */
210
+ postCalculateFlashlight(flashlightSkill) {
211
+ this.strainPeaks.flashlight = flashlightSkill.strainPeaks;
212
+ this.flashlight = this.starValue(flashlightSkill.difficultyValue());
213
+ }
180
214
  }
181
215
  exports.DroidStarRating = DroidStarRating;
@@ -35,15 +35,8 @@ class OsuStarRating extends StarRating_1.StarRating {
35
35
  calculateAim() {
36
36
  const aimSkill = new OsuAim_1.OsuAim(this.mods, true);
37
37
  const aimSkillWithoutSliders = new OsuAim_1.OsuAim(this.mods, false);
38
- this.calculateSkills(aimSkill);
39
- this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
40
- this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
41
- this.aim = this.starValue(aimSkill.difficultyValue());
42
- if (this.aim) {
43
- this.attributes.sliderFactor =
44
- this.starValue(aimSkillWithoutSliders.difficultyValue()) /
45
- this.aim;
46
- }
38
+ this.calculateSkills(aimSkill, aimSkillWithoutSliders);
39
+ this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
47
40
  }
48
41
  /**
49
42
  * Calculates the speed star rating of the beatmap and stores it in this instance.
@@ -52,10 +45,9 @@ class OsuStarRating extends StarRating_1.StarRating {
52
45
  if (this.mods.some((m) => m instanceof osu_base_1.ModRelax)) {
53
46
  return;
54
47
  }
55
- const speedSkill = new OsuSpeed_1.RebalanceOsuSpeed(this.mods, new osu_base_1.OsuHitWindow(this.stats.od).hitWindowFor300());
48
+ const speedSkill = new OsuSpeed_1.OsuSpeed(this.mods, new osu_base_1.OsuHitWindow(this.stats.od).hitWindowFor300());
56
49
  this.calculateSkills(speedSkill);
57
- this.strainPeaks.speed = speedSkill.strainPeaks;
58
- this.speed = this.starValue(speedSkill.difficultyValue());
50
+ this.postCalculateSpeed(speedSkill);
59
51
  }
60
52
  /**
61
53
  * Calculates the flashlight star rating of the beatmap and stores it in this instance.
@@ -103,20 +95,11 @@ class OsuStarRating extends StarRating_1.StarRating {
103
95
  speedSkill = skills[2];
104
96
  flashlightSkill = skills[3];
105
97
  }
106
- this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
107
- this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
108
- this.aim = this.starValue(aimSkill.difficultyValue());
109
- if (this.aim) {
110
- this.attributes.sliderFactor =
111
- this.starValue(aimSkillWithoutSliders.difficultyValue()) /
112
- this.aim;
113
- }
98
+ this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
114
99
  if (speedSkill) {
115
- this.strainPeaks.speed = speedSkill.strainPeaks;
116
- this.speed = this.starValue(speedSkill.difficultyValue());
100
+ this.postCalculateSpeed(speedSkill);
117
101
  }
118
- this.strainPeaks.flashlight = flashlightSkill.strainPeaks;
119
- this.flashlight = this.starValue(flashlightSkill.difficultyValue());
102
+ this.postCalculateFlashlight(flashlightSkill);
120
103
  this.calculateTotal();
121
104
  }
122
105
  /**
@@ -139,9 +122,43 @@ class OsuStarRating extends StarRating_1.StarRating {
139
122
  return [
140
123
  new OsuAim_1.OsuAim(this.mods, true),
141
124
  new OsuAim_1.OsuAim(this.mods, false),
142
- new OsuSpeed_1.RebalanceOsuSpeed(this.mods, new osu_base_1.OsuHitWindow(this.stats.od).hitWindowFor300()),
125
+ new OsuSpeed_1.OsuSpeed(this.mods, new osu_base_1.OsuHitWindow(this.stats.od).hitWindowFor300()),
143
126
  new OsuFlashlight_1.OsuFlashlight(this.mods),
144
127
  ];
145
128
  }
129
+ /**
130
+ * Called after aim skill calculation.
131
+ *
132
+ * @param aimSkill The aim skill that considers sliders.
133
+ * @param aimSkillWithoutSliders The aim skill that doesn't consider sliders.
134
+ */
135
+ postCalculateAim(aimSkill, aimSkillWithoutSliders) {
136
+ this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
137
+ this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
138
+ this.aim = this.starValue(aimSkill.difficultyValue());
139
+ if (this.aim) {
140
+ this.attributes.sliderFactor =
141
+ this.starValue(aimSkillWithoutSliders.difficultyValue()) /
142
+ this.aim;
143
+ }
144
+ }
145
+ /**
146
+ * Called after speed skill calculation.
147
+ *
148
+ * @param speedSkill The speed skill.
149
+ */
150
+ postCalculateSpeed(speedSkill) {
151
+ this.strainPeaks.speed = speedSkill.strainPeaks;
152
+ this.speed = this.starValue(speedSkill.difficultyValue());
153
+ }
154
+ /**
155
+ * Called after flashlight skill calculation.
156
+ *
157
+ * @param flashlightSkill The flashlight skill.
158
+ */
159
+ postCalculateFlashlight(flashlightSkill) {
160
+ this.strainPeaks.flashlight = flashlightSkill.strainPeaks;
161
+ this.flashlight = this.starValue(flashlightSkill.difficultyValue());
162
+ }
146
163
  }
147
164
  exports.OsuStarRating = OsuStarRating;
@@ -43,6 +43,8 @@ class StarRating {
43
43
  this.attributes = {
44
44
  speedNoteCount: 0,
45
45
  sliderFactor: 1,
46
+ aimDifficultStrainCount: 0,
47
+ speedDifficultStrainCount: 0,
46
48
  };
47
49
  this.sectionLength = 400;
48
50
  }
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RebalanceOsuSpeed = void 0;
3
+ exports.OsuSpeed = void 0;
4
4
  const osu_base_1 = require("@rian8337/osu-base");
5
5
  const OsuSkill_1 = require("./OsuSkill");
6
6
  /**
7
7
  * Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
8
8
  */
9
- class RebalanceOsuSpeed extends OsuSkill_1.OsuSkill {
9
+ class OsuSpeed extends OsuSkill_1.OsuSkill {
10
10
  constructor(mods, greatWindow) {
11
11
  super(mods);
12
12
  /**
@@ -172,4 +172,4 @@ class RebalanceOsuSpeed extends OsuSkill_1.OsuSkill {
172
172
  current.rhythmMultiplier = this.currentRhythm;
173
173
  }
174
174
  }
175
- exports.RebalanceOsuSpeed = RebalanceOsuSpeed;
175
+ exports.OsuSpeed = OsuSpeed;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rian8337/osu-rebalance-difficulty-calculator",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
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",
@@ -35,5 +35,5 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "gitHead": "8c08cf8f2c3af4b9a306f9fe9ffedfe339b9b046"
38
+ "gitHead": "e2d1f9bef01c9b12954a78683c3b8dcddabc7b1d"
39
39
  }
@@ -280,8 +280,14 @@ declare module "@rian8337/osu-rebalance-difficulty-calculator" {
280
280
  * Calculates the flashlight performance value of the beatmap.
281
281
  */
282
282
  private calculateFlashlightValue(): void;
283
- private calculateMissPenalty(strainCount: number): number;
284
283
  override toString(): string;
284
+ /**
285
+ * Calculates miss penalty.
286
+ *
287
+ * @param difficultStrainCount Difficult strain count from calculation.
288
+ * @returns The miss penalty.
289
+ */
290
+ private calculateMissPenalty(difficultStrainCount: number): number;
285
291
  }
286
292
 
287
293
  /**
@@ -393,15 +399,37 @@ declare module "@rian8337/osu-rebalance-difficulty-calculator" {
393
399
  */
394
400
  protected override createSkills(): DroidSkill[];
395
401
  /**
396
- * Calculates the base rating value of a difficulty.
402
+ * Called after aim skill calculation.
403
+ *
404
+ * @param aimSkill The aim skill that considers sliders.
405
+ * @param aimSkillWithoutSliders The aim skill that doesn't consider sliders.
397
406
  */
398
- private baseRatingValue(difficulty: number): number;
407
+ private postCalculateAim(
408
+ aimSkill: DroidAim,
409
+ aimSkillWithoutSliders: DroidAim
410
+ ): void;
399
411
  /**
400
- * Calculates the base performance value of a difficulty rating.
412
+ * Called after tap skill calculation.
401
413
  *
402
- * @param rating The difficulty rating.
414
+ * @param tapSkill The tap skill.
415
+ */
416
+ private postCalculateTap(tapSkill: DroidTap): void;
417
+ /**
418
+ * Calculates speed-related attributes.
403
419
  */
404
- private basePerformanceValue(rating: number): number;
420
+ private calculateSpeedAttributes(): void;
421
+ /**
422
+ * Called after rhythm skill calculation.
423
+ *
424
+ * @param rhythmSkill The rhythm skill.
425
+ */
426
+ private postCalculateRhythm(rhythmSkill: DroidRhythm): void;
427
+ /**
428
+ * Called after flashlight skill calculation.
429
+ *
430
+ * @param flashlightSkill The flashlight skill.
431
+ */
432
+ private postCalculateFlashlight(flashlightSkill: DroidFlashlight): void;
405
433
  }
406
434
 
407
435
  /**
@@ -686,17 +714,27 @@ declare module "@rian8337/osu-rebalance-difficulty-calculator" {
686
714
  */
687
715
  protected override createSkills(): OsuSkill[];
688
716
  /**
689
- * Calculates the base performance value of a difficulty rating.
717
+ * Called after aim skill calculation.
690
718
  *
691
- * @param rating The difficulty rating.
719
+ * @param aimSkill The aim skill that considers sliders.
720
+ * @param aimSkillWithoutSliders The aim skill that doesn't consider sliders.
692
721
  */
693
- private basePerformanceValue(rating: number): number;
722
+ private postCalculateAim(
723
+ aimSkill: OsuAim,
724
+ aimSkillWithoutSliders: OsuAim
725
+ ): void;
694
726
  /**
695
- * Calculates the star rating value of a difficulty.
727
+ * Called after speed skill calculation.
696
728
  *
697
- * @param difficulty The difficulty to calculate.
729
+ * @param speedSkill The speed skill.
730
+ */
731
+ private postCalculateSpeed(speedSkill: OsuSpeed): void;
732
+ /**
733
+ * Called after flashlight skill calculation.
734
+ *
735
+ * @param flashlightSkill The flashlight skill.
698
736
  */
699
- private starValue(difficulty: number): number;
737
+ private postCalculateFlashlight(flashlightSkill: OsuFlashlight): void;
700
738
  }
701
739
 
702
740
  //#endregion
@@ -709,6 +747,8 @@ declare module "@rian8337/osu-rebalance-difficulty-calculator" {
709
747
  export interface DifficultyAttributes {
710
748
  speedNoteCount: number;
711
749
  sliderFactor: number;
750
+ aimDifficultStrainCount: number;
751
+ speedDifficultStrainCount: number;
712
752
  }
713
753
 
714
754
  /**
@@ -1114,6 +1154,18 @@ declare module "@rian8337/osu-rebalance-difficulty-calculator" {
1114
1154
  * Creates skills to be calculated.
1115
1155
  */
1116
1156
  protected abstract createSkills(): Skill[];
1157
+ /**
1158
+ * Calculates the star rating value of a difficulty.
1159
+ *
1160
+ * @param difficulty The difficulty to calculate.
1161
+ */
1162
+ protected starValue(difficulty: number): number;
1163
+ /**
1164
+ * Calculates the base performance value of a difficulty rating.
1165
+ *
1166
+ * @param rating The difficulty rating.
1167
+ */
1168
+ protected basePerformanceValue(rating: number): number;
1117
1169
  }
1118
1170
 
1119
1171
  //#endregion