@rian8337/osu-rebalance-difficulty-calculator 4.0.0-beta.96 → 4.0.0-beta.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +133 -20
- package/package.json +3 -3
- package/typings/index.d.ts +38 -1
package/dist/index.js
CHANGED
|
@@ -60,6 +60,118 @@ class DifficultyCalculator {
|
|
|
60
60
|
flashlight: skills[3].peaks,
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Calculates the difficulty of a `Beatmap` with specific `Mod`s and returns a set of
|
|
65
|
+
* `TimedDifficultyAttributes` representing the difficulty at every relevant time value in the `Beatmap`.
|
|
66
|
+
*
|
|
67
|
+
* @param beatmap The `Beatmap` whose difficulty is to be calculated.
|
|
68
|
+
* @param mods The `Mod`s to apply to the `Beatmap`.
|
|
69
|
+
* @return The set of `TimedDifficultyAttributes`.
|
|
70
|
+
*/
|
|
71
|
+
calculateTimed(beatmap, mods) {
|
|
72
|
+
if (beatmap.hitObjects.objects.length === 0) {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
const playableBeatmap = this.createPlayableBeatmap(beatmap, mods);
|
|
76
|
+
const attributes = osuBase.Utils.initializeArray(beatmap.hitObjects.objects.length);
|
|
77
|
+
const skills = this.createSkills(playableBeatmap);
|
|
78
|
+
const progressiveBeatmap = new ProgressiveCalculationBeatmap(playableBeatmap);
|
|
79
|
+
const { objects } = playableBeatmap.hitObjects;
|
|
80
|
+
const difficultyObjects = this.createDifficultyHitObjects(playableBeatmap);
|
|
81
|
+
let currentIndex = 0;
|
|
82
|
+
for (let i = 0; i < objects.length; ++i) {
|
|
83
|
+
const obj = objects[i];
|
|
84
|
+
progressiveBeatmap.hitObjects.add(obj);
|
|
85
|
+
while (currentIndex < difficultyObjects.length && difficultyObjects[currentIndex].object.endTime <= obj.endTime) {
|
|
86
|
+
for (const skill of skills) {
|
|
87
|
+
skill.process(difficultyObjects[currentIndex]);
|
|
88
|
+
}
|
|
89
|
+
++currentIndex;
|
|
90
|
+
}
|
|
91
|
+
attributes[i] = {
|
|
92
|
+
time: obj.endTime,
|
|
93
|
+
attributes: this.createDifficultyAttributes(beatmap, playableBeatmap, skills, difficultyObjects.slice(0, currentIndex)),
|
|
94
|
+
sliderCount: progressiveBeatmap.hitObjects.sliders,
|
|
95
|
+
sliderTickCount: progressiveBeatmap.hitObjects.sliderTicks,
|
|
96
|
+
sliderRepeatCount: progressiveBeatmap.hitObjects.sliderRepeatPoints
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return attributes;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A {@link PlayableBeatmap} for timed difficulty calculation.
|
|
104
|
+
*/
|
|
105
|
+
class ProgressiveCalculationBeatmap extends osuBase.PlayableBeatmap {
|
|
106
|
+
get maxCombo() {
|
|
107
|
+
return this.hitObjects.maxCombo;
|
|
108
|
+
}
|
|
109
|
+
constructor(baseBeatmap) {
|
|
110
|
+
super(baseBeatmap, baseBeatmap.mods);
|
|
111
|
+
this.hitObjects = new ProgressiveCalculationHitObjects();
|
|
112
|
+
this.baseHitWindow = baseBeatmap.hitWindow;
|
|
113
|
+
}
|
|
114
|
+
createHitWindow() {
|
|
115
|
+
return this.baseHitWindow;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
class ProgressiveCalculationHitObjects extends osuBase.BeatmapHitObjects {
|
|
119
|
+
constructor() {
|
|
120
|
+
super(...arguments);
|
|
121
|
+
this.maxCombo = 0;
|
|
122
|
+
// We store these locally since the super class's getters iterate through all objects, which is inefficient for progressive calculation.
|
|
123
|
+
this.sliderTickCount = 0;
|
|
124
|
+
this.sliderRepeatCount = 0;
|
|
125
|
+
}
|
|
126
|
+
get sliderTicks() {
|
|
127
|
+
return this.sliderTickCount;
|
|
128
|
+
}
|
|
129
|
+
get sliderRepeatPoints() {
|
|
130
|
+
return this.sliderRepeatCount;
|
|
131
|
+
}
|
|
132
|
+
add(...objects) {
|
|
133
|
+
super.add(...objects);
|
|
134
|
+
for (const obj of objects) {
|
|
135
|
+
if (obj instanceof osuBase.Slider) {
|
|
136
|
+
this.maxCombo += obj.nestedHitObjects.length;
|
|
137
|
+
// Similarly, we loop through the nested hit objects since `Slider.ticks` also loops
|
|
138
|
+
// through the nested hit objects, which is inefficient for progressive calculation.
|
|
139
|
+
for (const nestedObj of obj.nestedHitObjects) {
|
|
140
|
+
if (nestedObj instanceof osuBase.SliderTick) {
|
|
141
|
+
++this.sliderTickCount;
|
|
142
|
+
}
|
|
143
|
+
else if (nestedObj instanceof osuBase.SliderRepeat) {
|
|
144
|
+
++this.sliderRepeatCount;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
++this.maxCombo;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
removeAt(index) {
|
|
154
|
+
const obj = super.removeAt(index);
|
|
155
|
+
if (obj !== null) {
|
|
156
|
+
if (obj instanceof osuBase.Slider) {
|
|
157
|
+
this.maxCombo -= obj.nestedHitObjects.length;
|
|
158
|
+
// Similarly, we loop through the nested hit objects since `Slider.ticks` also loops
|
|
159
|
+
// through the nested hit objects, which is inefficient for progressive calculation.
|
|
160
|
+
for (const nestedObj of obj.nestedHitObjects) {
|
|
161
|
+
if (nestedObj instanceof osuBase.SliderTick) {
|
|
162
|
+
--this.sliderTickCount;
|
|
163
|
+
}
|
|
164
|
+
else if (nestedObj instanceof osuBase.SliderRepeat) {
|
|
165
|
+
--this.sliderRepeatCount;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
--this.maxCombo;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return obj;
|
|
174
|
+
}
|
|
63
175
|
}
|
|
64
176
|
|
|
65
177
|
/**
|
|
@@ -151,11 +263,11 @@ class PerformanceCalculator {
|
|
|
151
263
|
* @param options Options for performance calculation.
|
|
152
264
|
*/
|
|
153
265
|
handleOptions(options) {
|
|
154
|
-
var _a, _b;
|
|
266
|
+
var _a, _b, _c;
|
|
155
267
|
if ((options === null || options === void 0 ? void 0 : options.accPercent) instanceof osuBase.Accuracy) {
|
|
156
268
|
// Copy into new instance to not modify the original
|
|
157
269
|
this.computedAccuracy = new osuBase.Accuracy(options.accPercent);
|
|
158
|
-
if (this.computedAccuracy.
|
|
270
|
+
if (!this.computedAccuracy.isN300Resolved) {
|
|
159
271
|
this.computedAccuracy.n300 = Math.max(0, this.totalHits -
|
|
160
272
|
this.computedAccuracy.n100 -
|
|
161
273
|
this.computedAccuracy.n50 -
|
|
@@ -165,16 +277,15 @@ class PerformanceCalculator {
|
|
|
165
277
|
this.computedAccuracy.nmiss = Math.max(0, this.totalHits - this.totalSuccessfulHits);
|
|
166
278
|
}
|
|
167
279
|
}
|
|
280
|
+
else if ((options === null || options === void 0 ? void 0 : options.accPercent) !== undefined) {
|
|
281
|
+
this.computedAccuracy = osuBase.Accuracy.fromPercent(options.accPercent, this.totalHits, (_a = options.miss) !== null && _a !== void 0 ? _a : 0);
|
|
282
|
+
}
|
|
168
283
|
else {
|
|
169
|
-
this.computedAccuracy =
|
|
170
|
-
percent: options === null || options === void 0 ? void 0 : options.accPercent,
|
|
171
|
-
nobjects: this.totalHits,
|
|
172
|
-
nmiss: (_a = options === null || options === void 0 ? void 0 : options.miss) !== null && _a !== void 0 ? _a : 0,
|
|
173
|
-
});
|
|
284
|
+
this.computedAccuracy = osuBase.Accuracy.fromHitCounts({ nmiss: (_b = options === null || options === void 0 ? void 0 : options.miss) !== null && _b !== void 0 ? _b : 0 }, this.totalHits);
|
|
174
285
|
}
|
|
175
286
|
const maxCombo = this.difficultyAttributes.maxCombo;
|
|
176
287
|
const miss = this.computedAccuracy.nmiss;
|
|
177
|
-
this.combo = (
|
|
288
|
+
this.combo = (_c = options === null || options === void 0 ? void 0 : options.combo) !== null && _c !== void 0 ? _c : maxCombo - miss;
|
|
178
289
|
if ((options === null || options === void 0 ? void 0 : options.sliderEndsDropped) !== undefined &&
|
|
179
290
|
options.sliderTicksMissed !== undefined) {
|
|
180
291
|
this._usingClassicSliderAccuracy = false;
|
|
@@ -3412,15 +3523,16 @@ class DroidScoreUtils {
|
|
|
3412
3523
|
/**
|
|
3413
3524
|
* Calculates the maximum possible spinner bonus for a given beatmap.
|
|
3414
3525
|
*
|
|
3415
|
-
* @param beatmap The
|
|
3526
|
+
* @param beatmap The `Beatmap` to calculate the maximum spinner bonus for.
|
|
3527
|
+
* @param playableBeatmap The `PlayableBeatmap` to calculate the maximum spinner bonus for.
|
|
3416
3528
|
* @returns The maximum spinner bonus.
|
|
3417
3529
|
*/
|
|
3418
|
-
static calculateMaximumSpinnerBonus(beatmap) {
|
|
3419
|
-
const { hitObjects } =
|
|
3530
|
+
static calculateMaximumSpinnerBonus(beatmap, playableBeatmap) {
|
|
3531
|
+
const { hitObjects } = playableBeatmap;
|
|
3420
3532
|
if (hitObjects.spinners === 0) {
|
|
3421
3533
|
return 0;
|
|
3422
3534
|
}
|
|
3423
|
-
const scoreMultiplier = osuBase.
|
|
3535
|
+
const scoreMultiplier = new osuBase.DroidScoreMultiplierCalculator(beatmap.difficulty).calculateFor(playableBeatmap.mods.values());
|
|
3424
3536
|
let bonus = 0;
|
|
3425
3537
|
// In osu!droid, there is no time-based limit to spinner RPM, since the limit is
|
|
3426
3538
|
// π/2 rad/*frame* and not rad/second.
|
|
@@ -3429,7 +3541,7 @@ class DroidScoreUtils {
|
|
|
3429
3541
|
// the actual maximum spinner bonus.
|
|
3430
3542
|
const maximumRotationsPerSecond = (Math.PI / 2) * 120;
|
|
3431
3543
|
// Taken from https://github.com/osudroid/osu-droid/blob/45ae4d66ce275382c5de037245ceca8704b3ae75/src/ru/nsu/ccfit/zuev/osu/game/GameScene.java#L1640.
|
|
3432
|
-
const minimumRotationsPerSecond = 2 + (2 *
|
|
3544
|
+
const minimumRotationsPerSecond = 2 + (2 * playableBeatmap.difficulty.od) / 10;
|
|
3433
3545
|
for (const obj of hitObjects.objects) {
|
|
3434
3546
|
if (!(obj instanceof osuBase.Spinner)) {
|
|
3435
3547
|
continue;
|
|
@@ -3472,8 +3584,9 @@ class DroidDifficultyCalculator extends DifficultyCalculator {
|
|
|
3472
3584
|
attributes.overallDifficulty = playableBeatmap.difficulty.od;
|
|
3473
3585
|
// Cap at 32-bit signed integer since that's the maximum score that can be submitted
|
|
3474
3586
|
// to the game's leaderboards.
|
|
3475
|
-
attributes.maximumScore =
|
|
3476
|
-
|
|
3587
|
+
attributes.maximumScore =
|
|
3588
|
+
beatmap.maxDroidScore(playableBeatmap.mods) +
|
|
3589
|
+
DroidScoreUtils.calculateMaximumSpinnerBonus(beatmap, playableBeatmap);
|
|
3477
3590
|
this.populateAimAttributes(attributes, skills, objects);
|
|
3478
3591
|
this.populateTapAttributes(attributes, skills, objects);
|
|
3479
3592
|
this.populateRhythmAttributes(attributes, skills);
|
|
@@ -5048,7 +5161,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
|
|
|
5048
5161
|
1.3 +
|
|
5049
5162
|
this.totalHits *
|
|
5050
5163
|
(0.0016 / (1 + 2 * this._effectiveMissCount)) *
|
|
5051
|
-
Math.pow(this.computedAccuracy.value
|
|
5164
|
+
Math.pow(this.computedAccuracy.value, 16) *
|
|
5052
5165
|
(1 -
|
|
5053
5166
|
0.003 *
|
|
5054
5167
|
Math.pow(this.difficultyAttributes.drainRate, 2));
|
|
@@ -5059,7 +5172,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
|
|
|
5059
5172
|
this.calculateTraceableBonus(this.difficultyAttributes.sliderFactor);
|
|
5060
5173
|
}
|
|
5061
5174
|
// Scale the aim value with accuracy.
|
|
5062
|
-
aimValue *= this.computedAccuracy.value
|
|
5175
|
+
aimValue *= this.computedAccuracy.value;
|
|
5063
5176
|
return aimValue;
|
|
5064
5177
|
}
|
|
5065
5178
|
/**
|
|
@@ -5108,7 +5221,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
|
|
|
5108
5221
|
// Considering to use derivation from perfect accuracy in a probabilistic manner - assume normal distribution
|
|
5109
5222
|
let accuracyValue = Math.pow(1.52163, this.overallDifficulty) *
|
|
5110
5223
|
// It is possible to reach a negative accuracy with this formula. Cap it at zero - zero points.
|
|
5111
|
-
Math.pow(realAccuracy.n300 < 0 ? 0 : realAccuracy.value
|
|
5224
|
+
Math.pow(realAccuracy.n300 < 0 ? 0 : realAccuracy.value, 24) *
|
|
5112
5225
|
2.83;
|
|
5113
5226
|
// Bonus for many hitcircles - it's harder to keep good accuracy up for longer.
|
|
5114
5227
|
accuracyValue *= Math.pow(ncircles / 1000, ncircles < 1000 ? 0.3 : 0.1);
|
|
@@ -5142,7 +5255,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
|
|
|
5142
5255
|
Math.pow(this.effectiveMissCount / this.totalHits, 0.775), Math.pow(this.effectiveMissCount, 0.875));
|
|
5143
5256
|
}
|
|
5144
5257
|
// Scale the flashlight value with accuracy slightly.
|
|
5145
|
-
flashlightValue *= 0.5 + this.computedAccuracy.value
|
|
5258
|
+
flashlightValue *= 0.5 + this.computedAccuracy.value / 2;
|
|
5146
5259
|
return flashlightValue;
|
|
5147
5260
|
}
|
|
5148
5261
|
/**
|
|
@@ -5155,7 +5268,7 @@ class OsuPerformanceCalculator extends PerformanceCalculator {
|
|
|
5155
5268
|
readingValue *= this.calculateMissPenalty(this.effectiveMissCount + aimEstimatedSliderBreaks, this.difficultyAttributes.readingDifficultNoteCount);
|
|
5156
5269
|
}
|
|
5157
5270
|
// Scale the reading value with accuracy _harshly_.
|
|
5158
|
-
readingValue *= Math.pow(this.computedAccuracy.value
|
|
5271
|
+
readingValue *= Math.pow(this.computedAccuracy.value, 3);
|
|
5159
5272
|
return readingValue;
|
|
5160
5273
|
}
|
|
5161
5274
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rian8337/osu-rebalance-difficulty-calculator",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.97",
|
|
4
4
|
"description": "A module for calculating osu!standard beatmap difficulty and performance value with respect to the latest osu!lazer difficulty and performance algorithm.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"osu",
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"url": "https://github.com/Rian8337/osu-droid-module/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@rian8337/osu-base": "4.0.0-beta.
|
|
36
|
+
"@rian8337/osu-base": "4.0.0-beta.97"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "0d77ee41c1b0eca8e46c118e942417483c4a9452"
|
|
42
42
|
}
|
package/typings/index.d.ts
CHANGED
|
@@ -450,6 +450,34 @@ declare abstract class Skill {
|
|
|
450
450
|
protected abstract processInternal(current: DifficultyHitObject): number;
|
|
451
451
|
}
|
|
452
452
|
|
|
453
|
+
/**
|
|
454
|
+
* Wraps a `DifficultyAttributes` object and adds a time value for which the attribute is valid.
|
|
455
|
+
*
|
|
456
|
+
* Output by `DifficultyCalculator.calculateTimed` methods.
|
|
457
|
+
*/
|
|
458
|
+
interface TimedDifficultyAttributes<TAttributes extends DifficultyAttributes> {
|
|
459
|
+
/**
|
|
460
|
+
* The non-clock-adjusted time value at which the attributes take effect.
|
|
461
|
+
*/
|
|
462
|
+
readonly time: number;
|
|
463
|
+
/**
|
|
464
|
+
* The attributes.
|
|
465
|
+
*/
|
|
466
|
+
readonly attributes: TAttributes;
|
|
467
|
+
/**
|
|
468
|
+
* The number of sliders in the beatmap up to this point.
|
|
469
|
+
*/
|
|
470
|
+
readonly sliderCount: number;
|
|
471
|
+
/**
|
|
472
|
+
* The number of slider ticks in the beatmap up to this point.
|
|
473
|
+
*/
|
|
474
|
+
readonly sliderTickCount: number;
|
|
475
|
+
/**
|
|
476
|
+
* The number of slider repeats in the beatmap up to this point.
|
|
477
|
+
*/
|
|
478
|
+
readonly sliderRepeatCount: number;
|
|
479
|
+
}
|
|
480
|
+
|
|
453
481
|
/**
|
|
454
482
|
* The base of a difficulty calculator.
|
|
455
483
|
*/
|
|
@@ -488,6 +516,15 @@ declare abstract class DifficultyCalculator<TBeatmap extends PlayableBeatmap, TH
|
|
|
488
516
|
* @returns The strain peaks of the `Beatmap`.
|
|
489
517
|
*/
|
|
490
518
|
calculateStrainPeaks(beatmap: Beatmap, mods?: ModMap): StrainPeaks;
|
|
519
|
+
/**
|
|
520
|
+
* Calculates the difficulty of a `Beatmap` with specific `Mod`s and returns a set of
|
|
521
|
+
* `TimedDifficultyAttributes` representing the difficulty at every relevant time value in the `Beatmap`.
|
|
522
|
+
*
|
|
523
|
+
* @param beatmap The `Beatmap` whose difficulty is to be calculated.
|
|
524
|
+
* @param mods The `Mod`s to apply to the `Beatmap`.
|
|
525
|
+
* @return The set of `TimedDifficultyAttributes`.
|
|
526
|
+
*/
|
|
527
|
+
calculateTimed(beatmap: Beatmap, mods?: ModMap): TimedDifficultyAttributes<TAttributes>[];
|
|
491
528
|
/**
|
|
492
529
|
* Creates the `Skill`s to calculate the difficulty of a `PlayableBeatmap`.
|
|
493
530
|
*
|
|
@@ -2049,4 +2086,4 @@ declare class OsuSpeed extends HarmonicSkill {
|
|
|
2049
2086
|
}
|
|
2050
2087
|
|
|
2051
2088
|
export { DifficultyAttributes, DifficultyCalculator, DifficultyHitObject, DroidAgilityEvaluator, DroidAim, DroidDifficultyAttributes, DroidDifficultyCalculator, DroidDifficultyHitObject, DroidFlashlight, DroidFlashlightEvaluator, DroidFlowAimEvaluator, DroidPerformanceCalculator, DroidReading, DroidReadingEvaluator, DroidRhythm, DroidRhythmEvaluator, DroidSnapAimEvaluator, DroidTap, DroidTapEvaluator, ExtendedDroidDifficultyAttributes, OsuAgilityEvaluator, OsuAim, OsuDifficultyAttributes, OsuDifficultyCalculator, OsuDifficultyHitObject, OsuFlashlight, OsuFlashlightEvaluator, OsuFlowAimEvaluator, OsuPerformanceCalculator, OsuReading, OsuReadingEvaluator, OsuRhythmEvaluator, OsuSnapAimEvaluator, OsuSpeed, OsuSpeedEvaluator, PerformanceCalculator };
|
|
2052
|
-
export type { CacheableDifficultyAttributes, DifficultSlider, HighStrainSection, IDifficultyAttributes, IDroidDifficultyAttributes, IExtendedDroidDifficultyAttributes, IOsuDifficultyAttributes, PerformanceCalculationOptions, StrainPeaks, TimedStrainPeak };
|
|
2089
|
+
export type { CacheableDifficultyAttributes, DifficultSlider, HighStrainSection, IDifficultyAttributes, IDroidDifficultyAttributes, IExtendedDroidDifficultyAttributes, IOsuDifficultyAttributes, PerformanceCalculationOptions, StrainPeaks, TimedDifficultyAttributes, TimedStrainPeak };
|