@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.53 → 4.0.0-beta.55

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.
Files changed (3) hide show
  1. package/dist/index.js +784 -987
  2. package/package.json +3 -3
  3. package/typings/index.d.ts +258 -358
package/dist/index.js CHANGED
@@ -3,146 +3,121 @@
3
3
  var osuBase = require('@rian8337/osu-base');
4
4
 
5
5
  /**
6
- * The base of a difficulty calculator.
6
+ * Holds data that can be used to calculate performance points.
7
7
  */
8
- class DifficultyCalculator {
9
- /**
10
- * The difficulty objects of the beatmap.
11
- */
12
- get objects() {
13
- return this._objects;
14
- }
15
- /**
16
- * The total star rating of the beatmap.
17
- */
18
- get total() {
19
- return this.attributes.starRating;
20
- }
21
- /**
22
- * Constructs a new instance of the calculator.
23
- *
24
- * @param beatmap The beatmap to calculate.
25
- */
26
- constructor(beatmap) {
27
- /**
28
- * The difficulty objects of the beatmap.
29
- */
30
- this._objects = [];
31
- /**
32
- * The modifications applied.
33
- */
8
+ class DifficultyAttributes {
9
+ constructor(cacheableAttributes) {
34
10
  this.mods = [];
35
- /**
36
- * The strain peaks of various calculated difficulties.
37
- */
38
- this.strainPeaks = {
39
- aimWithSliders: [],
40
- aimWithoutSliders: [],
41
- speed: [],
42
- flashlight: [],
43
- };
44
- this.beatmap = beatmap;
11
+ this.starRating = 0;
12
+ this.maxCombo = 0;
13
+ this.aimDifficulty = 0;
14
+ this.flashlightDifficulty = 0;
15
+ this.speedNoteCount = 0;
16
+ this.sliderFactor = 1;
17
+ this.clockRate = 1;
18
+ this.overallDifficulty = 0;
19
+ this.hitCircleCount = 0;
20
+ this.sliderCount = 0;
21
+ this.spinnerCount = 0;
22
+ this.aimDifficultSliderCount = 0;
23
+ this.aimDifficultStrainCount = 0;
24
+ if (!cacheableAttributes) {
25
+ return;
26
+ }
27
+ this.mods = osuBase.ModUtil.deserializeMods(cacheableAttributes.mods);
28
+ this.starRating = cacheableAttributes.starRating;
29
+ this.maxCombo = cacheableAttributes.maxCombo;
30
+ this.aimDifficulty = cacheableAttributes.aimDifficulty;
31
+ this.flashlightDifficulty = cacheableAttributes.flashlightDifficulty;
32
+ this.speedNoteCount = cacheableAttributes.speedNoteCount;
33
+ this.sliderFactor = cacheableAttributes.sliderFactor;
34
+ this.clockRate = cacheableAttributes.clockRate;
35
+ this.overallDifficulty = cacheableAttributes.overallDifficulty;
36
+ this.hitCircleCount = cacheableAttributes.hitCircleCount;
37
+ this.sliderCount = cacheableAttributes.sliderCount;
38
+ this.spinnerCount = cacheableAttributes.spinnerCount;
39
+ this.aimDifficultSliderCount =
40
+ cacheableAttributes.aimDifficultSliderCount;
41
+ this.aimDifficultStrainCount =
42
+ cacheableAttributes.aimDifficultStrainCount;
45
43
  }
46
44
  /**
47
- * Retains `Mod`s that adjust a beatmap's difficulty from the specified mods.
45
+ * Converts this `DifficultyAttributes` instance to an attribute structure that can be cached.
48
46
  *
49
- * @param mods The mods to retain the difficulty adjustment mods from.
50
- * @returns The retained difficulty adjustment mods.
47
+ * @returns The cacheable attributes.
51
48
  */
52
- static retainDifficultyAdjustmentMods(mods) {
53
- return mods.filter((mod) => this.difficultyAdjustmentMods.has(mod.constructor));
49
+ toCacheableAttributes() {
50
+ return Object.assign(Object.assign({}, this), { mods: osuBase.ModUtil.serializeMods(this.mods) });
54
51
  }
55
52
  /**
56
- * Calculates the star rating of the specified beatmap.
57
- *
58
- * The beatmap is analyzed in chunks of `sectionLength` duration.
59
- * For each chunk the highest hitobject strains are added to
60
- * a list which is then collapsed into a weighted sum, much
61
- * like scores are weighted on a user's profile.
62
- *
63
- * For subsequent chunks, the initial max strain is calculated
64
- * by decaying the previous hitobject's strain until the
65
- * beginning of the new chunk.
66
- *
67
- * @param options Options for the difficulty calculation.
68
- * @returns The current instance.
53
+ * Returns a string representation of the difficulty attributes.
69
54
  */
70
- calculate(options) {
71
- var _a;
72
- this.mods = (_a = options === null || options === void 0 ? void 0 : options.mods) !== null && _a !== void 0 ? _a : [];
73
- const playableBeatmap = this.beatmap.createPlayableBeatmap({
74
- mode: this.mode,
75
- mods: this.mods,
76
- customSpeedMultiplier: options === null || options === void 0 ? void 0 : options.customSpeedMultiplier,
77
- });
78
- const clockRate = this.calculateClockRate(options);
79
- this.populateDifficultyAttributes(playableBeatmap, clockRate);
80
- this._objects = this.generateDifficultyHitObjects(playableBeatmap, clockRate);
81
- this.calculateAll();
82
- return this;
55
+ toString() {
56
+ return `${this.starRating.toFixed(2)} stars`;
83
57
  }
84
- /**
85
- * Calculates the skills provided.
86
- *
87
- * @param skills The skills to calculate.
88
- */
89
- calculateSkills(...skills) {
90
- // The first object doesn't generate a strain, so we begin calculating from the second object.
91
- for (const object of this.objects.slice(1)) {
58
+ }
59
+
60
+ /**
61
+ * The base of a difficulty calculator.
62
+ */
63
+ class DifficultyCalculator {
64
+ constructor() {
65
+ /**
66
+ * `Mod`s that adjust the difficulty of a beatmap.
67
+ */
68
+ this.difficultyAdjustmentMods = new Set([
69
+ osuBase.ModDoubleTime,
70
+ osuBase.ModNightCore,
71
+ osuBase.ModDifficultyAdjust,
72
+ osuBase.ModCustomSpeed,
73
+ osuBase.ModHalfTime,
74
+ osuBase.ModEasy,
75
+ osuBase.ModHardRock,
76
+ osuBase.ModFlashlight,
77
+ osuBase.ModHidden,
78
+ osuBase.ModRelax,
79
+ osuBase.ModAutopilot,
80
+ ]);
81
+ }
82
+ calculate(beatmap, mods = []) {
83
+ const playableBeatmap = beatmap instanceof osuBase.PlayableBeatmap
84
+ ? beatmap
85
+ : this.createPlayableBeatmap(beatmap, mods);
86
+ const skills = this.createSkills(playableBeatmap);
87
+ const objects = this.createDifficultyHitObjects(playableBeatmap);
88
+ for (const object of objects) {
92
89
  for (const skill of skills) {
93
90
  skill.process(object);
94
91
  }
95
92
  }
93
+ return this.createDifficultyAttributes(playableBeatmap, skills, objects);
96
94
  }
97
- /**
98
- * Obtains the clock rate of the beatmap.
99
- *
100
- * @param options The options to obtain the clock rate with.
101
- * @returns The clock rate of the beatmap.
102
- */
103
- calculateClockRate(options) {
104
- var _a, _b;
105
- return (osuBase.ModUtil.calculateRateWithMods((_a = options === null || options === void 0 ? void 0 : options.mods) !== null && _a !== void 0 ? _a : []) *
106
- ((_b = options === null || options === void 0 ? void 0 : options.customSpeedMultiplier) !== null && _b !== void 0 ? _b : 1));
107
- }
108
- /**
109
- * Populates the stored difficulty attributes with necessary data.
110
- *
111
- * @param beatmap The beatmap to populate the attributes with.
112
- * @param clockRate The clock rate of the beatmap.
113
- */
114
- populateDifficultyAttributes(beatmap, clockRate) {
115
- this.attributes.hitCircleCount = this.beatmap.hitObjects.circles;
116
- this.attributes.maxCombo = this.beatmap.maxCombo;
117
- this.attributes.mods = this.mods.slice();
118
- this.attributes.sliderCount = this.beatmap.hitObjects.sliders;
119
- this.attributes.spinnerCount = this.beatmap.hitObjects.spinners;
120
- this.attributes.clockRate = clockRate;
121
- let greatWindow;
122
- switch (this.mode) {
123
- case osuBase.Modes.droid:
124
- if (this.mods.some((m) => m instanceof osuBase.ModPrecise)) {
125
- greatWindow = new osuBase.PreciseDroidHitWindow(beatmap.difficulty.od).greatWindow;
126
- }
127
- else {
128
- greatWindow = new osuBase.DroidHitWindow(beatmap.difficulty.od)
129
- .greatWindow;
130
- }
131
- break;
132
- case osuBase.Modes.osu:
133
- greatWindow = new osuBase.OsuHitWindow(beatmap.difficulty.od)
134
- .greatWindow;
135
- break;
95
+ calculateStrainPeaks(beatmap, mods = []) {
96
+ const playableBeatmap = beatmap instanceof osuBase.PlayableBeatmap
97
+ ? beatmap
98
+ : this.createPlayableBeatmap(beatmap, mods);
99
+ const skills = this.createStrainPeakSkills(playableBeatmap);
100
+ const objects = this.createDifficultyHitObjects(playableBeatmap);
101
+ for (const object of objects) {
102
+ for (const skill of skills) {
103
+ skill.process(object);
104
+ }
136
105
  }
137
- this.attributes.overallDifficulty = osuBase.OsuHitWindow.greatWindowToOD(greatWindow / clockRate);
106
+ return {
107
+ aimWithSliders: skills[0].strainPeaks,
108
+ aimWithoutSliders: skills[1].strainPeaks,
109
+ speed: skills[2].strainPeaks,
110
+ flashlight: skills[3].strainPeaks,
111
+ };
138
112
  }
139
113
  /**
140
- * Calculates the star rating value of a difficulty.
114
+ * Calculates the base rating of a `Skill`.
141
115
  *
142
- * @param difficulty The difficulty to calculate.
116
+ * @param skill The `Skill` to calculate the rating of.
117
+ * @returns The rating of the `Skill`.
143
118
  */
144
- starValue(difficulty) {
145
- return Math.sqrt(difficulty) * this.difficultyMultiplier;
119
+ calculateRating(skill) {
120
+ return Math.sqrt(skill.difficultyValue()) * this.difficultyMultiplier;
146
121
  }
147
122
  /**
148
123
  * Calculates the base performance value of a difficulty rating.
@@ -153,10 +128,6 @@ class DifficultyCalculator {
153
128
  return Math.pow(5 * Math.max(1, rating / 0.0675) - 4, 3) / 100000;
154
129
  }
155
130
  }
156
- /**
157
- * `Mod`s that adjust the difficulty of a beatmap.
158
- */
159
- DifficultyCalculator.difficultyAdjustmentMods = new Set();
160
131
 
161
132
  /**
162
133
  * Represents a hit object with difficulty calculation values.
@@ -178,7 +149,7 @@ class DifficultyHitObject {
178
149
  * @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
179
150
  * @param clockRate The clock rate of the beatmap.
180
151
  */
181
- constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate) {
152
+ constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate, index) {
182
153
  var _a, _b, _c, _d;
183
154
  /**
184
155
  * The aim strain generated by the hitobject if sliders are considered.
@@ -235,6 +206,7 @@ class DifficultyHitObject {
235
206
  this.lastObject = lastObject;
236
207
  this.lastLastObject = lastLastObject;
237
208
  this.hitObjects = difficultyHitObjects;
209
+ this.index = index;
238
210
  if (object instanceof osuBase.Slider) {
239
211
  this.fullGreatWindow =
240
212
  ((_b = (_a = object.head.hitWindow) === null || _a === void 0 ? void 0 : _a.greatWindow) !== null && _b !== void 0 ? _b : 1200) * 2;
@@ -243,7 +215,6 @@ class DifficultyHitObject {
243
215
  this.fullGreatWindow = ((_d = (_c = object.hitWindow) === null || _c === void 0 ? void 0 : _c.greatWindow) !== null && _d !== void 0 ? _d : 1200) * 2;
244
216
  }
245
217
  this.fullGreatWindow /= clockRate;
246
- this.index = difficultyHitObjects.length - 1;
247
218
  // Capped to 25ms to prevent difficulty calculation breaking from simultaneous objects.
248
219
  this.startTime = object.startTime / clockRate;
249
220
  this.endTime = object.endTime / clockRate;
@@ -280,7 +251,7 @@ class DifficultyHitObject {
280
251
  */
281
252
  previous(backwardsIndex) {
282
253
  var _a;
283
- return (_a = this.hitObjects[this.index - backwardsIndex]) !== null && _a !== void 0 ? _a : null;
254
+ return ((_a = this.hitObjects[this.index - backwardsIndex - 1]) !== null && _a !== void 0 ? _a : null);
284
255
  }
285
256
  /**
286
257
  * Gets the difficulty hitobject at a specific index with respect to the current
@@ -294,7 +265,7 @@ class DifficultyHitObject {
294
265
  */
295
266
  next(forwardsIndex) {
296
267
  var _a;
297
- return ((_a = this.hitObjects[this.index + forwardsIndex + 2]) !== null && _a !== void 0 ? _a : null);
268
+ return ((_a = this.hitObjects[this.index + forwardsIndex + 1]) !== null && _a !== void 0 ? _a : null);
298
269
  }
299
270
  /**
300
271
  * Calculates the opacity of the hitobject at a given time.
@@ -545,8 +516,8 @@ class DroidDifficultyHitObject extends DifficultyHitObject {
545
516
  * @param difficultyHitObjects All difficulty hitobjects in the processed beatmap.
546
517
  * @param clockRate The clock rate of the beatmap.
547
518
  */
548
- constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate) {
549
- super(object, lastObject, lastLastObject, difficultyHitObjects, clockRate);
519
+ constructor(object, lastObject, lastLastObject, difficultyHitObjects, clockRate, index) {
520
+ super(object, lastObject, lastLastObject, difficultyHitObjects, clockRate, index);
550
521
  /**
551
522
  * The tap strain generated by the hitobject.
552
523
  */
@@ -603,6 +574,14 @@ class DroidDifficultyHitObject extends DifficultyHitObject {
603
574
  }
604
575
  return super.opacityAt(time, mods);
605
576
  }
577
+ previous(backwardsIndex) {
578
+ var _a;
579
+ return (_a = this.hitObjects[this.index - backwardsIndex]) !== null && _a !== void 0 ? _a : null;
580
+ }
581
+ next(forwardsIndex) {
582
+ var _a;
583
+ return ((_a = this.hitObjects[this.index + forwardsIndex + 2]) !== null && _a !== void 0 ? _a : null);
584
+ }
606
585
  /**
607
586
  * Determines whether this hitobject is considered overlapping with the hitobject before it.
608
587
  *
@@ -1008,6 +987,9 @@ class StrainSkill extends Skill {
1008
987
  */
1009
988
  class DroidSkill extends StrainSkill {
1010
989
  process(current) {
990
+ if (current.index < 0) {
991
+ return;
992
+ }
1011
993
  super.process(current);
1012
994
  this._objectStrains.push(this.getObjectStrain(current));
1013
995
  }
@@ -1096,132 +1078,41 @@ class DroidAim extends DroidSkill {
1096
1078
  }
1097
1079
 
1098
1080
  /**
1099
- * An evaluator for calculating osu!droid tap skill.
1100
- */
1101
- class DroidTapEvaluator {
1102
- /**
1103
- * Evaluates the difficulty of tapping the current object, based on:
1104
- *
1105
- * - time between pressing the previous and current object,
1106
- * - distance between those objects,
1107
- * - how easily they can be cheesed,
1108
- * - and the strain time cap.
1109
- *
1110
- * @param current The current object.
1111
- * @param considerCheesability Whether to consider cheesability.
1112
- * @param strainTimeCap The strain time to cap the object's strain time to.
1113
- */
1114
- static evaluateDifficultyOf(current, considerCheesability, strainTimeCap) {
1115
- if (current.object instanceof osuBase.Spinner ||
1116
- // Exclude overlapping objects that can be tapped at once.
1117
- current.isOverlapping(false)) {
1118
- return 0;
1119
- }
1120
- const doubletapness = considerCheesability
1121
- ? 1 - current.doubletapness
1122
- : 1;
1123
- const strainTime = strainTimeCap !== undefined
1124
- ? // We cap the strain time to 50 here as the chance of vibro is higher in any BPM higher than 300.
1125
- Math.max(50, strainTimeCap, current.strainTime)
1126
- : current.strainTime;
1127
- let speedBonus = 1;
1128
- if (strainTime < this.minSpeedBonus) {
1129
- speedBonus +=
1130
- 0.75 *
1131
- Math.pow(osuBase.ErrorFunction.erf((this.minSpeedBonus - strainTime) / 40), 2);
1132
- }
1133
- return (speedBonus * Math.pow(doubletapness, 1.5) * 1000) / strainTime;
1134
- }
1135
- }
1136
- // ~200 1/4 BPM streams
1137
- DroidTapEvaluator.minSpeedBonus = 75;
1138
-
1139
- /**
1140
- * Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
1081
+ * Holds data that can be used to calculate osu!droid performance points.
1141
1082
  */
1142
- class DroidTap extends DroidSkill {
1143
- /**
1144
- * The delta time of hitobjects.
1145
- */
1146
- get objectDeltaTimes() {
1147
- return this._objectDeltaTimes;
1148
- }
1149
- constructor(mods, considerCheesability, strainTimeCap) {
1150
- super(mods);
1151
- this.reducedSectionCount = 10;
1152
- this.reducedSectionBaseline = 0.75;
1153
- this.strainDecayBase = 0.3;
1154
- this.starsPerDouble = 1.1;
1155
- this.currentTapStrain = 0;
1156
- this.currentRhythmMultiplier = 0;
1157
- this.skillMultiplier = 1.375;
1158
- this._objectDeltaTimes = [];
1159
- this.considerCheesability = considerCheesability;
1160
- this.strainTimeCap = strainTimeCap;
1161
- }
1162
- /**
1163
- * The amount of notes that are relevant to the difficulty.
1164
- */
1165
- relevantNoteCount() {
1166
- if (this._objectStrains.length === 0) {
1167
- return 0;
1168
- }
1169
- const maxStrain = osuBase.MathUtils.max(this._objectStrains);
1170
- if (maxStrain === 0) {
1171
- return 0;
1172
- }
1173
- return this._objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
1174
- }
1175
- /**
1176
- * The delta time relevant to the difficulty.
1177
- */
1178
- relevantDeltaTime() {
1179
- if (this._objectStrains.length === 0) {
1180
- return 0;
1181
- }
1182
- const maxStrain = osuBase.MathUtils.max(this._objectStrains);
1183
- if (maxStrain === 0) {
1184
- return 0;
1185
- }
1186
- return (this._objectDeltaTimes.reduce((total, next, index) => total +
1187
- (next * 1) /
1188
- (1 +
1189
- Math.exp(-((this._objectStrains[index] / maxStrain) *
1190
- 25 -
1191
- 20))), 0) /
1192
- this._objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 25 - 20))), 0));
1193
- }
1194
- strainValueAt(current) {
1195
- this.currentTapStrain *= this.strainDecay(current.strainTime);
1196
- this.currentTapStrain +=
1197
- DroidTapEvaluator.evaluateDifficultyOf(current, this.considerCheesability, this.strainTimeCap) * this.skillMultiplier;
1198
- this.currentRhythmMultiplier = current.rhythmMultiplier;
1199
- this._objectDeltaTimes.push(current.deltaTime);
1200
- return this.currentTapStrain * current.rhythmMultiplier;
1201
- }
1202
- calculateInitialStrain(time, current) {
1203
- var _a, _b;
1204
- return (this.currentTapStrain *
1205
- this.currentRhythmMultiplier *
1206
- this.strainDecay(time - ((_b = (_a = current.previous(0)) === null || _a === void 0 ? void 0 : _a.startTime) !== null && _b !== void 0 ? _b : 0)));
1207
- }
1208
- getObjectStrain() {
1209
- return this.currentTapStrain * this.currentRhythmMultiplier;
1210
- }
1211
- /**
1212
- * @param current The hitobject to save to.
1213
- */
1214
- saveToHitObject(current) {
1215
- if (this.strainTimeCap !== undefined) {
1083
+ class DroidDifficultyAttributes extends DifficultyAttributes {
1084
+ constructor(cacheableAttributes) {
1085
+ super(cacheableAttributes);
1086
+ this.tapDifficulty = 0;
1087
+ this.rhythmDifficulty = 0;
1088
+ this.visualDifficulty = 0;
1089
+ this.tapDifficultStrainCount = 0;
1090
+ this.flashlightDifficultStrainCount = 0;
1091
+ this.visualDifficultStrainCount = 0;
1092
+ this.averageSpeedDeltaTime = 0;
1093
+ this.vibroFactor = 1;
1094
+ if (!cacheableAttributes) {
1216
1095
  return;
1217
1096
  }
1218
- const strain = this.currentTapStrain * this.currentRhythmMultiplier;
1219
- if (this.considerCheesability) {
1220
- current.tapStrain = strain;
1221
- }
1222
- else {
1223
- current.originalTapStrain = strain;
1224
- }
1097
+ this.tapDifficulty = cacheableAttributes.tapDifficulty;
1098
+ this.rhythmDifficulty = cacheableAttributes.rhythmDifficulty;
1099
+ this.visualDifficulty = cacheableAttributes.visualDifficulty;
1100
+ this.tapDifficultStrainCount =
1101
+ cacheableAttributes.tapDifficultStrainCount;
1102
+ this.flashlightDifficultStrainCount =
1103
+ cacheableAttributes.flashlightDifficultStrainCount;
1104
+ this.visualDifficultStrainCount =
1105
+ cacheableAttributes.visualDifficultStrainCount;
1106
+ this.averageSpeedDeltaTime = cacheableAttributes.averageSpeedDeltaTime;
1107
+ this.vibroFactor = cacheableAttributes.vibroFactor;
1108
+ }
1109
+ toString() {
1110
+ return (super.toString() +
1111
+ ` (${this.aimDifficulty.toFixed(2)} aim, ` +
1112
+ `${this.tapDifficulty.toFixed(2)} tap, ` +
1113
+ `${this.rhythmDifficulty.toFixed(2)} rhythm, ` +
1114
+ `${this.flashlightDifficulty.toFixed(2)} flashlight, ` +
1115
+ `${this.visualDifficulty.toFixed(2)} visual)`);
1225
1116
  }
1226
1117
  }
1227
1118
 
@@ -1599,52 +1490,182 @@ class DroidRhythm extends DroidSkill {
1599
1490
  }
1600
1491
 
1601
1492
  /**
1602
- * An evaluator for calculating osu!droid visual skill.
1493
+ * An evaluator for calculating osu!droid tap skill.
1603
1494
  */
1604
- class DroidVisualEvaluator {
1495
+ class DroidTapEvaluator {
1605
1496
  /**
1606
- * Evaluates the difficulty of reading the current object, based on:
1497
+ * Evaluates the difficulty of tapping the current object, based on:
1607
1498
  *
1608
- * - note density of the current object,
1609
- * - overlapping factor of the current object,
1610
- * - the preempt time of the current object,
1611
- * - the visual opacity of the current object,
1612
- * - the velocity of the current object if it's a slider,
1613
- * - past objects' velocity if they are sliders,
1614
- * - and whether the Hidden mod is enabled.
1499
+ * - time between pressing the previous and current object,
1500
+ * - distance between those objects,
1501
+ * - how easily they can be cheesed,
1502
+ * - and the strain time cap.
1615
1503
  *
1616
1504
  * @param current The current object.
1617
- * @param mods The mods used.
1618
- * @param withSliders Whether to take slider difficulty into account.
1505
+ * @param considerCheesability Whether to consider cheesability.
1506
+ * @param strainTimeCap The strain time to cap the object's strain time to.
1619
1507
  */
1620
- static evaluateDifficultyOf(current, mods, withSliders) {
1508
+ static evaluateDifficultyOf(current, considerCheesability, strainTimeCap) {
1621
1509
  if (current.object instanceof osuBase.Spinner ||
1622
1510
  // Exclude overlapping objects that can be tapped at once.
1623
- current.isOverlapping(true) ||
1624
- current.index === 0) {
1511
+ current.isOverlapping(false)) {
1625
1512
  return 0;
1626
1513
  }
1627
- // Start with base density and give global bonus for Hidden.
1628
- // Add density caps for sanity.
1629
- let strain;
1630
- if (mods.some((m) => m instanceof osuBase.ModHidden)) {
1631
- strain = Math.min(30, Math.pow(current.noteDensity, 3));
1632
- }
1633
- else if (mods.some((m) => m instanceof osuBase.ModTraceable)) {
1634
- // Give more bonus for hit circles due to there being no circle piece.
1635
- if (current.object instanceof osuBase.Circle) {
1636
- strain = Math.min(25, Math.pow(current.noteDensity, 2.5));
1637
- }
1638
- else {
1639
- strain = Math.min(22.5, Math.pow(current.noteDensity, 2.25));
1640
- }
1641
- }
1642
- else {
1643
- strain = Math.min(20, Math.pow(current.noteDensity, 2));
1514
+ const doubletapness = considerCheesability
1515
+ ? 1 - current.doubletapness
1516
+ : 1;
1517
+ const strainTime = strainTimeCap !== undefined
1518
+ ? // We cap the strain time to 50 here as the chance of vibro is higher in any BPM higher than 300.
1519
+ Math.max(50, strainTimeCap, current.strainTime)
1520
+ : current.strainTime;
1521
+ let speedBonus = 1;
1522
+ if (strainTime < this.minSpeedBonus) {
1523
+ speedBonus +=
1524
+ 0.75 *
1525
+ Math.pow(osuBase.ErrorFunction.erf((this.minSpeedBonus - strainTime) / 40), 2);
1644
1526
  }
1645
- // Bonus based on how visible the object is.
1646
- for (let i = 0; i < Math.min(current.index, 10); ++i) {
1647
- const previous = current.previous(i);
1527
+ return (speedBonus * Math.pow(doubletapness, 1.5) * 1000) / strainTime;
1528
+ }
1529
+ }
1530
+ // ~200 1/4 BPM streams
1531
+ DroidTapEvaluator.minSpeedBonus = 75;
1532
+
1533
+ /**
1534
+ * Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
1535
+ */
1536
+ class DroidTap extends DroidSkill {
1537
+ /**
1538
+ * The delta time of hitobjects.
1539
+ */
1540
+ get objectDeltaTimes() {
1541
+ return this._objectDeltaTimes;
1542
+ }
1543
+ constructor(mods, considerCheesability, strainTimeCap) {
1544
+ super(mods);
1545
+ this.reducedSectionCount = 10;
1546
+ this.reducedSectionBaseline = 0.75;
1547
+ this.strainDecayBase = 0.3;
1548
+ this.starsPerDouble = 1.1;
1549
+ this.currentTapStrain = 0;
1550
+ this.currentRhythmMultiplier = 0;
1551
+ this.skillMultiplier = 1.375;
1552
+ this._objectDeltaTimes = [];
1553
+ this.considerCheesability = considerCheesability;
1554
+ this.strainTimeCap = strainTimeCap;
1555
+ }
1556
+ /**
1557
+ * The amount of notes that are relevant to the difficulty.
1558
+ */
1559
+ relevantNoteCount() {
1560
+ if (this._objectStrains.length === 0) {
1561
+ return 0;
1562
+ }
1563
+ const maxStrain = osuBase.MathUtils.max(this._objectStrains);
1564
+ if (maxStrain === 0) {
1565
+ return 0;
1566
+ }
1567
+ return this._objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
1568
+ }
1569
+ /**
1570
+ * The delta time relevant to the difficulty.
1571
+ */
1572
+ relevantDeltaTime() {
1573
+ if (this._objectStrains.length === 0) {
1574
+ return 0;
1575
+ }
1576
+ const maxStrain = osuBase.MathUtils.max(this._objectStrains);
1577
+ if (maxStrain === 0) {
1578
+ return 0;
1579
+ }
1580
+ return (this._objectDeltaTimes.reduce((total, next, index) => total +
1581
+ (next * 1) /
1582
+ (1 +
1583
+ Math.exp(-((this._objectStrains[index] / maxStrain) *
1584
+ 25 -
1585
+ 20))), 0) /
1586
+ this._objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 25 - 20))), 0));
1587
+ }
1588
+ strainValueAt(current) {
1589
+ this.currentTapStrain *= this.strainDecay(current.strainTime);
1590
+ this.currentTapStrain +=
1591
+ DroidTapEvaluator.evaluateDifficultyOf(current, this.considerCheesability, this.strainTimeCap) * this.skillMultiplier;
1592
+ this.currentRhythmMultiplier = current.rhythmMultiplier;
1593
+ this._objectDeltaTimes.push(current.deltaTime);
1594
+ return this.currentTapStrain * current.rhythmMultiplier;
1595
+ }
1596
+ calculateInitialStrain(time, current) {
1597
+ var _a, _b;
1598
+ return (this.currentTapStrain *
1599
+ this.currentRhythmMultiplier *
1600
+ this.strainDecay(time - ((_b = (_a = current.previous(0)) === null || _a === void 0 ? void 0 : _a.startTime) !== null && _b !== void 0 ? _b : 0)));
1601
+ }
1602
+ getObjectStrain() {
1603
+ return this.currentTapStrain * this.currentRhythmMultiplier;
1604
+ }
1605
+ /**
1606
+ * @param current The hitobject to save to.
1607
+ */
1608
+ saveToHitObject(current) {
1609
+ if (this.strainTimeCap !== undefined) {
1610
+ return;
1611
+ }
1612
+ const strain = this.currentTapStrain * this.currentRhythmMultiplier;
1613
+ if (this.considerCheesability) {
1614
+ current.tapStrain = strain;
1615
+ }
1616
+ else {
1617
+ current.originalTapStrain = strain;
1618
+ }
1619
+ }
1620
+ }
1621
+
1622
+ /**
1623
+ * An evaluator for calculating osu!droid visual skill.
1624
+ */
1625
+ class DroidVisualEvaluator {
1626
+ /**
1627
+ * Evaluates the difficulty of reading the current object, based on:
1628
+ *
1629
+ * - note density of the current object,
1630
+ * - overlapping factor of the current object,
1631
+ * - the preempt time of the current object,
1632
+ * - the visual opacity of the current object,
1633
+ * - the velocity of the current object if it's a slider,
1634
+ * - past objects' velocity if they are sliders,
1635
+ * - and whether the Hidden mod is enabled.
1636
+ *
1637
+ * @param current The current object.
1638
+ * @param mods The mods used.
1639
+ * @param withSliders Whether to take slider difficulty into account.
1640
+ */
1641
+ static evaluateDifficultyOf(current, mods, withSliders) {
1642
+ if (current.object instanceof osuBase.Spinner ||
1643
+ // Exclude overlapping objects that can be tapped at once.
1644
+ current.isOverlapping(true) ||
1645
+ current.index === 0) {
1646
+ return 0;
1647
+ }
1648
+ // Start with base density and give global bonus for Hidden.
1649
+ // Add density caps for sanity.
1650
+ let strain;
1651
+ if (mods.some((m) => m instanceof osuBase.ModHidden)) {
1652
+ strain = Math.min(30, Math.pow(current.noteDensity, 3));
1653
+ }
1654
+ else if (mods.some((m) => m instanceof osuBase.ModTraceable)) {
1655
+ // Give more bonus for hit circles due to there being no circle piece.
1656
+ if (current.object instanceof osuBase.Circle) {
1657
+ strain = Math.min(25, Math.pow(current.noteDensity, 2.5));
1658
+ }
1659
+ else {
1660
+ strain = Math.min(22.5, Math.pow(current.noteDensity, 2.25));
1661
+ }
1662
+ }
1663
+ else {
1664
+ strain = Math.min(20, Math.pow(current.noteDensity, 2));
1665
+ }
1666
+ // Bonus based on how visible the object is.
1667
+ for (let i = 0; i < Math.min(current.index, 10); ++i) {
1668
+ const previous = current.previous(i);
1648
1669
  if (previous.object instanceof osuBase.Spinner ||
1649
1670
  // Exclude overlapping objects that can be tapped at once.
1650
1671
  previous.isOverlapping(true)) {
@@ -1745,151 +1766,78 @@ class DroidVisual extends DroidSkill {
1745
1766
  }
1746
1767
  }
1747
1768
 
1769
+ /**
1770
+ * Holds data that can be used to calculate osu!droid performance points as well
1771
+ * as doing some analysis using the replay of a score.
1772
+ */
1773
+ class ExtendedDroidDifficultyAttributes extends DroidDifficultyAttributes {
1774
+ constructor(cacheableAttributes) {
1775
+ super(cacheableAttributes);
1776
+ this.mode = "rebalance";
1777
+ this.possibleThreeFingeredSections = [];
1778
+ this.difficultSliders = [];
1779
+ this.aimNoteCount = 0;
1780
+ this.flashlightSliderFactor = 1;
1781
+ this.visualSliderFactor = 1;
1782
+ if (!cacheableAttributes) {
1783
+ return;
1784
+ }
1785
+ this.possibleThreeFingeredSections =
1786
+ cacheableAttributes.possibleThreeFingeredSections;
1787
+ this.difficultSliders = cacheableAttributes.difficultSliders;
1788
+ this.aimNoteCount = cacheableAttributes.aimNoteCount;
1789
+ this.flashlightSliderFactor =
1790
+ cacheableAttributes.flashlightSliderFactor;
1791
+ this.visualSliderFactor = cacheableAttributes.visualSliderFactor;
1792
+ }
1793
+ }
1794
+
1748
1795
  /**
1749
1796
  * A difficulty calculator for osu!droid gamemode.
1750
1797
  */
1751
1798
  class DroidDifficultyCalculator extends DifficultyCalculator {
1752
1799
  constructor() {
1753
- super(...arguments);
1754
- this.attributes = {
1755
- mode: "rebalance",
1756
- aimDifficultSliderCount: 0,
1757
- tapDifficulty: 0,
1758
- rhythmDifficulty: 0,
1759
- visualDifficulty: 0,
1760
- aimNoteCount: 0,
1761
- mods: [],
1762
- starRating: 0,
1763
- maxCombo: 0,
1764
- aimDifficulty: 0,
1765
- flashlightDifficulty: 0,
1766
- speedNoteCount: 0,
1767
- sliderFactor: 0,
1768
- clockRate: 1,
1769
- overallDifficulty: 0,
1770
- hitCircleCount: 0,
1771
- sliderCount: 0,
1772
- spinnerCount: 0,
1773
- aimDifficultStrainCount: 0,
1774
- tapDifficultStrainCount: 0,
1775
- flashlightDifficultStrainCount: 0,
1776
- visualDifficultStrainCount: 0,
1777
- flashlightSliderFactor: 0,
1778
- visualSliderFactor: 0,
1779
- possibleThreeFingeredSections: [],
1780
- difficultSliders: [],
1781
- averageSpeedDeltaTime: 0,
1782
- vibroFactor: 1,
1783
- };
1800
+ super();
1784
1801
  this.difficultyMultiplier = 0.18;
1785
- this.mode = osuBase.Modes.droid;
1786
- }
1787
- /**
1788
- * The aim star rating of the beatmap.
1789
- */
1790
- get aim() {
1791
- return this.attributes.aimDifficulty;
1792
- }
1793
- /**
1794
- * The tap star rating of the beatmap.
1795
- */
1796
- get tap() {
1797
- return this.attributes.tapDifficulty;
1798
- }
1799
- /**
1800
- * The rhythm star rating of the beatmap.
1801
- */
1802
- get rhythm() {
1803
- return this.attributes.rhythmDifficulty;
1804
- }
1805
- /**
1806
- * The flashlight star rating of the beatmap.
1807
- */
1808
- get flashlight() {
1809
- return this.attributes.flashlightDifficulty;
1810
- }
1811
- /**
1812
- * The visual star rating of the beatmap.
1813
- */
1814
- get visual() {
1815
- return this.attributes.visualDifficulty;
1816
- }
1817
- get cacheableAttributes() {
1818
- return Object.assign(Object.assign({}, this.attributes), { mods: osuBase.ModUtil.modsToOsuString(this.attributes.mods) });
1819
- }
1820
- // Override to use DroidDifficultyCalculationOptions
1821
- calculate(options) {
1822
- return super.calculate(options);
1823
- }
1824
- /**
1825
- * Calculates the aim star rating of the beatmap and stores it in this instance.
1826
- */
1827
- calculateAim() {
1828
- if (this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
1829
- this.attributes.aimDifficulty = 0;
1830
- return;
1831
- }
1832
- const aimSkill = new DroidAim(this.mods, true);
1833
- const aimSkillWithoutSliders = new DroidAim(this.mods, false);
1834
- this.calculateSkills(aimSkill, aimSkillWithoutSliders);
1835
- this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
1836
- }
1837
- /**
1838
- * Calculates the tap star rating of the beatmap and stores it in this instance.
1839
- */
1840
- calculateTap() {
1841
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
1842
- this.attributes.tapDifficulty = 0;
1843
- return;
1844
- }
1845
- const tapSkillCheese = new DroidTap(this.mods, true);
1846
- const tapSkillNoCheese = new DroidTap(this.mods, false);
1847
- this.calculateSkills(tapSkillCheese, tapSkillNoCheese);
1848
- const tapSkillVibro = new DroidTap(this.mods, true, tapSkillCheese.relevantDeltaTime());
1849
- this.calculateSkills(tapSkillVibro);
1850
- this.postCalculateTap(tapSkillCheese, tapSkillVibro);
1851
- }
1852
- /**
1853
- * Calculates the rhythm star rating of the beatmap and stores it in this instance.
1854
- */
1855
- calculateRhythm() {
1856
- const rhythmSkill = new DroidRhythm(this.mods);
1857
- this.calculateSkills(rhythmSkill);
1858
- this.postCalculateRhythm(rhythmSkill);
1859
- }
1860
- /**
1861
- * Calculates the flashlight star rating of the beatmap and stores it in this instance.
1862
- */
1863
- calculateFlashlight() {
1864
- if (!this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
1865
- this.attributes.flashlightDifficulty = 0;
1866
- return;
1867
- }
1868
- const flashlightSkill = new DroidFlashlight(this.mods, true);
1869
- const flashlightSkillWithoutSliders = new DroidFlashlight(this.mods, false);
1870
- this.calculateSkills(flashlightSkill, flashlightSkillWithoutSliders);
1871
- this.postCalculateFlashlight(flashlightSkill, flashlightSkillWithoutSliders);
1872
- }
1873
- /**
1874
- * Calculates the visual star rating of the beatmap and stores it in this instance.
1875
- */
1876
- calculateVisual() {
1877
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
1878
- this.attributes.visualDifficulty = 0;
1879
- return;
1880
- }
1881
- const visualSkill = new DroidVisual(this.mods, true);
1882
- const visualSkillWithoutSliders = new DroidVisual(this.mods, false);
1883
- this.calculateSkills(visualSkill, visualSkillWithoutSliders);
1884
- this.postCalculateVisual(visualSkill, visualSkillWithoutSliders);
1885
- }
1886
- calculateTotal() {
1887
- const aimPerformanceValue = this.basePerformanceValue(Math.pow(this.aim, 0.8));
1888
- const tapPerformanceValue = this.basePerformanceValue(this.tap);
1889
- const flashlightPerformanceValue = this.mods.some((m) => m instanceof osuBase.ModFlashlight)
1890
- ? Math.pow(this.flashlight, 1.6) * 25
1891
- : 0;
1892
- const visualPerformanceValue = Math.pow(this.visual, 1.6) * 22.5;
1802
+ this.difficultyAdjustmentMods
1803
+ .add(osuBase.ModPrecise)
1804
+ .add(osuBase.ModScoreV2)
1805
+ .add(osuBase.ModTraceable);
1806
+ }
1807
+ retainDifficultyAdjustmentMods(mods) {
1808
+ return mods.filter((mod) => mod.isApplicableToDroid() &&
1809
+ this.difficultyAdjustmentMods.has(mod.constructor) &&
1810
+ mod.isDroidRelevant);
1811
+ }
1812
+ createDifficultyAttributes(beatmap, skills, objects) {
1813
+ const attributes = new ExtendedDroidDifficultyAttributes();
1814
+ attributes.mods = beatmap.mods.slice();
1815
+ attributes.maxCombo = beatmap.maxCombo;
1816
+ attributes.clockRate = beatmap.speedMultiplier;
1817
+ attributes.hitCircleCount = beatmap.hitObjects.circles;
1818
+ attributes.sliderCount = beatmap.hitObjects.sliders;
1819
+ attributes.spinnerCount = beatmap.hitObjects.spinners;
1820
+ this.populateAimAttributes(attributes, skills, objects);
1821
+ this.populateTapAttributes(attributes, skills, objects);
1822
+ this.populateRhythmAttributes(attributes, skills);
1823
+ this.populateFlashlightAttributes(attributes, skills);
1824
+ this.populateVisualAttributes(attributes, skills);
1825
+ if (attributes.mods.some((m) => m instanceof osuBase.ModRelax)) {
1826
+ attributes.aimDifficulty *= 0.9;
1827
+ attributes.tapDifficulty = 0;
1828
+ attributes.rhythmDifficulty = 0;
1829
+ attributes.flashlightDifficulty *= 0.7;
1830
+ attributes.visualDifficulty = 0;
1831
+ }
1832
+ else if (attributes.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
1833
+ attributes.aimDifficulty = 0;
1834
+ attributes.flashlightDifficulty *= 0.3;
1835
+ attributes.visualDifficulty *= 0.8;
1836
+ }
1837
+ const aimPerformanceValue = this.basePerformanceValue(Math.pow(attributes.aimDifficulty, 0.8));
1838
+ const tapPerformanceValue = this.basePerformanceValue(attributes.tapDifficulty);
1839
+ const flashlightPerformanceValue = Math.pow(attributes.flashlightDifficulty, 1.6) * 25;
1840
+ const visualPerformanceValue = Math.pow(attributes.visualDifficulty, 1.6) * 22.5;
1893
1841
  const basePerformanceValue = Math.pow(Math.pow(aimPerformanceValue, 1.1) +
1894
1842
  Math.pow(tapPerformanceValue, 1.1) +
1895
1843
  Math.pow(flashlightPerformanceValue, 1.1) +
@@ -1897,126 +1845,82 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
1897
1845
  if (basePerformanceValue > 1e-5) {
1898
1846
  // Document for formula derivation:
1899
1847
  // https://docs.google.com/document/d/10DZGYYSsT_yjz2Mtp6yIJld0Rqx4E-vVHupCqiM4TNI/edit
1900
- this.attributes.starRating =
1848
+ attributes.starRating =
1901
1849
  0.027 *
1902
1850
  (Math.cbrt((100000 / Math.pow(2, 1 / 1.1)) * basePerformanceValue) +
1903
1851
  4);
1904
1852
  }
1905
1853
  else {
1906
- this.attributes.starRating = 0;
1907
- }
1908
- }
1909
- calculateAll() {
1910
- const skills = this.createSkills();
1911
- this.calculateSkills(...skills);
1912
- const aimSkill = skills.find((s) => s instanceof DroidAim && s.withSliders);
1913
- const aimSkillWithoutSliders = skills.find((s) => s instanceof DroidAim && !s.withSliders);
1914
- const rhythmSkill = skills.find((s) => s instanceof DroidRhythm);
1915
- const tapSkillCheese = skills.find((s) => s instanceof DroidTap && s.considerCheesability);
1916
- const flashlightSkill = skills.find((s) => s instanceof DroidFlashlight && s.withSliders);
1917
- const flashlightSkillWithoutSliders = skills.find((s) => s instanceof DroidFlashlight && !s.withSliders);
1918
- const visualSkill = skills.find((s) => s instanceof DroidVisual && s.withSliders);
1919
- const visualSkillWithoutSliders = skills.find((s) => s instanceof DroidVisual && !s.withSliders);
1920
- if (aimSkill && aimSkillWithoutSliders) {
1921
- this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
1922
- }
1923
- if (tapSkillCheese) {
1924
- const tapSkillVibro = new DroidTap(this.mods, true, tapSkillCheese.relevantDeltaTime());
1925
- this.calculateSkills(tapSkillVibro);
1926
- this.postCalculateTap(tapSkillCheese, tapSkillVibro);
1854
+ attributes.starRating = 0;
1927
1855
  }
1928
- this.postCalculateRhythm(rhythmSkill);
1929
- if (flashlightSkill && flashlightSkillWithoutSliders) {
1930
- this.postCalculateFlashlight(flashlightSkill, flashlightSkillWithoutSliders);
1856
+ let greatWindow;
1857
+ if (attributes.mods.some((m) => m instanceof osuBase.ModPrecise)) {
1858
+ greatWindow = new osuBase.PreciseDroidHitWindow(beatmap.difficulty.od)
1859
+ .greatWindow;
1931
1860
  }
1932
- if (visualSkill && visualSkillWithoutSliders) {
1933
- this.postCalculateVisual(visualSkill, visualSkillWithoutSliders);
1861
+ else {
1862
+ greatWindow = new osuBase.DroidHitWindow(beatmap.difficulty.od).greatWindow;
1934
1863
  }
1935
- this.calculateTotal();
1864
+ attributes.overallDifficulty = osuBase.OsuHitWindow.greatWindowToOD(greatWindow / attributes.clockRate);
1865
+ return attributes;
1936
1866
  }
1937
- toString() {
1938
- return (this.total.toFixed(2) +
1939
- " stars (" +
1940
- this.aim.toFixed(2) +
1941
- " aim, " +
1942
- this.tap.toFixed(2) +
1943
- " tap, " +
1944
- this.rhythm.toFixed(2) +
1945
- " rhythm, " +
1946
- this.flashlight.toFixed(2) +
1947
- " flashlight, " +
1948
- this.visual.toFixed(2) +
1949
- " visual)");
1867
+ createPlayableBeatmap(beatmap, mods) {
1868
+ return beatmap.createDroidPlayableBeatmap(mods);
1950
1869
  }
1951
- generateDifficultyHitObjects(beatmap, clockRate) {
1870
+ createDifficultyHitObjects(beatmap) {
1952
1871
  var _a, _b;
1872
+ const clockRate = beatmap.speedMultiplier;
1953
1873
  const difficultyObjects = [];
1954
1874
  const { objects } = beatmap.hitObjects;
1955
1875
  for (let i = 0; i < objects.length; ++i) {
1956
- const difficultyObject = new DroidDifficultyHitObject(objects[i], (_a = objects[i - 1]) !== null && _a !== void 0 ? _a : null, (_b = objects[i - 2]) !== null && _b !== void 0 ? _b : null, difficultyObjects, clockRate);
1876
+ const difficultyObject = new DroidDifficultyHitObject(objects[i], (_a = objects[i - 1]) !== null && _a !== void 0 ? _a : null, (_b = objects[i - 2]) !== null && _b !== void 0 ? _b : null, difficultyObjects, clockRate, i - 1);
1957
1877
  difficultyObject.computeProperties(clockRate, objects);
1958
1878
  difficultyObjects.push(difficultyObject);
1959
1879
  }
1960
1880
  return difficultyObjects;
1961
1881
  }
1962
- createSkills() {
1882
+ createSkills(beatmap) {
1883
+ const { mods } = beatmap;
1963
1884
  const skills = [];
1964
- if (!this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
1965
- skills.push(new DroidAim(this.mods, true));
1966
- skills.push(new DroidAim(this.mods, false));
1885
+ if (!mods.some((m) => m instanceof osuBase.ModAutopilot)) {
1886
+ skills.push(new DroidAim(mods, true));
1887
+ skills.push(new DroidAim(mods, false));
1967
1888
  }
1968
- if (!this.mods.some((m) => m instanceof osuBase.ModRelax)) {
1889
+ if (!mods.some((m) => m instanceof osuBase.ModRelax)) {
1969
1890
  // Tap and visual skills depend on rhythm skill, so we put it first
1970
- skills.push(new DroidRhythm(this.mods));
1971
- skills.push(new DroidTap(this.mods, true));
1972
- skills.push(new DroidTap(this.mods, false));
1973
- skills.push(new DroidVisual(this.mods, true));
1974
- skills.push(new DroidVisual(this.mods, false));
1891
+ skills.push(new DroidRhythm(mods));
1892
+ skills.push(new DroidTap(mods, true));
1893
+ skills.push(new DroidTap(mods, false));
1894
+ skills.push(new DroidVisual(mods, true));
1895
+ skills.push(new DroidVisual(mods, false));
1975
1896
  }
1976
- if (this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
1977
- skills.push(new DroidFlashlight(this.mods, true));
1978
- skills.push(new DroidFlashlight(this.mods, false));
1897
+ if (mods.some((m) => m instanceof osuBase.ModFlashlight)) {
1898
+ skills.push(new DroidFlashlight(mods, true));
1899
+ skills.push(new DroidFlashlight(mods, false));
1979
1900
  }
1980
1901
  return skills;
1981
1902
  }
1982
- calculateClockRate(options) {
1983
- var _a, _b;
1984
- return (osuBase.ModUtil.calculateRateWithMods((_a = options === null || options === void 0 ? void 0 : options.mods) !== null && _a !== void 0 ? _a : [], options === null || options === void 0 ? void 0 : options.oldStatistics) * ((_b = options === null || options === void 0 ? void 0 : options.customSpeedMultiplier) !== null && _b !== void 0 ? _b : 1));
1985
- }
1986
- /**
1987
- * Called after aim skill calculation.
1988
- *
1989
- * @param aimSkill The aim skill that considers sliders.
1990
- * @param aimSkillWithoutSliders The aim skill that doesn't consider sliders.
1991
- */
1992
- postCalculateAim(aimSkill, aimSkillWithoutSliders) {
1993
- this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
1994
- this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
1995
- this.attributes.aimDifficulty = this.mods.some((m) => m instanceof osuBase.ModAutopilot)
1996
- ? 0
1997
- : this.starValue(aimSkill.difficultyValue());
1998
- if (this.aim) {
1999
- this.attributes.sliderFactor =
2000
- this.starValue(aimSkillWithoutSliders.difficultyValue()) /
2001
- this.aim;
2002
- }
2003
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
2004
- this.attributes.aimDifficulty *= 0.9;
1903
+ createStrainPeakSkills(beatmap) {
1904
+ const { mods } = beatmap;
1905
+ return [
1906
+ new DroidAim(mods, true),
1907
+ new DroidAim(mods, false),
1908
+ new DroidTap(mods, true),
1909
+ new DroidFlashlight(mods, true),
1910
+ ];
1911
+ }
1912
+ populateAimAttributes(attributes, skills, objects) {
1913
+ const aim = skills.find((s) => s instanceof DroidAim && s.withSliders);
1914
+ const aimNoSlider = skills.find((s) => s instanceof DroidAim && !s.withSliders);
1915
+ if (!aim || !aimNoSlider) {
1916
+ return;
2005
1917
  }
2006
- this.attributes.aimDifficultStrainCount =
2007
- aimSkill.countDifficultStrains();
2008
- this.attributes.aimDifficultSliderCount =
2009
- aimSkill.countDifficultSliders();
2010
- this.calculateAimAttributes();
2011
- }
2012
- /**
2013
- * Calculates aim-related attributes.
2014
- */
2015
- calculateAimAttributes() {
2016
- this.attributes.difficultSliders = [];
1918
+ attributes.aimDifficulty = this.calculateRating(aim);
1919
+ attributes.aimDifficultSliderCount = aim.countDifficultSliders();
1920
+ attributes.aimDifficultStrainCount = aim.countDifficultStrains();
2017
1921
  const topDifficultSliders = [];
2018
- for (let i = 0; i < this.objects.length; ++i) {
2019
- const object = this.objects[i];
1922
+ for (let i = 0; i < objects.length; ++i) {
1923
+ const object = objects[i];
2020
1924
  const velocity = object.travelDistance / object.travelTime;
2021
1925
  if (velocity > 0) {
2022
1926
  topDifficultSliders.push({
@@ -2030,53 +1934,50 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
2030
1934
  const difficultyRating = slider.velocity / velocitySum;
2031
1935
  // Only consider sliders that are fast enough.
2032
1936
  if (difficultyRating > 0.02) {
2033
- this.attributes.difficultSliders.push({
1937
+ attributes.difficultSliders.push({
2034
1938
  index: slider.index,
2035
1939
  difficultyRating: slider.velocity / velocitySum,
2036
1940
  });
2037
1941
  }
2038
1942
  }
2039
- this.attributes.difficultSliders.sort((a, b) => b.difficultyRating - a.difficultyRating);
1943
+ attributes.difficultSliders.sort((a, b) => b.difficultyRating - a.difficultyRating);
2040
1944
  // Take the top 15% most difficult sliders.
2041
- while (this.attributes.difficultSliders.length >
2042
- Math.ceil(0.15 * this.beatmap.hitObjects.sliders)) {
2043
- this.attributes.difficultSliders.pop();
1945
+ while (attributes.difficultSliders.length >
1946
+ Math.ceil(0.15 * attributes.sliderCount)) {
1947
+ attributes.difficultSliders.pop();
1948
+ }
1949
+ if (attributes.aimDifficulty > 0) {
1950
+ attributes.sliderFactor =
1951
+ this.calculateRating(aimNoSlider) / attributes.aimDifficulty;
1952
+ }
1953
+ else {
1954
+ attributes.sliderFactor = 1;
2044
1955
  }
2045
1956
  }
2046
- /**
2047
- * Called after tap skill calculation.
2048
- *
2049
- * @param tapSkillCheese The tap skill that considers cheesing.
2050
- * @param tapSkillVibro The tap skill that considers vibro.
2051
- */
2052
- postCalculateTap(tapSkillCheese, tapSkillVibro) {
2053
- this.strainPeaks.speed = tapSkillCheese.strainPeaks;
2054
- this.attributes.tapDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
2055
- ? 0
2056
- : this.starValue(tapSkillCheese.difficultyValue());
2057
- if (this.tap) {
2058
- this.attributes.vibroFactor =
2059
- this.starValue(tapSkillVibro.difficultyValue()) / this.tap;
2060
- }
2061
- this.attributes.speedNoteCount = tapSkillCheese.relevantNoteCount();
2062
- this.attributes.averageSpeedDeltaTime =
2063
- tapSkillCheese.relevantDeltaTime();
2064
- this.attributes.tapDifficultStrainCount =
2065
- tapSkillCheese.countDifficultStrains();
2066
- this.calculateTapAttributes();
2067
- }
2068
- /**
2069
- * Calculates tap-related attributes.
2070
- */
2071
- calculateTapAttributes() {
2072
- this.attributes.possibleThreeFingeredSections = [];
1957
+ populateTapAttributes(attributes, skills, objects) {
1958
+ const tap = skills.find((s) => s instanceof DroidTap && s.considerCheesability);
1959
+ if (!tap) {
1960
+ return;
1961
+ }
1962
+ attributes.tapDifficulty = this.calculateRating(tap);
1963
+ attributes.tapDifficultStrainCount = tap.countDifficultStrains();
1964
+ attributes.speedNoteCount = tap.relevantNoteCount();
1965
+ attributes.averageSpeedDeltaTime = tap.relevantDeltaTime();
1966
+ if (attributes.tapDifficulty > 0) {
1967
+ const tapVibro = new DroidTap(attributes.mods, true, attributes.averageSpeedDeltaTime);
1968
+ for (const object of objects) {
1969
+ tapVibro.process(object);
1970
+ }
1971
+ attributes.vibroFactor =
1972
+ this.calculateRating(tapVibro) / attributes.tapDifficulty;
1973
+ }
2073
1974
  const { threeFingerStrainThreshold } = DroidDifficultyCalculator;
2074
1975
  const minSectionObjectCount = 5;
2075
1976
  let inSpeedSection = false;
2076
1977
  let firstSpeedObjectIndex = 0;
2077
- for (let i = 2; i < this.objects.length; ++i) {
2078
- const current = this.objects[i];
2079
- const prev = this.objects[i - 1];
1978
+ for (let i = 2; i < objects.length; ++i) {
1979
+ const current = objects[i];
1980
+ const prev = objects[i - 1];
2080
1981
  if (!inSpeedSection &&
2081
1982
  current.originalTapStrain >= threeFingerStrainThreshold) {
2082
1983
  inSpeedSection = true;
@@ -2092,17 +1993,17 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
2092
1993
  // Stop speed section on slowing down 1/2 rhythm change or anything slower.
2093
1994
  (prevDelta < currentDelta && deltaRatio <= 0.5) ||
2094
1995
  // Don't forget to manually add the last section, which would otherwise be ignored.
2095
- i === this.objects.length - 1)) {
2096
- const lastSpeedObjectIndex = i - (i === this.objects.length - 1 ? 0 : 1);
1996
+ i === objects.length - 1)) {
1997
+ const lastSpeedObjectIndex = i - (i === objects.length - 1 ? 0 : 1);
2097
1998
  inSpeedSection = false;
2098
1999
  // Ignore sections that don't meet object count requirement.
2099
2000
  if (i - firstSpeedObjectIndex < minSectionObjectCount) {
2100
2001
  continue;
2101
2002
  }
2102
- this.attributes.possibleThreeFingeredSections.push({
2003
+ attributes.possibleThreeFingeredSections.push({
2103
2004
  firstObjectIndex: firstSpeedObjectIndex,
2104
2005
  lastObjectIndex: lastSpeedObjectIndex,
2105
- sumStrain: Math.pow(this.objects
2006
+ sumStrain: Math.pow(objects
2106
2007
  .slice(firstSpeedObjectIndex, lastSpeedObjectIndex + 1)
2107
2008
  .reduce((a, v) => a +
2108
2009
  v.originalTapStrain /
@@ -2111,61 +2012,47 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
2111
2012
  }
2112
2013
  }
2113
2014
  }
2114
- /**
2115
- * Called after rhythm skill calculation.
2116
- *
2117
- * @param rhythmSkill The rhythm skill.
2118
- */
2119
- postCalculateRhythm(rhythmSkill) {
2120
- this.attributes.rhythmDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
2121
- ? 0
2122
- : this.starValue(rhythmSkill.difficultyValue());
2123
- }
2124
- /**
2125
- * Called after flashlight skill calculation.
2126
- *
2127
- * @param flashlightSkill The flashlight skill that considers sliders.
2128
- * @param flashlightSkillWithoutSliders The flashlight skill that doesn't consider sliders.
2129
- */
2130
- postCalculateFlashlight(flashlightSkill, flashlightSkillWithoutSliders) {
2131
- this.strainPeaks.flashlight = flashlightSkill.strainPeaks;
2132
- this.attributes.flashlightDifficulty = this.starValue(flashlightSkill.difficultyValue());
2133
- if (this.flashlight) {
2134
- this.attributes.flashlightSliderFactor =
2135
- this.starValue(flashlightSkillWithoutSliders.difficultyValue()) / this.flashlight;
2015
+ populateRhythmAttributes(attributes, skills) {
2016
+ const rhythm = skills.find((s) => s instanceof DroidRhythm);
2017
+ if (!rhythm) {
2018
+ return;
2136
2019
  }
2137
- if (this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
2138
- this.attributes.flashlightDifficulty *= 0.3;
2020
+ attributes.rhythmDifficulty = this.calculateRating(rhythm);
2021
+ }
2022
+ populateFlashlightAttributes(attributes, skills) {
2023
+ const flashlight = skills.find((s) => s instanceof DroidFlashlight && s.withSliders);
2024
+ const flashlightNoSliders = skills.find((s) => s instanceof DroidFlashlight && !s.withSliders);
2025
+ if (!flashlight || !flashlightNoSliders) {
2026
+ return;
2139
2027
  }
2140
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
2141
- this.attributes.flashlightDifficulty *= 0.7;
2028
+ attributes.flashlightDifficulty = this.calculateRating(flashlight);
2029
+ attributes.flashlightDifficultStrainCount =
2030
+ flashlight.countDifficultStrains();
2031
+ if (attributes.flashlightDifficulty > 0) {
2032
+ attributes.flashlightSliderFactor =
2033
+ this.calculateRating(flashlightNoSliders) /
2034
+ attributes.flashlightDifficulty;
2142
2035
  }
2143
- else if (this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
2144
- this.attributes.flashlightDifficulty *= 0.4;
2036
+ else {
2037
+ attributes.flashlightSliderFactor = 1;
2145
2038
  }
2146
- this.attributes.flashlightDifficultStrainCount =
2147
- flashlightSkill.countDifficultStrains();
2148
2039
  }
2149
- /**
2150
- * Called after visual skill calculation.
2151
- *
2152
- * @param visualSkillWithSliders The visual skill that considers sliders.
2153
- * @param visualSkillWithoutSliders The visual skill that doesn't consider sliders.
2154
- */
2155
- postCalculateVisual(visualSkillWithSliders, visualSkillWithoutSliders) {
2156
- this.attributes.visualDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
2157
- ? 0
2158
- : this.starValue(visualSkillWithSliders.difficultyValue());
2159
- if (this.visual) {
2160
- this.attributes.visualSliderFactor =
2161
- this.starValue(visualSkillWithoutSliders.difficultyValue()) /
2162
- this.visual;
2040
+ populateVisualAttributes(attributes, skills) {
2041
+ const visual = skills.find((s) => s instanceof DroidVisual && s.withSliders);
2042
+ const visualNoSliders = skills.find((s) => s instanceof DroidVisual && !s.withSliders);
2043
+ if (!visual || !visualNoSliders) {
2044
+ return;
2163
2045
  }
2164
- if (this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
2165
- this.attributes.visualDifficulty *= 0.8;
2046
+ attributes.visualDifficulty = this.calculateRating(visual);
2047
+ attributes.visualDifficultStrainCount = visual.countDifficultStrains();
2048
+ if (attributes.visualDifficulty > 0) {
2049
+ attributes.visualSliderFactor =
2050
+ this.calculateRating(visualNoSliders) /
2051
+ attributes.visualDifficulty;
2052
+ }
2053
+ else {
2054
+ attributes.visualSliderFactor = 1;
2166
2055
  }
2167
- this.attributes.visualDifficultStrainCount =
2168
- visualSkillWithSliders.countDifficultStrains();
2169
2056
  }
2170
2057
  }
2171
2058
  /**
@@ -2174,21 +2061,6 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
2174
2061
  * Increasing this number will result in less sections being flagged.
2175
2062
  */
2176
2063
  DroidDifficultyCalculator.threeFingerStrainThreshold = 175;
2177
- DroidDifficultyCalculator.difficultyAdjustmentMods = new Set([
2178
- osuBase.ModDoubleTime,
2179
- osuBase.ModNightCore,
2180
- osuBase.ModDifficultyAdjust,
2181
- osuBase.ModHalfTime,
2182
- osuBase.ModEasy,
2183
- osuBase.ModHardRock,
2184
- osuBase.ModFlashlight,
2185
- osuBase.ModHidden,
2186
- osuBase.ModRelax,
2187
- osuBase.ModAutopilot,
2188
- osuBase.ModPrecise,
2189
- osuBase.ModScoreV2,
2190
- osuBase.ModTraceable,
2191
- ]);
2192
2064
 
2193
2065
  /**
2194
2066
  * The base class of performance calculators.
@@ -2216,7 +2088,7 @@ class PerformanceCalculator {
2216
2088
  this.sliderNerfFactor = 1;
2217
2089
  this.difficultyAttributes = difficultyAttributes;
2218
2090
  this.mods = this.isCacheableAttribute(difficultyAttributes)
2219
- ? osuBase.ModUtil.pcStringToMods(difficultyAttributes.mods)
2091
+ ? osuBase.ModUtil.deserializeMods(difficultyAttributes.mods)
2220
2092
  : difficultyAttributes.mods;
2221
2093
  }
2222
2094
  /**
@@ -3153,62 +3025,149 @@ class OsuAim extends OsuSkill {
3153
3025
  }
3154
3026
 
3155
3027
  /**
3156
- * An evaluator for calculating osu!standard speed skill.
3028
+ * Holds data that can be used to calculate osu!standard performance points.
3157
3029
  */
3158
- class OsuSpeedEvaluator {
3030
+ class OsuDifficultyAttributes extends DifficultyAttributes {
3031
+ constructor(cacheableAttributes) {
3032
+ super(cacheableAttributes);
3033
+ this.approachRate = 0;
3034
+ this.speedDifficulty = 0;
3035
+ this.speedDifficultStrainCount = 0;
3036
+ if (!cacheableAttributes) {
3037
+ return;
3038
+ }
3039
+ this.approachRate = cacheableAttributes.approachRate;
3040
+ this.speedDifficulty = cacheableAttributes.speedDifficulty;
3041
+ this.speedDifficultStrainCount =
3042
+ cacheableAttributes.speedDifficultStrainCount;
3043
+ }
3044
+ toString() {
3045
+ return (super.toString() +
3046
+ ` (${this.aimDifficulty.toFixed(2)} aim, ` +
3047
+ `${this.speedDifficulty.toFixed(2)} speed, ` +
3048
+ `${this.flashlightDifficulty.toFixed(2)} flashlight)`);
3049
+ }
3050
+ }
3051
+
3052
+ /**
3053
+ * An evaluator for calculating osu!standard Flashlight skill.
3054
+ */
3055
+ class OsuFlashlightEvaluator {
3159
3056
  /**
3160
- * Evaluates the difficulty of tapping the current object, based on:
3057
+ * Evaluates the difficulty of memorizing and hitting the current object, based on:
3161
3058
  *
3162
- * - time between pressing the previous and current object,
3163
- * - distance between those objects,
3164
- * - and how easily they can be cheesed.
3059
+ * - distance between a number of previous objects and the current object,
3060
+ * - the visual opacity of the current object,
3061
+ * - the angle made by the current object,
3062
+ * - length and speed of the current object (for sliders),
3063
+ * - and whether Hidden mod is enabled.
3165
3064
  *
3166
3065
  * @param current The current object.
3167
- * @param mods The mods applied.
3066
+ * @param mods The mods used.
3168
3067
  */
3169
3068
  static evaluateDifficultyOf(current, mods) {
3170
- var _a;
3171
3069
  if (current.object instanceof osuBase.Spinner) {
3172
3070
  return 0;
3173
3071
  }
3174
- const prev = current.previous(0);
3175
- let strainTime = current.strainTime;
3176
- // Nerf doubletappable doubles.
3177
- const doubletapness = 1 - current.doubletapness;
3178
- // Cap deltatime to the OD 300 hitwindow.
3179
- // 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.
3180
- strainTime /= osuBase.MathUtils.clamp(strainTime / current.fullGreatWindow / 0.93, 0.92, 1);
3181
- // speedBonus will be 0.0 for BPM < 200
3182
- let speedBonus = 0;
3183
- // Add additional scaling bonus for streams/bursts higher than 200bpm
3184
- if (strainTime < this.minSpeedBonus) {
3185
- speedBonus =
3186
- 0.75 * Math.pow((this.minSpeedBonus - strainTime) / 40, 2);
3072
+ const scalingFactor = 52 / current.object.radius;
3073
+ let smallDistNerf = 1;
3074
+ let cumulativeStrainTime = 0;
3075
+ let result = 0;
3076
+ let last = current;
3077
+ let angleRepeatCount = 0;
3078
+ for (let i = 0; i < Math.min(current.index, 10); ++i) {
3079
+ const currentObject = current.previous(i);
3080
+ cumulativeStrainTime += last.strainTime;
3081
+ if (!(currentObject.object instanceof osuBase.Spinner)) {
3082
+ const jumpDistance = current.object
3083
+ .getStackedPosition(osuBase.Modes.osu)
3084
+ .subtract(currentObject.object.getStackedEndPosition(osuBase.Modes.osu)).length;
3085
+ // We want to nerf objects that can be easily seen within the Flashlight circle radius.
3086
+ if (i === 0) {
3087
+ smallDistNerf = Math.min(1, jumpDistance / 75);
3088
+ }
3089
+ // We also want to nerf stacks so that only the first object of the stack is accounted for.
3090
+ const stackNerf = Math.min(1, currentObject.lazyJumpDistance / scalingFactor / 25);
3091
+ // Bonus based on how visible the object is.
3092
+ const opacityBonus = 1 +
3093
+ this.maxOpacityBonus *
3094
+ (1 -
3095
+ current.opacityAt(currentObject.object.startTime, mods));
3096
+ result +=
3097
+ (stackNerf * opacityBonus * scalingFactor * jumpDistance) /
3098
+ cumulativeStrainTime;
3099
+ if (currentObject.angle !== null && current.angle !== null) {
3100
+ // Objects further back in time should count less for the nerf.
3101
+ if (Math.abs(currentObject.angle - current.angle) < 0.02) {
3102
+ angleRepeatCount += Math.max(0, 1 - 0.1 * i);
3103
+ }
3104
+ }
3105
+ }
3106
+ last = currentObject;
3187
3107
  }
3188
- const travelDistance = (_a = prev === null || prev === void 0 ? void 0 : prev.travelDistance) !== null && _a !== void 0 ? _a : 0;
3189
- // Cap distance at spacing threshold
3190
- const distance = Math.min(this.SINGLE_SPACING_THRESHOLD, travelDistance + current.minimumJumpDistance);
3191
- // Max distance bonus is 1 * `distance_multiplier` at single_spacing_threshold
3192
- let distanceBonus = Math.pow(distance / this.SINGLE_SPACING_THRESHOLD, 3.95) *
3193
- this.DISTANCE_MULTIPLIER;
3194
- if (mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3195
- distanceBonus = 0;
3108
+ result = Math.pow(smallDistNerf * result, 2);
3109
+ // Additional bonus for Hidden due to there being no approach circles.
3110
+ if (mods.some((m) => m instanceof osuBase.ModHidden)) {
3111
+ result *= 1 + this.hiddenBonus;
3196
3112
  }
3197
- // Base difficulty with all bonuses
3198
- const difficulty = ((1 + speedBonus + distanceBonus) * 1000) / strainTime;
3199
- // Apply penalty if there's doubletappable doubles
3200
- return difficulty * doubletapness;
3113
+ // Nerf patterns with repeated angles.
3114
+ result *=
3115
+ this.minAngleMultiplier +
3116
+ (1 - this.minAngleMultiplier) / (angleRepeatCount + 1);
3117
+ let sliderBonus = 0;
3118
+ if (current.object instanceof osuBase.Slider) {
3119
+ // Invert the scaling factor to determine the true travel distance independent of circle size.
3120
+ const pixelTravelDistance = current.object.lazyTravelDistance / scalingFactor;
3121
+ // Reward sliders based on velocity.
3122
+ sliderBonus = Math.pow(Math.max(0, pixelTravelDistance / current.travelTime - this.minVelocity), 0.5);
3123
+ // Longer sliders require more memorization.
3124
+ sliderBonus *= pixelTravelDistance;
3125
+ // Nerf sliders with repeats, as less memorization is required.
3126
+ if (current.object.repeatCount > 0)
3127
+ sliderBonus /= current.object.repeatCount + 1;
3128
+ }
3129
+ result += sliderBonus * this.sliderMultiplier;
3130
+ return result;
3201
3131
  }
3202
3132
  }
3133
+ OsuFlashlightEvaluator.maxOpacityBonus = 0.4;
3134
+ OsuFlashlightEvaluator.hiddenBonus = 0.2;
3135
+ OsuFlashlightEvaluator.minVelocity = 0.5;
3136
+ OsuFlashlightEvaluator.sliderMultiplier = 1.3;
3137
+ OsuFlashlightEvaluator.minAngleMultiplier = 0.2;
3138
+
3203
3139
  /**
3204
- * Spacing threshold for a single hitobject spacing.
3205
- *
3206
- * About 1.25 circles distance between hitobject centers.
3140
+ * Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
3207
3141
  */
3208
- OsuSpeedEvaluator.SINGLE_SPACING_THRESHOLD = 125;
3209
- // ~200 1/4 BPM streams
3210
- OsuSpeedEvaluator.minSpeedBonus = 75;
3211
- OsuSpeedEvaluator.DISTANCE_MULTIPLIER = 0.9;
3142
+ class OsuFlashlight extends OsuSkill {
3143
+ constructor() {
3144
+ super(...arguments);
3145
+ this.strainDecayBase = 0.15;
3146
+ this.reducedSectionCount = 0;
3147
+ this.reducedSectionBaseline = 1;
3148
+ this.decayWeight = 1;
3149
+ this.currentFlashlightStrain = 0;
3150
+ this.skillMultiplier = 0.05512;
3151
+ }
3152
+ difficultyValue() {
3153
+ return this.strainPeaks.reduce((a, b) => a + b, 0);
3154
+ }
3155
+ strainValueAt(current) {
3156
+ this.currentFlashlightStrain *= this.strainDecay(current.deltaTime);
3157
+ this.currentFlashlightStrain +=
3158
+ OsuFlashlightEvaluator.evaluateDifficultyOf(current, this.mods) *
3159
+ this.skillMultiplier;
3160
+ return this.currentFlashlightStrain;
3161
+ }
3162
+ calculateInitialStrain(time, current) {
3163
+ var _a, _b;
3164
+ return (this.currentFlashlightStrain *
3165
+ this.strainDecay(time - ((_b = (_a = current.previous(0)) === null || _a === void 0 ? void 0 : _a.startTime) !== null && _b !== void 0 ? _b : 0)));
3166
+ }
3167
+ saveToHitObject(current) {
3168
+ current.flashlightStrain = this.currentFlashlightStrain;
3169
+ }
3170
+ }
3212
3171
 
3213
3172
  /**
3214
3173
  * An evaluator for calculating osu!standard Rhythm skill.
@@ -3358,6 +3317,64 @@ OsuRhythmEvaluator.historyObjectsMax = 32;
3358
3317
  OsuRhythmEvaluator.rhythmOverallMultiplier = 0.95;
3359
3318
  OsuRhythmEvaluator.rhythmRatioMultiplier = 12;
3360
3319
 
3320
+ /**
3321
+ * An evaluator for calculating osu!standard speed skill.
3322
+ */
3323
+ class OsuSpeedEvaluator {
3324
+ /**
3325
+ * Evaluates the difficulty of tapping the current object, based on:
3326
+ *
3327
+ * - time between pressing the previous and current object,
3328
+ * - distance between those objects,
3329
+ * - and how easily they can be cheesed.
3330
+ *
3331
+ * @param current The current object.
3332
+ * @param mods The mods applied.
3333
+ */
3334
+ static evaluateDifficultyOf(current, mods) {
3335
+ var _a;
3336
+ if (current.object instanceof osuBase.Spinner) {
3337
+ return 0;
3338
+ }
3339
+ const prev = current.previous(0);
3340
+ let strainTime = current.strainTime;
3341
+ // Nerf doubletappable doubles.
3342
+ const doubletapness = 1 - current.doubletapness;
3343
+ // Cap deltatime to the OD 300 hitwindow.
3344
+ // 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.
3345
+ strainTime /= osuBase.MathUtils.clamp(strainTime / current.fullGreatWindow / 0.93, 0.92, 1);
3346
+ // speedBonus will be 0.0 for BPM < 200
3347
+ let speedBonus = 0;
3348
+ // Add additional scaling bonus for streams/bursts higher than 200bpm
3349
+ if (strainTime < this.minSpeedBonus) {
3350
+ speedBonus =
3351
+ 0.75 * Math.pow((this.minSpeedBonus - strainTime) / 40, 2);
3352
+ }
3353
+ const travelDistance = (_a = prev === null || prev === void 0 ? void 0 : prev.travelDistance) !== null && _a !== void 0 ? _a : 0;
3354
+ // Cap distance at spacing threshold
3355
+ const distance = Math.min(this.SINGLE_SPACING_THRESHOLD, travelDistance + current.minimumJumpDistance);
3356
+ // Max distance bonus is 1 * `distance_multiplier` at single_spacing_threshold
3357
+ let distanceBonus = Math.pow(distance / this.SINGLE_SPACING_THRESHOLD, 3.95) *
3358
+ this.DISTANCE_MULTIPLIER;
3359
+ if (mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3360
+ distanceBonus = 0;
3361
+ }
3362
+ // Base difficulty with all bonuses
3363
+ const difficulty = ((1 + speedBonus + distanceBonus) * 1000) / strainTime;
3364
+ // Apply penalty if there's doubletappable doubles
3365
+ return difficulty * doubletapness;
3366
+ }
3367
+ }
3368
+ /**
3369
+ * Spacing threshold for a single hitobject spacing.
3370
+ *
3371
+ * About 1.25 circles distance between hitobject centers.
3372
+ */
3373
+ OsuSpeedEvaluator.SINGLE_SPACING_THRESHOLD = 125;
3374
+ // ~200 1/4 BPM streams
3375
+ OsuSpeedEvaluator.minSpeedBonus = 75;
3376
+ OsuSpeedEvaluator.DISTANCE_MULTIPLIER = 0.9;
3377
+
3361
3378
  /**
3362
3379
  * Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
3363
3380
  */
@@ -3372,6 +3389,19 @@ class OsuSpeed extends OsuSkill {
3372
3389
  this.currentRhythm = 0;
3373
3390
  this.skillMultiplier = 1.46;
3374
3391
  }
3392
+ /**
3393
+ * The amount of notes that are relevant to the difficulty.
3394
+ */
3395
+ relevantNoteCount() {
3396
+ if (this._objectStrains.length === 0) {
3397
+ return 0;
3398
+ }
3399
+ const maxStrain = osuBase.MathUtils.max(this._objectStrains);
3400
+ if (maxStrain === 0) {
3401
+ return 0;
3402
+ }
3403
+ return this._objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
3404
+ }
3375
3405
  /**
3376
3406
  * @param current The hitobject to calculate.
3377
3407
  */
@@ -3400,375 +3430,138 @@ class OsuSpeed extends OsuSkill {
3400
3430
  }
3401
3431
  }
3402
3432
 
3403
- /**
3404
- * An evaluator for calculating osu!standard Flashlight skill.
3405
- */
3406
- class OsuFlashlightEvaluator {
3407
- /**
3408
- * Evaluates the difficulty of memorizing and hitting the current object, based on:
3409
- *
3410
- * - distance between a number of previous objects and the current object,
3411
- * - the visual opacity of the current object,
3412
- * - the angle made by the current object,
3413
- * - length and speed of the current object (for sliders),
3414
- * - and whether Hidden mod is enabled.
3415
- *
3416
- * @param current The current object.
3417
- * @param mods The mods used.
3418
- */
3419
- static evaluateDifficultyOf(current, mods) {
3420
- if (current.object instanceof osuBase.Spinner) {
3421
- return 0;
3422
- }
3423
- const scalingFactor = 52 / current.object.radius;
3424
- let smallDistNerf = 1;
3425
- let cumulativeStrainTime = 0;
3426
- let result = 0;
3427
- let last = current;
3428
- let angleRepeatCount = 0;
3429
- for (let i = 0; i < Math.min(current.index, 10); ++i) {
3430
- const currentObject = current.previous(i);
3431
- cumulativeStrainTime += last.strainTime;
3432
- if (!(currentObject.object instanceof osuBase.Spinner)) {
3433
- const jumpDistance = current.object
3434
- .getStackedPosition(osuBase.Modes.osu)
3435
- .subtract(currentObject.object.getStackedEndPosition(osuBase.Modes.osu)).length;
3436
- // We want to nerf objects that can be easily seen within the Flashlight circle radius.
3437
- if (i === 0) {
3438
- smallDistNerf = Math.min(1, jumpDistance / 75);
3439
- }
3440
- // We also want to nerf stacks so that only the first object of the stack is accounted for.
3441
- const stackNerf = Math.min(1, currentObject.lazyJumpDistance / scalingFactor / 25);
3442
- // Bonus based on how visible the object is.
3443
- const opacityBonus = 1 +
3444
- this.maxOpacityBonus *
3445
- (1 -
3446
- current.opacityAt(currentObject.object.startTime, mods));
3447
- result +=
3448
- (stackNerf * opacityBonus * scalingFactor * jumpDistance) /
3449
- cumulativeStrainTime;
3450
- if (currentObject.angle !== null && current.angle !== null) {
3451
- // Objects further back in time should count less for the nerf.
3452
- if (Math.abs(currentObject.angle - current.angle) < 0.02) {
3453
- angleRepeatCount += Math.max(0, 1 - 0.1 * i);
3454
- }
3455
- }
3456
- }
3457
- last = currentObject;
3458
- }
3459
- result = Math.pow(smallDistNerf * result, 2);
3460
- // Additional bonus for Hidden due to there being no approach circles.
3461
- if (mods.some((m) => m instanceof osuBase.ModHidden)) {
3462
- result *= 1 + this.hiddenBonus;
3463
- }
3464
- // Nerf patterns with repeated angles.
3465
- result *=
3466
- this.minAngleMultiplier +
3467
- (1 - this.minAngleMultiplier) / (angleRepeatCount + 1);
3468
- let sliderBonus = 0;
3469
- if (current.object instanceof osuBase.Slider) {
3470
- // Invert the scaling factor to determine the true travel distance independent of circle size.
3471
- const pixelTravelDistance = current.object.lazyTravelDistance / scalingFactor;
3472
- // Reward sliders based on velocity.
3473
- sliderBonus = Math.pow(Math.max(0, pixelTravelDistance / current.travelTime - this.minVelocity), 0.5);
3474
- // Longer sliders require more memorization.
3475
- sliderBonus *= pixelTravelDistance;
3476
- // Nerf sliders with repeats, as less memorization is required.
3477
- if (current.object.repeatCount > 0)
3478
- sliderBonus /= current.object.repeatCount + 1;
3479
- }
3480
- result += sliderBonus * this.sliderMultiplier;
3481
- return result;
3482
- }
3483
- }
3484
- OsuFlashlightEvaluator.maxOpacityBonus = 0.4;
3485
- OsuFlashlightEvaluator.hiddenBonus = 0.2;
3486
- OsuFlashlightEvaluator.minVelocity = 0.5;
3487
- OsuFlashlightEvaluator.sliderMultiplier = 1.3;
3488
- OsuFlashlightEvaluator.minAngleMultiplier = 0.2;
3489
-
3490
- /**
3491
- * Represents the skill required to memorize and hit every object in a beatmap with the Flashlight mod enabled.
3492
- */
3493
- class OsuFlashlight extends OsuSkill {
3494
- constructor() {
3495
- super(...arguments);
3496
- this.strainDecayBase = 0.15;
3497
- this.reducedSectionCount = 0;
3498
- this.reducedSectionBaseline = 1;
3499
- this.decayWeight = 1;
3500
- this.currentFlashlightStrain = 0;
3501
- this.skillMultiplier = 0.05512;
3502
- }
3503
- difficultyValue() {
3504
- return this.strainPeaks.reduce((a, b) => a + b, 0);
3505
- }
3506
- strainValueAt(current) {
3507
- this.currentFlashlightStrain *= this.strainDecay(current.deltaTime);
3508
- this.currentFlashlightStrain +=
3509
- OsuFlashlightEvaluator.evaluateDifficultyOf(current, this.mods) *
3510
- this.skillMultiplier;
3511
- return this.currentFlashlightStrain;
3512
- }
3513
- calculateInitialStrain(time, current) {
3514
- var _a, _b;
3515
- return (this.currentFlashlightStrain *
3516
- this.strainDecay(time - ((_b = (_a = current.previous(0)) === null || _a === void 0 ? void 0 : _a.startTime) !== null && _b !== void 0 ? _b : 0)));
3517
- }
3518
- saveToHitObject(current) {
3519
- current.flashlightStrain = this.currentFlashlightStrain;
3520
- }
3521
- }
3522
-
3523
3433
  /**
3524
3434
  * A difficulty calculator for osu!standard gamemode.
3525
3435
  */
3526
3436
  class OsuDifficultyCalculator extends DifficultyCalculator {
3527
3437
  constructor() {
3528
- super(...arguments);
3529
- this.attributes = {
3530
- speedDifficulty: 0,
3531
- mods: [],
3532
- starRating: 0,
3533
- maxCombo: 0,
3534
- aimDifficulty: 0,
3535
- flashlightDifficulty: 0,
3536
- speedNoteCount: 0,
3537
- sliderFactor: 0,
3538
- clockRate: 1,
3539
- approachRate: 0,
3540
- overallDifficulty: 0,
3541
- hitCircleCount: 0,
3542
- sliderCount: 0,
3543
- spinnerCount: 0,
3544
- aimDifficultSliderCount: 0,
3545
- aimDifficultStrainCount: 0,
3546
- speedDifficultStrainCount: 0,
3547
- };
3438
+ super();
3548
3439
  this.difficultyMultiplier = 0.0675;
3549
- this.mode = osuBase.Modes.osu;
3550
- }
3551
- /**
3552
- * The aim star rating of the beatmap.
3553
- */
3554
- get aim() {
3555
- return this.attributes.aimDifficulty;
3556
- }
3557
- /**
3558
- * The speed star rating of the beatmap.
3559
- */
3560
- get speed() {
3561
- return this.attributes.speedDifficulty;
3562
- }
3563
- /**
3564
- * The flashlight star rating of the beatmap.
3565
- */
3566
- get flashlight() {
3567
- return this.attributes.flashlightDifficulty;
3568
- }
3569
- get cacheableAttributes() {
3570
- return Object.assign(Object.assign({}, this.attributes), { mods: osuBase.ModUtil.modsToOsuString(this.attributes.mods) });
3571
- }
3572
- /**
3573
- * Calculates the aim star rating of the beatmap and stores it in this instance.
3574
- */
3575
- calculateAim() {
3576
- if (this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3577
- this.attributes.aimDifficulty = 0;
3578
- return;
3579
- }
3580
- const aimSkill = new OsuAim(this.mods, true);
3581
- const aimSkillWithoutSliders = new OsuAim(this.mods, false);
3582
- this.calculateSkills(aimSkill, aimSkillWithoutSliders);
3583
- this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
3584
- }
3585
- /**
3586
- * Calculates the speed star rating of the beatmap and stores it in this instance.
3587
- */
3588
- calculateSpeed() {
3589
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3590
- this.attributes.speedDifficulty = 0;
3591
- return;
3592
- }
3593
- const speedSkill = new OsuSpeed(this.mods);
3594
- this.calculateSkills(speedSkill);
3595
- this.postCalculateSpeed(speedSkill);
3596
- }
3597
- /**
3598
- * Calculates the flashlight star rating of the beatmap and stores it in this instance.
3599
- */
3600
- calculateFlashlight() {
3601
- if (!this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3602
- this.attributes.flashlightDifficulty = 0;
3603
- return;
3604
- }
3605
- const flashlightSkill = new OsuFlashlight(this.mods);
3606
- this.calculateSkills(flashlightSkill);
3607
- this.postCalculateFlashlight(flashlightSkill);
3608
- }
3609
- calculateTotal() {
3610
- const aimPerformanceValue = this.basePerformanceValue(this.aim);
3611
- const speedPerformanceValue = this.basePerformanceValue(this.speed);
3612
- let flashlightPerformanceValue = 0;
3613
- if (this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3614
- flashlightPerformanceValue = Math.pow(this.flashlight, 2) * 25;
3615
- }
3440
+ this.difficultyAdjustmentMods.add(osuBase.ModTouchDevice);
3441
+ }
3442
+ retainDifficultyAdjustmentMods(mods) {
3443
+ return mods.filter((mod) => mod.isApplicableToOsu() &&
3444
+ this.difficultyAdjustmentMods.has(mod.constructor) &&
3445
+ mod.isOsuRelevant);
3446
+ }
3447
+ createDifficultyAttributes(beatmap, skills) {
3448
+ const attributes = new OsuDifficultyAttributes();
3449
+ attributes.mods = beatmap.mods.slice();
3450
+ attributes.maxCombo = beatmap.maxCombo;
3451
+ attributes.clockRate = beatmap.speedMultiplier;
3452
+ attributes.hitCircleCount = beatmap.hitObjects.circles;
3453
+ attributes.sliderCount = beatmap.hitObjects.sliders;
3454
+ attributes.spinnerCount = beatmap.hitObjects.spinners;
3455
+ this.populateAimAttributes(attributes, skills);
3456
+ this.populateSpeedAttributes(attributes, skills);
3457
+ this.populateFlashlightAttributes(attributes, skills);
3458
+ if (attributes.mods.some((m) => m instanceof osuBase.ModRelax)) {
3459
+ attributes.aimDifficulty *= 0.9;
3460
+ attributes.speedDifficulty = 0;
3461
+ attributes.flashlightDifficulty *= 0.7;
3462
+ }
3463
+ else if (attributes.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3464
+ attributes.aimDifficulty = 0;
3465
+ attributes.speedDifficulty *= 0.5;
3466
+ attributes.flashlightDifficulty *= 0.4;
3467
+ }
3468
+ const aimPerformanceValue = this.basePerformanceValue(attributes.aimDifficulty);
3469
+ const speedPerformanceValue = this.basePerformanceValue(attributes.speedDifficulty);
3470
+ const flashlightPerformanceValue = Math.pow(attributes.flashlightDifficulty, 2) * 25;
3616
3471
  const basePerformanceValue = Math.pow(Math.pow(aimPerformanceValue, 1.1) +
3617
3472
  Math.pow(speedPerformanceValue, 1.1) +
3618
3473
  Math.pow(flashlightPerformanceValue, 1.1), 1 / 1.1);
3619
3474
  if (basePerformanceValue > 1e-5) {
3620
3475
  // Document for formula derivation:
3621
3476
  // https://docs.google.com/document/d/10DZGYYSsT_yjz2Mtp6yIJld0Rqx4E-vVHupCqiM4TNI/edit
3622
- this.attributes.starRating =
3477
+ attributes.starRating =
3623
3478
  Math.cbrt(1.15) *
3624
3479
  0.027 *
3625
3480
  (Math.cbrt((100000 / Math.pow(2, 1 / 1.1)) * basePerformanceValue) +
3626
3481
  4);
3627
3482
  }
3628
3483
  else {
3629
- this.attributes.starRating = 0;
3484
+ attributes.starRating = 0;
3630
3485
  }
3486
+ const preempt = osuBase.BeatmapDifficulty.difficultyRange(beatmap.difficulty.ar, osuBase.HitObject.preemptMax, osuBase.HitObject.preemptMid, osuBase.HitObject.preemptMin) / attributes.clockRate;
3487
+ attributes.approachRate = osuBase.BeatmapDifficulty.inverseDifficultyRange(preempt, osuBase.HitObject.preemptMax, osuBase.HitObject.preemptMid, osuBase.HitObject.preemptMin);
3488
+ const { greatWindow } = new osuBase.OsuHitWindow(beatmap.difficulty.od);
3489
+ attributes.overallDifficulty = osuBase.OsuHitWindow.greatWindowToOD(greatWindow / attributes.clockRate);
3490
+ return attributes;
3631
3491
  }
3632
- calculateAll() {
3633
- const skills = this.createSkills();
3634
- this.calculateSkills(...skills);
3635
- const aimSkill = skills.find((s) => s instanceof OsuAim && s.withSliders);
3636
- const aimSkillWithoutSliders = skills.find((s) => s instanceof OsuAim && !s.withSliders);
3637
- const speedSkill = skills.find((s) => s instanceof OsuSpeed);
3638
- const flashlightSkill = skills.find((s) => s instanceof OsuFlashlight);
3639
- if (aimSkill && aimSkillWithoutSliders) {
3640
- this.postCalculateAim(aimSkill, aimSkillWithoutSliders);
3641
- }
3642
- if (speedSkill) {
3643
- this.postCalculateSpeed(speedSkill);
3644
- }
3645
- if (flashlightSkill) {
3646
- this.postCalculateFlashlight(flashlightSkill);
3647
- }
3648
- this.calculateTotal();
3492
+ createPlayableBeatmap(beatmap, mods) {
3493
+ return beatmap.createOsuPlayableBeatmap(mods);
3649
3494
  }
3650
- toString() {
3651
- return (this.total.toFixed(2) +
3652
- " stars (" +
3653
- this.aim.toFixed(2) +
3654
- " aim, " +
3655
- this.speed.toFixed(2) +
3656
- " speed, " +
3657
- this.flashlight.toFixed(2) +
3658
- " flashlight)");
3659
- }
3660
- generateDifficultyHitObjects(beatmap, clockRate) {
3495
+ createDifficultyHitObjects(beatmap) {
3661
3496
  var _a, _b;
3497
+ const clockRate = beatmap.speedMultiplier;
3662
3498
  const difficultyObjects = [];
3663
3499
  const { objects } = beatmap.hitObjects;
3664
- for (let i = 0; i < objects.length; ++i) {
3665
- const difficultyObject = new OsuDifficultyHitObject(objects[i], (_a = objects[i - 1]) !== null && _a !== void 0 ? _a : null, (_b = objects[i - 2]) !== null && _b !== void 0 ? _b : null, difficultyObjects, clockRate);
3500
+ for (let i = 1; i < objects.length; ++i) {
3501
+ const difficultyObject = new OsuDifficultyHitObject(objects[i], (_a = objects[i - 1]) !== null && _a !== void 0 ? _a : null, (_b = objects[i - 2]) !== null && _b !== void 0 ? _b : null, difficultyObjects, clockRate, i - 1);
3666
3502
  difficultyObject.computeProperties(clockRate, objects);
3667
3503
  difficultyObjects.push(difficultyObject);
3668
3504
  }
3669
3505
  return difficultyObjects;
3670
3506
  }
3671
- createSkills() {
3507
+ createSkills(beatmap) {
3508
+ const { mods } = beatmap;
3672
3509
  const skills = [];
3673
- if (!this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3674
- skills.push(new OsuAim(this.mods, true));
3675
- skills.push(new OsuAim(this.mods, false));
3510
+ if (!mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3511
+ skills.push(new OsuAim(mods, true));
3512
+ skills.push(new OsuAim(mods, false));
3676
3513
  }
3677
- if (!this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3678
- skills.push(new OsuSpeed(this.mods));
3514
+ if (!mods.some((m) => m instanceof osuBase.ModRelax)) {
3515
+ skills.push(new OsuSpeed(mods));
3679
3516
  }
3680
- if (this.mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3681
- skills.push(new OsuFlashlight(this.mods));
3517
+ if (mods.some((m) => m instanceof osuBase.ModFlashlight)) {
3518
+ skills.push(new OsuFlashlight(mods));
3682
3519
  }
3683
3520
  return skills;
3684
3521
  }
3685
- populateDifficultyAttributes(beatmap, clockRate) {
3686
- super.populateDifficultyAttributes(beatmap, clockRate);
3687
- const preempt = osuBase.BeatmapDifficulty.difficultyRange(beatmap.difficulty.ar, osuBase.HitObject.preemptMax, osuBase.HitObject.preemptMid, osuBase.HitObject.preemptMin) / clockRate;
3688
- this.attributes.approachRate = osuBase.BeatmapDifficulty.inverseDifficultyRange(preempt, osuBase.HitObject.preemptMax, osuBase.HitObject.preemptMid, osuBase.HitObject.preemptMin);
3689
- }
3690
- /**
3691
- * Called after aim skill calculation.
3692
- *
3693
- * @param aimSkill The aim skill that considers sliders.
3694
- * @param aimSkillWithoutSliders The aim skill that doesn't consider sliders.
3695
- */
3696
- postCalculateAim(aimSkill, aimSkillWithoutSliders) {
3697
- this.strainPeaks.aimWithSliders = aimSkill.strainPeaks;
3698
- this.strainPeaks.aimWithoutSliders = aimSkillWithoutSliders.strainPeaks;
3699
- this.attributes.aimDifficulty = this.starValue(aimSkill.difficultyValue());
3700
- if (this.aim) {
3701
- this.attributes.sliderFactor =
3702
- this.starValue(aimSkillWithoutSliders.difficultyValue()) /
3703
- this.aim;
3704
- }
3705
- if (this.mods.some((m) => m instanceof osuBase.ModTouchDevice)) {
3706
- this.attributes.aimDifficulty = Math.pow(this.aim, 0.8);
3522
+ createStrainPeakSkills(beatmap) {
3523
+ const { mods } = beatmap;
3524
+ return [
3525
+ new OsuAim(mods, true),
3526
+ new OsuAim(mods, false),
3527
+ new OsuSpeed(mods),
3528
+ new OsuFlashlight(mods),
3529
+ ];
3530
+ }
3531
+ populateAimAttributes(attributes, skills) {
3532
+ const aim = skills.find((s) => s instanceof OsuAim && s.withSliders);
3533
+ const aimNoSlider = skills.find((s) => s instanceof OsuAim && !s.withSliders);
3534
+ if (!aim || !aimNoSlider) {
3535
+ return;
3707
3536
  }
3708
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3709
- this.attributes.aimDifficulty *= 0.9;
3537
+ attributes.aimDifficulty = this.calculateRating(aim);
3538
+ attributes.aimDifficultSliderCount = aim.countDifficultSliders();
3539
+ attributes.aimDifficultStrainCount = aim.countDifficultStrains();
3540
+ if (attributes.aimDifficulty > 0) {
3541
+ attributes.sliderFactor =
3542
+ this.calculateRating(aimNoSlider) / attributes.aimDifficulty;
3710
3543
  }
3711
- else if (this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3712
- this.attributes.aimDifficulty = 0;
3544
+ else {
3545
+ attributes.sliderFactor = 1;
3713
3546
  }
3714
- this.attributes.aimDifficultStrainCount =
3715
- aimSkill.countDifficultStrains();
3716
- this.attributes.aimDifficultSliderCount =
3717
- aimSkill.countDifficultSliders();
3718
3547
  }
3719
- /**
3720
- * Called after speed skill calculation.
3721
- *
3722
- * @param speedSkill The speed skill.
3723
- */
3724
- postCalculateSpeed(speedSkill) {
3725
- this.strainPeaks.speed = speedSkill.strainPeaks;
3726
- this.attributes.speedDifficulty = this.mods.some((m) => m instanceof osuBase.ModRelax)
3727
- ? 0
3728
- : this.starValue(speedSkill.difficultyValue());
3729
- if (this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3730
- this.attributes.speedDifficulty *= 0.5;
3731
- }
3732
- this.attributes.speedDifficultStrainCount =
3733
- speedSkill.countDifficultStrains();
3734
- const objectStrains = this.objects.map((v) => v.speedStrain);
3735
- const maxStrain = osuBase.MathUtils.max(objectStrains);
3736
- if (maxStrain) {
3737
- this.attributes.speedNoteCount = objectStrains.reduce((total, next) => total + 1 / (1 + Math.exp(-((next / maxStrain) * 12 - 6))), 0);
3548
+ populateSpeedAttributes(attributes, skills) {
3549
+ const speed = skills.find((s) => s instanceof OsuSpeed);
3550
+ if (!speed) {
3551
+ return;
3738
3552
  }
3553
+ attributes.speedDifficulty = this.calculateRating(speed);
3554
+ attributes.speedNoteCount = speed.relevantNoteCount();
3555
+ attributes.speedDifficultStrainCount = speed.countDifficultStrains();
3739
3556
  }
3740
- /**
3741
- * Called after flashlight skill calculation.
3742
- *
3743
- * @param flashlightSkill The flashlight skill.
3744
- */
3745
- postCalculateFlashlight(flashlightSkill) {
3746
- this.strainPeaks.flashlight = flashlightSkill.strainPeaks;
3747
- this.attributes.flashlightDifficulty = this.starValue(flashlightSkill.difficultyValue());
3748
- if (this.mods.some((m) => m instanceof osuBase.ModTouchDevice)) {
3749
- this.attributes.flashlightDifficulty = Math.pow(this.flashlight, 0.8);
3750
- }
3751
- if (this.mods.some((m) => m instanceof osuBase.ModRelax)) {
3752
- this.attributes.flashlightDifficulty *= 0.7;
3753
- }
3754
- else if (this.mods.some((m) => m instanceof osuBase.ModAutopilot)) {
3755
- this.attributes.flashlightDifficulty *= 0.4;
3557
+ populateFlashlightAttributes(attributes, skills) {
3558
+ const flashlight = skills.find((s) => s instanceof OsuFlashlight);
3559
+ if (!flashlight) {
3560
+ return;
3756
3561
  }
3562
+ attributes.flashlightDifficulty = this.calculateRating(flashlight);
3757
3563
  }
3758
3564
  }
3759
- OsuDifficultyCalculator.difficultyAdjustmentMods = new Set([
3760
- osuBase.ModTouchDevice,
3761
- osuBase.ModDoubleTime,
3762
- osuBase.ModNightCore,
3763
- osuBase.ModDifficultyAdjust,
3764
- osuBase.ModHalfTime,
3765
- osuBase.ModEasy,
3766
- osuBase.ModHardRock,
3767
- osuBase.ModFlashlight,
3768
- osuBase.ModHidden,
3769
- osuBase.ModRelax,
3770
- osuBase.ModAutopilot,
3771
- ]);
3772
3565
 
3773
3566
  /**
3774
3567
  * A performance points calculator that calculates performance points for osu!standard gamemode.
@@ -4100,10 +3893,12 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
4100
3893
  }
4101
3894
  }
4102
3895
 
3896
+ exports.DifficultyAttributes = DifficultyAttributes;
4103
3897
  exports.DifficultyCalculator = DifficultyCalculator;
4104
3898
  exports.DifficultyHitObject = DifficultyHitObject;
4105
3899
  exports.DroidAim = DroidAim;
4106
3900
  exports.DroidAimEvaluator = DroidAimEvaluator;
3901
+ exports.DroidDifficultyAttributes = DroidDifficultyAttributes;
4107
3902
  exports.DroidDifficultyCalculator = DroidDifficultyCalculator;
4108
3903
  exports.DroidDifficultyHitObject = DroidDifficultyHitObject;
4109
3904
  exports.DroidFlashlight = DroidFlashlight;
@@ -4115,8 +3910,10 @@ exports.DroidTap = DroidTap;
4115
3910
  exports.DroidTapEvaluator = DroidTapEvaluator;
4116
3911
  exports.DroidVisual = DroidVisual;
4117
3912
  exports.DroidVisualEvaluator = DroidVisualEvaluator;
3913
+ exports.ExtendedDroidDifficultyAttributes = ExtendedDroidDifficultyAttributes;
4118
3914
  exports.OsuAim = OsuAim;
4119
3915
  exports.OsuAimEvaluator = OsuAimEvaluator;
3916
+ exports.OsuDifficultyAttributes = OsuDifficultyAttributes;
4120
3917
  exports.OsuDifficultyCalculator = OsuDifficultyCalculator;
4121
3918
  exports.OsuDifficultyHitObject = OsuDifficultyHitObject;
4122
3919
  exports.OsuFlashlight = OsuFlashlight;