@rian8337/osu-difficulty-calculator 1.3.0 → 1.4.12

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 (48) hide show
  1. package/dist/DroidPerformanceCalculator.js +52 -62
  2. package/dist/DroidPerformanceCalculator.js.map +1 -0
  3. package/dist/DroidStarRating.js +36 -7
  4. package/dist/DroidStarRating.js.map +1 -0
  5. package/dist/MapStars.js +1 -0
  6. package/dist/MapStars.js.map +1 -0
  7. package/dist/OsuPerformanceCalculator.js +10 -7
  8. package/dist/OsuPerformanceCalculator.js.map +1 -0
  9. package/dist/OsuStarRating.js +1 -0
  10. package/dist/OsuStarRating.js.map +1 -0
  11. package/dist/base/DifficultyAttributes.js +1 -0
  12. package/dist/base/DifficultyAttributes.js.map +1 -0
  13. package/dist/base/PerformanceCalculator.js +16 -4
  14. package/dist/base/PerformanceCalculator.js.map +1 -0
  15. package/dist/base/Skill.js +1 -0
  16. package/dist/base/Skill.js.map +1 -0
  17. package/dist/base/StarRating.js +2 -0
  18. package/dist/base/StarRating.js.map +1 -0
  19. package/dist/base/StrainSkill.js +1 -0
  20. package/dist/base/StrainSkill.js.map +1 -0
  21. package/dist/index.js +1 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/preprocessing/DifficultyHitObject.js +23 -0
  24. package/dist/preprocessing/DifficultyHitObject.js.map +1 -0
  25. package/dist/preprocessing/DifficultyHitObjectCreator.js +43 -1
  26. package/dist/preprocessing/DifficultyHitObjectCreator.js.map +1 -0
  27. package/dist/skills/DroidAim.js +3 -2
  28. package/dist/skills/DroidAim.js.map +1 -0
  29. package/dist/skills/DroidFlashlight.js +2 -1
  30. package/dist/skills/DroidFlashlight.js.map +1 -0
  31. package/dist/skills/DroidRhythm.js +8 -4
  32. package/dist/skills/DroidRhythm.js.map +1 -0
  33. package/dist/skills/DroidSkill.js +15 -1
  34. package/dist/skills/DroidSkill.js.map +1 -0
  35. package/dist/skills/DroidTap.js +3 -3
  36. package/dist/skills/DroidTap.js.map +1 -0
  37. package/dist/skills/DroidVisual.js +81 -0
  38. package/dist/skills/DroidVisual.js.map +1 -0
  39. package/dist/skills/OsuAim.js +1 -0
  40. package/dist/skills/OsuAim.js.map +1 -0
  41. package/dist/skills/OsuFlashlight.js +1 -0
  42. package/dist/skills/OsuFlashlight.js.map +1 -0
  43. package/dist/skills/OsuSkill.js +1 -0
  44. package/dist/skills/OsuSkill.js.map +1 -0
  45. package/dist/skills/OsuSpeed.js +1 -0
  46. package/dist/skills/OsuSpeed.js.map +1 -0
  47. package/package.json +3 -3
  48. package/typings/index.d.ts +219 -126
@@ -52,6 +52,10 @@ declare module "@rian8337/osu-difficulty-calculator" {
52
52
  * The flashlight strain generated by the hitobject.
53
53
  */
54
54
  flashlightStrain: number;
55
+ /**
56
+ * The visual strain generated by the hitobject.
57
+ */
58
+ visualStrain: number;
55
59
  /**
56
60
  * The normalized distance from the "lazy" end position of the previous hitobject to the start position of this hitobject.
57
61
  *
@@ -101,6 +105,24 @@ declare module "@rian8337/osu-difficulty-calculator" {
101
105
  * Adjusted start time of the hitobject, taking speed multiplier into account.
102
106
  */
103
107
  startTime: number;
108
+ /**
109
+ * Adjusted end time of the hitobject, taking speed multiplier into account.
110
+ */
111
+ endTime: number;
112
+ /**
113
+ * The note density of the hitobject.
114
+ */
115
+ noteDensity: number;
116
+ /**
117
+ * The overlapping factor of the hitobject.
118
+ *
119
+ * This is used to scale visual skill.
120
+ */
121
+ overlappingFactor: number;
122
+ /**
123
+ * Adjusted velocity of the hitobject, taking speed multiplier into account.
124
+ */
125
+ velocity: number;
104
126
  /**
105
127
  * @param object The underlying hitobject.
106
128
  */
@@ -135,6 +157,7 @@ declare module "@rian8337/osu-difficulty-calculator" {
135
157
  circleSize: number;
136
158
  speedMultiplier: number;
137
159
  mode: modes;
160
+ preempt?: number;
138
161
  }): DifficultyHitObject[];
139
162
  /**
140
163
  * Calculates a slider's cursor position.
@@ -182,7 +205,7 @@ declare module "@rian8337/osu-difficulty-calculator" {
182
205
  */
183
206
  protected override strainValueAt(current: DifficultyHitObject): number;
184
207
  /**
185
- * @param currentObject The hitobject to save to.
208
+ * @param current The hitobject to save to.
186
209
  */
187
210
  protected override saveToHitObject(current: DifficultyHitObject): void;
188
211
  }
@@ -210,6 +233,7 @@ declare module "@rian8337/osu-difficulty-calculator" {
210
233
  */
211
234
  protected override saveToHitObject(current: DifficultyHitObject): void;
212
235
  }
236
+
213
237
  /**
214
238
  * A performance points calculator that calculates performance points for osu!droid gamemode.
215
239
  */
@@ -232,7 +256,11 @@ declare module "@rian8337/osu-difficulty-calculator" {
232
256
  * The flashlight performance value.
233
257
  */
234
258
  flashlight: number;
235
- private averageRhythmMultiplier: number;
259
+ /**
260
+ * The visual performance value.
261
+ */
262
+ visual: number;
263
+ private tapPenalty: number;
236
264
  override calculate(params: {
237
265
  /**
238
266
  * The star rating instance to calculate.
@@ -259,10 +287,8 @@ declare module "@rian8337/osu-difficulty-calculator" {
259
287
  */
260
288
  stats?: MapStats;
261
289
  }): this;
262
- /**
263
- * Calculates the average rhythm multiplier of the beatmap.
264
- */
265
- private calculateAverageRhythmMultiplier(): void;
290
+ protected override calculateValues(): void;
291
+ protected override calculateTotalValue(): number;
266
292
  /**
267
293
  * Calculates the aim performance value of the beatmap.
268
294
  */
@@ -279,6 +305,10 @@ declare module "@rian8337/osu-difficulty-calculator" {
279
305
  * Calculates the flashlight performance value of the beatmap.
280
306
  */
281
307
  private calculateFlashlightValue(): void;
308
+ /**
309
+ * Calculates the visual performance value of the beatmap.
310
+ */
311
+ private calculateVisualValue(): void;
282
312
  override toString(): string;
283
313
  }
284
314
 
@@ -317,10 +347,18 @@ declare module "@rian8337/osu-difficulty-calculator" {
317
347
  * The tap star rating of the beatmap.
318
348
  */
319
349
  tap: number;
350
+ /**
351
+ * The rhythm star rating of the beatmap.
352
+ */
353
+ rhythm: number;
320
354
  /**
321
355
  * The flashlight star rating of the beatmap.
322
356
  */
323
357
  flashlight: number;
358
+ /**
359
+ * The visual star rating of the beatmap.
360
+ */
361
+ visual: number;
324
362
  protected override readonly difficultyMultiplier: number;
325
363
  /**
326
364
  * Calculates the star rating of the specified beatmap.
@@ -363,17 +401,19 @@ declare module "@rian8337/osu-difficulty-calculator" {
363
401
  */
364
402
  calculateTap(): void;
365
403
  /**
366
- * Calculates the flashlight star rating of the beatmap and stores it in this instance.
404
+ * Calculates the rhythm star rating of the beatmap and stores it in this instance.
367
405
  */
368
- calculateFlashlight(): void;
406
+ calculateRhythm(): void;
369
407
  /**
370
- * Calculates the total star rating of the beatmap and stores it in this instance.
408
+ * Calculates the flashlight star rating of the beatmap and stores it in this instance.
371
409
  */
372
- calculateTotal(): void;
410
+ calculateFlashlight(): void;
373
411
  /**
374
- * Calculates every star rating of the beatmap and stores it in this instance.
412
+ * Calculates the visual star rating of the beatmap and stores it in this instance.
375
413
  */
376
- calculateAll(): void;
414
+ calculateVisual(): void;
415
+ override calculateTotal(): void;
416
+ override calculateAll(): void;
377
417
  /**
378
418
  * Returns a string representative of the class.
379
419
  */
@@ -399,9 +439,9 @@ declare module "@rian8337/osu-difficulty-calculator" {
399
439
  */
400
440
  private postCalculateTap(tapSkill: DroidTap): void;
401
441
  /**
402
- * Calculates the speed note count attribute.
442
+ * Calculates speed-related attributes.
403
443
  */
404
- private calculateSpeedNoteCount(): void;
444
+ private calculateSpeedAttributes(): void;
405
445
  /**
406
446
  * Called after rhythm skill calculation.
407
447
  *
@@ -414,13 +454,18 @@ declare module "@rian8337/osu-difficulty-calculator" {
414
454
  * @param flashlightSkill The flashlight skill.
415
455
  */
416
456
  private postCalculateFlashlight(flashlightSkill: DroidFlashlight): void;
457
+ /**
458
+ * Called after visual skill calculation.
459
+ *
460
+ * @param visualSkill The visual skill.
461
+ */
462
+ private postCalculateVisual(visualSkill: DroidVisual): void;
417
463
  }
418
464
 
419
465
  /**
420
466
  * Represents the skill required to press keys or tap with regards to keeping up with the speed at which objects need to be hit.
421
467
  */
422
468
  export class DroidTap extends DroidSkill {
423
- protected override readonly historyLength: number;
424
469
  protected override readonly skillMultiplier: number;
425
470
  protected override readonly strainDecayBase: number;
426
471
  protected override readonly reducedSectionBaseline: number;
@@ -429,10 +474,6 @@ declare module "@rian8337/osu-difficulty-calculator" {
429
474
  private readonly minSpeedBonus: number;
430
475
  private currentTapStrain: number;
431
476
  private currentOriginalTapStrain: number;
432
- private readonly rhythmMultiplier: number;
433
- private readonly historyTimeMax: number;
434
- private currentRhythm: number;
435
- private readonly overallDifficulty: number;
436
477
  private readonly hitWindow: OsuHitWindow;
437
478
  constructor(mods: Mod[], overallDifficulty: number);
438
479
  /**
@@ -453,6 +494,32 @@ declare module "@rian8337/osu-difficulty-calculator" {
453
494
  protected override saveToHitObject(current: DifficultyHitObject): void;
454
495
  }
455
496
 
497
+ /**
498
+ * Represents the skill required to read every object in the map.
499
+ */
500
+ export class DroidVisual extends DroidSkill {
501
+ protected override readonly skillMultiplier: number;
502
+ protected override readonly strainDecayBase: number;
503
+ protected override readonly reducedSectionBaseline: number;
504
+ protected override readonly reducedSectionCount: number;
505
+ protected override readonly starsPerDouble: number;
506
+ private readonly preempt: number;
507
+ private readonly isHidden: boolean;
508
+ constructor(mods: Mod[], preempt: number);
509
+ /**
510
+ * @param current The hitobject to calculate.
511
+ */
512
+ protected strainValueOf(current: DifficultyHitObject): number;
513
+ /**
514
+ * @param current The hitobject to calculate.
515
+ */
516
+ protected override strainValueAt(current: DifficultyHitObject): number;
517
+ /**
518
+ * @param current The hitobject to save to.
519
+ */
520
+ protected override saveToHitObject(current: DifficultyHitObject): void;
521
+ }
522
+
456
523
  /**
457
524
  * A star rating calculator that configures which mode to calculate difficulty for and what mods are applied.
458
525
  */
@@ -587,6 +654,8 @@ declare module "@rian8337/osu-difficulty-calculator" {
587
654
  */
588
655
  stats?: MapStats;
589
656
  }): this;
657
+ protected override calculateValues(): void;
658
+ protected override calculateTotalValue(): number;
590
659
  /**
591
660
  * Calculates the aim performance value of the beatmap.
592
661
  */
@@ -621,13 +690,9 @@ declare module "@rian8337/osu-difficulty-calculator" {
621
690
  protected override readonly reducedSectionBaseline: number;
622
691
  protected override readonly difficultyMultiplier: number;
623
692
  protected override readonly decayWeight: number;
624
- private readonly rhythmMultiplier: number;
625
- private readonly historyTimeMax: number;
626
- private currentSpeedStrain: number;
627
- private currentRhythm: number;
628
693
  private readonly minSpeedBonus: number;
629
- private readonly greatWindow: number;
630
- constructor(mods: Mod[], greatWindow: number);
694
+ private readonly maxSpeedBonus: number;
695
+ private readonly angleBonusScale: number;
631
696
  /**
632
697
  * @param current The hitobject to calculate.
633
698
  */
@@ -689,14 +754,8 @@ declare module "@rian8337/osu-difficulty-calculator" {
689
754
  * Calculates the flashlight star rating of the beatmap and stores it in this instance.
690
755
  */
691
756
  calculateFlashlight(): void;
692
- /**
693
- * Calculates the total star rating of the beatmap and stores it in this instance.
694
- */
695
- calculateTotal(): void;
696
- /**
697
- * Calculates every star rating of the beatmap and stores it in this instance.
698
- */
699
- calculateAll(): void;
757
+ override calculateTotal(): void;
758
+ override calculateAll(): void;
700
759
  /**
701
760
  * Returns a string representative of the class.
702
761
  */
@@ -739,6 +798,8 @@ declare module "@rian8337/osu-difficulty-calculator" {
739
798
  export interface DifficultyAttributes {
740
799
  speedNoteCount: number;
741
800
  sliderFactor: number;
801
+ aimDifficultStrainCount: number;
802
+ speedDifficultStrainCount: number;
742
803
  }
743
804
 
744
805
  /**
@@ -867,10 +928,6 @@ declare module "@rian8337/osu-difficulty-calculator" {
867
928
  * The amount of misses achieved in the score.
868
929
  */
869
930
  miss?: number;
870
- /**
871
- * The gamemode to calculate.
872
- */
873
- mode?: modes;
874
931
  /**
875
932
  * The tap penalty to apply for penalized scores. Only applies to droid gamemode.
876
933
  */
@@ -885,13 +942,53 @@ declare module "@rian8337/osu-difficulty-calculator" {
885
942
  */
886
943
  abstract toString(): string;
887
944
  /**
888
- * Calculates the base performance value for of a star rating.
945
+ * Internal calculation method, used to process calculation from implementations.
946
+ */
947
+ protected calculateInternal(
948
+ params: {
949
+ /**
950
+ * The star rating instance to calculate.
951
+ */
952
+ stars: StarRating;
953
+ /**
954
+ * The maximum combo achieved in the score.
955
+ */
956
+ combo?: number;
957
+ /**
958
+ * The accuracy achieved in the score.
959
+ */
960
+ accPercent?: Accuracy | number;
961
+ /**
962
+ * The amount of misses achieved in the score.
963
+ */
964
+ miss?: number;
965
+ /**
966
+ * The tap penalty to apply for penalized scores. Only applies to droid gamemode.
967
+ */
968
+ tapPenalty?: number;
969
+ /**
970
+ * Custom map statistics to apply custom speed multiplier and force AR values as well as old statistics.
971
+ */
972
+ stats?: MapStats;
973
+ },
974
+ mode: modes
975
+ ): this;
976
+ /**
977
+ * Calculates values that will be used for calculating the total performance value of the beatmap.
978
+ */
979
+ protected abstract calculateValues(): void;
980
+ /**
981
+ * Calculates the total performance value of the beatmap.
982
+ */
983
+ protected abstract calculateTotalValue(): number;
984
+ /**
985
+ * Calculates the base performance value of a star rating.
889
986
  */
890
987
  protected baseValue(stars: number): number;
891
988
  /**
892
989
  * Processes given parameters for usage in performance calculation.
893
990
  */
894
- protected handleParams(
991
+ private handleParams(
895
992
  params: {
896
993
  /**
897
994
  * The star rating instance to calculate.
@@ -909,10 +1006,6 @@ declare module "@rian8337/osu-difficulty-calculator" {
909
1006
  * The amount of misses achieved in the score.
910
1007
  */
911
1008
  miss?: number;
912
- /**
913
- * The gamemode to calculate.
914
- */
915
- mode?: modes;
916
1009
  /**
917
1010
  * The tap penalty to apply for penalized scores.
918
1011
  */
@@ -964,6 +1057,89 @@ declare module "@rian8337/osu-difficulty-calculator" {
964
1057
  abstract difficultyValue(): number;
965
1058
  }
966
1059
 
1060
+ /**
1061
+ * Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
1062
+ * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
1063
+ */
1064
+ abstract class StrainSkill extends Skill {
1065
+ /**
1066
+ * The strain of currently calculated hitobject.
1067
+ */
1068
+ protected currentStrain: number;
1069
+
1070
+ /**
1071
+ * The current section's strain peak.
1072
+ */
1073
+ protected currentSectionPeak: number;
1074
+
1075
+ /**
1076
+ * Strain peaks are stored here.
1077
+ */
1078
+ readonly strainPeaks: number[];
1079
+ /**
1080
+ * The number of sections with the highest strains, which the peak strain reductions will apply to.
1081
+ * This is done in order to decrease their impact on the overall difficulty of the map for this skill.
1082
+ */
1083
+ protected abstract readonly reducedSectionCount: number;
1084
+
1085
+ /**
1086
+ * The baseline multiplier applied to the section with the biggest strain.
1087
+ */
1088
+ protected abstract readonly reducedSectionBaseline: number;
1089
+
1090
+ /**
1091
+ * Strain values are multiplied by this number for the given skill. Used to balance the value of different skills between each other.
1092
+ */
1093
+ protected abstract readonly skillMultiplier: number;
1094
+
1095
+ /**
1096
+ * Determines how quickly strain decays for the given skill.
1097
+ *
1098
+ * For example, a value of 0.15 indicates that strain decays to 15% of its original value in one second.
1099
+ */
1100
+ protected abstract readonly strainDecayBase: number;
1101
+
1102
+ protected readonly sectionLength: number;
1103
+
1104
+ protected currentSectionEnd: number;
1105
+
1106
+ /**
1107
+ * Calculates the strain value of a hitobject and stores the value in it. This value is affected by previously processed objects.
1108
+ *
1109
+ * @param current The hitobject to process.
1110
+ */
1111
+ protected override process(current: DifficultyHitObject): void;
1112
+
1113
+ /**
1114
+ * Saves the current peak strain level to the list of strain peaks, which will be used to calculate an overall difficulty.
1115
+ */
1116
+ saveCurrentPeak(): void;
1117
+
1118
+ /**
1119
+ * Sets the initial strain level for a new section.
1120
+ *
1121
+ * @param offset The beginning of the new section in milliseconds, adjusted by speed multiplier.
1122
+ */
1123
+ protected startNewSectionFrom(offset: number): void;
1124
+
1125
+ /**
1126
+ * Calculates strain decay for a specified time frame.
1127
+ *
1128
+ * @param ms The time frame to calculate.
1129
+ */
1130
+ protected strainDecay(ms: number): number;
1131
+
1132
+ /**
1133
+ * Calculates the strain value at a hitobject.
1134
+ */
1135
+ protected abstract strainValueAt(current: DifficultyHitObject): number;
1136
+
1137
+ /**
1138
+ * Saves the current strain to a hitobject.
1139
+ */
1140
+ protected abstract saveToHitObject(current: DifficultyHitObject): void;
1141
+ }
1142
+
967
1143
  /**
968
1144
  * The base of difficulty calculation.
969
1145
  */
@@ -1075,88 +1251,5 @@ declare module "@rian8337/osu-difficulty-calculator" {
1075
1251
  protected basePerformanceValue(rating: number): number;
1076
1252
  }
1077
1253
 
1078
- /**
1079
- * Used to processes strain values of difficulty hitobjects, keep track of strain levels caused by the processed objects
1080
- * and to calculate a final difficulty value representing the difficulty of hitting all the processed objects.
1081
- */
1082
- abstract class StrainSkill extends Skill {
1083
- /**
1084
- * The strain of currently calculated hitobject.
1085
- */
1086
- protected currentStrain: number;
1087
-
1088
- /**
1089
- * The current section's strain peak.
1090
- */
1091
- protected currentSectionPeak: number;
1092
-
1093
- /**
1094
- * Strain peaks are stored here.
1095
- */
1096
- readonly strainPeaks: number[];
1097
- /**
1098
- * The number of sections with the highest strains, which the peak strain reductions will apply to.
1099
- * This is done in order to decrease their impact on the overall difficulty of the map for this skill.
1100
- */
1101
- protected abstract readonly reducedSectionCount: number;
1102
-
1103
- /**
1104
- * The baseline multiplier applied to the section with the biggest strain.
1105
- */
1106
- protected abstract readonly reducedSectionBaseline: number;
1107
-
1108
- /**
1109
- * Strain values are multiplied by this number for the given skill. Used to balance the value of different skills between each other.
1110
- */
1111
- protected abstract readonly skillMultiplier: number;
1112
-
1113
- /**
1114
- * Determines how quickly strain decays for the given skill.
1115
- *
1116
- * For example, a value of 0.15 indicates that strain decays to 15% of its original value in one second.
1117
- */
1118
- protected abstract readonly strainDecayBase: number;
1119
-
1120
- protected readonly sectionLength: number;
1121
-
1122
- protected currentSectionEnd: number;
1123
-
1124
- /**
1125
- * Calculates the strain value of a hitobject and stores the value in it. This value is affected by previously processed objects.
1126
- *
1127
- * @param current The hitobject to process.
1128
- */
1129
- protected override process(current: DifficultyHitObject): void;
1130
-
1131
- /**
1132
- * Saves the current peak strain level to the list of strain peaks, which will be used to calculate an overall difficulty.
1133
- */
1134
- saveCurrentPeak(): void;
1135
-
1136
- /**
1137
- * Sets the initial strain level for a new section.
1138
- *
1139
- * @param offset The beginning of the new section in milliseconds, adjusted by speed multiplier.
1140
- */
1141
- protected startNewSectionFrom(offset: number): void;
1142
-
1143
- /**
1144
- * Calculates strain decay for a specified time frame.
1145
- *
1146
- * @param ms The time frame to calculate.
1147
- */
1148
- protected strainDecay(ms: number): number;
1149
-
1150
- /**
1151
- * Calculates the strain value at a hitobject.
1152
- */
1153
- protected abstract strainValueAt(current: DifficultyHitObject): number;
1154
-
1155
- /**
1156
- * Saves the current strain to a hitobject.
1157
- */
1158
- protected abstract saveToHitObject(current: DifficultyHitObject): void;
1159
- }
1160
-
1161
1254
  //#endregion
1162
1255
  }