@rian8337/osu-difficulty-calculator 1.2.3 → 1.3.0
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/README.md +102 -2
- package/dist/DroidPerformanceCalculator.js +2 -5
- package/package.json +4 -4
- package/typings/index.d.ts +4 -4
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ yarn add @rian8337/osu-base @rian8337/osu-difficulty-calculator
|
|
|
26
26
|
|
|
27
27
|
# Usage
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## Difficulty calculator
|
|
30
30
|
|
|
31
31
|
```js
|
|
32
32
|
import { MapInfo } from "@rian8337/osu-base";
|
|
@@ -67,7 +67,7 @@ console.log(rating.droidStars);
|
|
|
67
67
|
console.log(rating.pcStars);
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
### Specifying difficulty calculation parameters
|
|
71
71
|
|
|
72
72
|
Parameters can be applied to alter the result of the calculation:
|
|
73
73
|
|
|
@@ -104,3 +104,103 @@ console.log(rating.droidStars);
|
|
|
104
104
|
// osu!standard difficulty
|
|
105
105
|
console.log(rating.pcStars);
|
|
106
106
|
```
|
|
107
|
+
|
|
108
|
+
## Performance calculator
|
|
109
|
+
|
|
110
|
+
```js
|
|
111
|
+
import { MapInfo } from "@rian8337/osu-base";
|
|
112
|
+
import {
|
|
113
|
+
DroidPerformanceCalculator,
|
|
114
|
+
MapStars,
|
|
115
|
+
OsuPerformanceCalculator,
|
|
116
|
+
} from "@rian8337/osu-difficulty-calculator";
|
|
117
|
+
|
|
118
|
+
const beatmapInfo = await MapInfo.getInformation({ beatmapID: 901854 });
|
|
119
|
+
|
|
120
|
+
if (!beatmapInfo.title) {
|
|
121
|
+
return console.log("Beatmap not found");
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const rating = new MapStars().calculate({
|
|
125
|
+
map: beatmapInfo.map,
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// osu!droid performance
|
|
129
|
+
const droidPerformance = new DroidPerformanceCalculator().calculate({
|
|
130
|
+
stars: rating.droidStars,
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
console.log(droidPerformance);
|
|
134
|
+
|
|
135
|
+
// osu!standard performance
|
|
136
|
+
const osuPerformance = new OsuPerformanceCalculator().calculate({
|
|
137
|
+
stars: rating.pcStars,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
console.log(osuPerformance);
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Specifying performance calculation parameters
|
|
144
|
+
|
|
145
|
+
Parameters can be passed to alter the result of the calculation:
|
|
146
|
+
|
|
147
|
+
- Combo: The maximum combo achieved. Defaults to the beatmap's maximum combo.
|
|
148
|
+
- Accuracy: The accuracy achieved. Defaults to 100%.
|
|
149
|
+
- Misses: The amount of misses achieved.
|
|
150
|
+
- Tap penalty: Penalty given from three-finger detection. Only applied for osu!droid gamemode. Defaults to 1.
|
|
151
|
+
- Custom statistics: Used to apply a custom speed multiplier and force AR. Defaults to none.
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
import { Accuracy, MapInfo, MapStats } from "@rian8337/osu-base";
|
|
155
|
+
import {
|
|
156
|
+
OsuPerformanceCalculator,
|
|
157
|
+
OsuStarRating,
|
|
158
|
+
} from "@rian8337/osu-difficulty-calculator";
|
|
159
|
+
|
|
160
|
+
const beatmapInfo = await MapInfo.getInformation({ beatmapID: 901854 });
|
|
161
|
+
|
|
162
|
+
if (!beatmapInfo.title) {
|
|
163
|
+
return console.log("Beatmap not found");
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const rating = new OsuStarRating().calculate({
|
|
167
|
+
map: beatmapInfo.map,
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const accuracy = new Accuracy({
|
|
171
|
+
// Specify your misses here
|
|
172
|
+
nmiss: 1,
|
|
173
|
+
|
|
174
|
+
// The module provides a convenient way to specify accuracy based on the data that you have
|
|
175
|
+
// Remove the codes below as you see fit
|
|
176
|
+
|
|
177
|
+
// If you have hit data (amount of 300s, 100s, and 50s)
|
|
178
|
+
n300: 1000,
|
|
179
|
+
n100: 0,
|
|
180
|
+
n50: 0,
|
|
181
|
+
|
|
182
|
+
// If you have accuracy percentage
|
|
183
|
+
// While this method is more convenient to use, the amount of 300s, 100s, and 50s will be estimated
|
|
184
|
+
// This will lead to values being off when calculating for specific accuracies
|
|
185
|
+
percent: 100,
|
|
186
|
+
nobjects: beatmapInfo.objects,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const stats = new MapStats({
|
|
190
|
+
ar: 9.5,
|
|
191
|
+
isForceAR: true,
|
|
192
|
+
speedMultiplier: 1.25,
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const performance = new OsuPerformanceCalculator().calculate({
|
|
196
|
+
stars: rating,
|
|
197
|
+
combo: 1250,
|
|
198
|
+
accPercent: accuracy,
|
|
199
|
+
// The tap penalty can be properly obtained by checking a replay for three finger usage
|
|
200
|
+
// However, a custom value can also be provided
|
|
201
|
+
tapPenalty: 1.5,
|
|
202
|
+
stats: stats,
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
console.log(performance);
|
|
206
|
+
```
|
|
@@ -51,11 +51,8 @@ class DroidPerformanceCalculator extends PerformanceCalculator_1.PerformanceCalc
|
|
|
51
51
|
*/
|
|
52
52
|
calculateAverageRhythmMultiplier() {
|
|
53
53
|
// The first object doesn't have any rhythm multiplier, so we begin with the second object
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
.slice(1);
|
|
57
|
-
this.aggregatedRhythmMultiplier = Math.max(1, rhythmMultipliers.reduce((total, value) => total + value, 0) /
|
|
58
|
-
Math.max(500, rhythmMultipliers.length));
|
|
54
|
+
const rhythmObjects = this.stars.objects.slice(1);
|
|
55
|
+
this.aggregatedRhythmMultiplier = Math.max(1, rhythmObjects.reduce((total, value) => total + value.rhythmMultiplier, 0) / Math.max(500, rhythmObjects.length));
|
|
59
56
|
}
|
|
60
57
|
/**
|
|
61
58
|
* Calculates the aim performance value of the beatmap.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rian8337/osu-difficulty-calculator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A module for calculating osu!standard beatmap difficulty and performance value with respect to the current difficulty and performance algorithm.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"osu",
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"main": "dist/index.js",
|
|
13
13
|
"types": "typings/index.d.ts",
|
|
14
|
+
"typedocMain": "src/index.ts",
|
|
14
15
|
"files": [
|
|
15
16
|
"dist/**",
|
|
16
17
|
"typings/**"
|
|
@@ -21,7 +22,6 @@
|
|
|
21
22
|
},
|
|
22
23
|
"scripts": {
|
|
23
24
|
"build": "tsc",
|
|
24
|
-
"generate-docs": "typedoc src/index.ts",
|
|
25
25
|
"lint": "eslint --ext ts",
|
|
26
26
|
"prepare": "npm run build",
|
|
27
27
|
"test": "jest -i"
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"url": "https://github.com/Rian8337/osu-droid-module/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@rian8337/osu-base": "^1.
|
|
33
|
+
"@rian8337/osu-base": "^1.3.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "0efc41e2d7f077aaf388424318ee9bd356ff611f"
|
|
39
39
|
}
|
package/typings/index.d.ts
CHANGED
|
@@ -872,9 +872,9 @@ declare module "@rian8337/osu-difficulty-calculator" {
|
|
|
872
872
|
*/
|
|
873
873
|
mode?: modes;
|
|
874
874
|
/**
|
|
875
|
-
* The
|
|
875
|
+
* The tap penalty to apply for penalized scores. Only applies to droid gamemode.
|
|
876
876
|
*/
|
|
877
|
-
|
|
877
|
+
tapPenalty?: number;
|
|
878
878
|
/**
|
|
879
879
|
* Custom map statistics to apply custom speed multiplier and force AR values as well as old statistics.
|
|
880
880
|
*/
|
|
@@ -914,9 +914,9 @@ declare module "@rian8337/osu-difficulty-calculator" {
|
|
|
914
914
|
*/
|
|
915
915
|
mode?: modes;
|
|
916
916
|
/**
|
|
917
|
-
* The
|
|
917
|
+
* The tap penalty to apply for penalized scores.
|
|
918
918
|
*/
|
|
919
|
-
|
|
919
|
+
tapPenalty?: number;
|
|
920
920
|
/**
|
|
921
921
|
* Custom map statistics to apply custom speed multiplier and force AR values as well as old statistics.
|
|
922
922
|
*/
|