@rian8337/osu-droid-replay-analyzer 3.0.0-beta.8 → 3.0.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 +4 -4
- package/dist/index.js +2516 -2155
- package/dist/index.js.map +1 -1
- package/package.json +47 -47
- package/typings/index.d.ts +936 -764
package/dist/index.js
CHANGED
|
@@ -29,2185 +29,2544 @@ function _interopNamespace(e) {
|
|
|
29
29
|
|
|
30
30
|
var javaDeserialization__namespace = /*#__PURE__*/_interopNamespace(javaDeserialization);
|
|
31
31
|
|
|
32
|
-
/**
|
|
33
|
-
* Movement types of a cursor in an osu!droid replay.
|
|
34
|
-
*
|
|
35
|
-
* The cursor movement is represented as a player's action on the screen.
|
|
36
|
-
*/
|
|
37
|
-
exports.
|
|
38
|
-
(function (
|
|
39
|
-
/**
|
|
40
|
-
* The player places their finger on the screen.
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The player drags their finger on the screen.
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* The player releases their finger from the screen.
|
|
49
|
-
*/
|
|
50
|
-
|
|
51
|
-
})(exports.
|
|
32
|
+
/**
|
|
33
|
+
* Movement types of a cursor in an osu!droid replay.
|
|
34
|
+
*
|
|
35
|
+
* The cursor movement is represented as a player's action on the screen.
|
|
36
|
+
*/
|
|
37
|
+
exports.MovementType = void 0;
|
|
38
|
+
(function (MovementType) {
|
|
39
|
+
/**
|
|
40
|
+
* The player places their finger on the screen.
|
|
41
|
+
*/
|
|
42
|
+
MovementType[MovementType["down"] = 0] = "down";
|
|
43
|
+
/**
|
|
44
|
+
* The player drags their finger on the screen.
|
|
45
|
+
*/
|
|
46
|
+
MovementType[MovementType["move"] = 1] = "move";
|
|
47
|
+
/**
|
|
48
|
+
* The player releases their finger from the screen.
|
|
49
|
+
*/
|
|
50
|
+
MovementType[MovementType["up"] = 2] = "up";
|
|
51
|
+
})(exports.MovementType || (exports.MovementType = {}));
|
|
52
52
|
|
|
53
|
-
/**
|
|
54
|
-
* Represents a cursor's occurrence.
|
|
55
|
-
*/
|
|
56
|
-
class CursorOccurrence {
|
|
57
|
-
/**
|
|
58
|
-
* The time of this occurrence.
|
|
59
|
-
*/
|
|
60
|
-
time;
|
|
61
|
-
/**
|
|
62
|
-
* The position of the occurrence.
|
|
63
|
-
*/
|
|
64
|
-
position;
|
|
65
|
-
/**
|
|
66
|
-
* The movement ID of the occurrence.
|
|
67
|
-
*/
|
|
68
|
-
id;
|
|
69
|
-
constructor(time, x, y, id) {
|
|
70
|
-
this.time = time;
|
|
71
|
-
this.position = new osuBase.Vector2(x, y);
|
|
72
|
-
this.id = id;
|
|
73
|
-
}
|
|
53
|
+
/**
|
|
54
|
+
* Represents a cursor's occurrence.
|
|
55
|
+
*/
|
|
56
|
+
class CursorOccurrence {
|
|
57
|
+
/**
|
|
58
|
+
* The time of this occurrence.
|
|
59
|
+
*/
|
|
60
|
+
time;
|
|
61
|
+
/**
|
|
62
|
+
* The position of the occurrence.
|
|
63
|
+
*/
|
|
64
|
+
position;
|
|
65
|
+
/**
|
|
66
|
+
* The movement ID of the occurrence.
|
|
67
|
+
*/
|
|
68
|
+
id;
|
|
69
|
+
constructor(time, x, y, id) {
|
|
70
|
+
this.time = time;
|
|
71
|
+
this.position = new osuBase.Vector2(x, y);
|
|
72
|
+
this.id = id;
|
|
73
|
+
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
/**
|
|
77
|
-
* Represents a group of cursor occurrences representing a cursor instance's
|
|
78
|
-
* movement when a player places their finger on the screen.
|
|
79
|
-
*/
|
|
80
|
-
class CursorOccurrenceGroup {
|
|
81
|
-
/**
|
|
82
|
-
* The cursor occurrence of movement type `movementType.DOWN`.
|
|
83
|
-
*/
|
|
84
|
-
get down() {
|
|
85
|
-
return this._down;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* The cursor occurrence of movement type `movementType.DOWN`.
|
|
89
|
-
*/
|
|
90
|
-
set down(value) {
|
|
91
|
-
if (value.id !== exports.
|
|
92
|
-
throw new TypeError("Attempting to set the down cursor occurrence to one with different movement type.");
|
|
93
|
-
}
|
|
94
|
-
this._down = value;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* The cursor occurrences of movement type `movementType.MOVE`.
|
|
98
|
-
*/
|
|
99
|
-
get moves() {
|
|
100
|
-
return this._moves;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* The cursor occurrence of movement type `movementType.UP`.
|
|
104
|
-
*
|
|
105
|
-
* May not exist, such as when the player holds their cursor until the end of a beatmap.
|
|
106
|
-
*/
|
|
107
|
-
get up() {
|
|
108
|
-
return this._up;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* The cursor occurrence of movement type `movementType.UP`.
|
|
112
|
-
*
|
|
113
|
-
* May not exist, such as when the player holds their cursor until the end of a beatmap.
|
|
114
|
-
*/
|
|
115
|
-
set up(value) {
|
|
116
|
-
if (value && value.id !== exports.
|
|
117
|
-
throw new TypeError("Attempting to set the up cursor occurrence to one with different movement type.");
|
|
118
|
-
}
|
|
119
|
-
this._up = value;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* The time at which this cursor occurrence group starts.
|
|
123
|
-
*/
|
|
124
|
-
get startTime() {
|
|
125
|
-
return this._down.time;
|
|
126
|
-
}
|
|
127
|
-
/**
|
|
128
|
-
* The time at which this cursor occurrence group ends.
|
|
129
|
-
*/
|
|
130
|
-
get endTime() {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
this.
|
|
167
|
-
this.
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
*
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if (this.
|
|
189
|
-
return
|
|
190
|
-
}
|
|
191
|
-
if (this.
|
|
192
|
-
return this.
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
else {
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Represents a group of cursor occurrences representing a cursor instance's
|
|
78
|
+
* movement when a player places their finger on the screen.
|
|
79
|
+
*/
|
|
80
|
+
class CursorOccurrenceGroup {
|
|
81
|
+
/**
|
|
82
|
+
* The cursor occurrence of movement type `movementType.DOWN`.
|
|
83
|
+
*/
|
|
84
|
+
get down() {
|
|
85
|
+
return this._down;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The cursor occurrence of movement type `movementType.DOWN`.
|
|
89
|
+
*/
|
|
90
|
+
set down(value) {
|
|
91
|
+
if (value.id !== exports.MovementType.down) {
|
|
92
|
+
throw new TypeError("Attempting to set the down cursor occurrence to one with different movement type.");
|
|
93
|
+
}
|
|
94
|
+
this._down = value;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The cursor occurrences of movement type `movementType.MOVE`.
|
|
98
|
+
*/
|
|
99
|
+
get moves() {
|
|
100
|
+
return this._moves;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The cursor occurrence of movement type `movementType.UP`.
|
|
104
|
+
*
|
|
105
|
+
* May not exist, such as when the player holds their cursor until the end of a beatmap.
|
|
106
|
+
*/
|
|
107
|
+
get up() {
|
|
108
|
+
return this._up;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The cursor occurrence of movement type `movementType.UP`.
|
|
112
|
+
*
|
|
113
|
+
* May not exist, such as when the player holds their cursor until the end of a beatmap.
|
|
114
|
+
*/
|
|
115
|
+
set up(value) {
|
|
116
|
+
if (value && value.id !== exports.MovementType.up) {
|
|
117
|
+
throw new TypeError("Attempting to set the up cursor occurrence to one with different movement type.");
|
|
118
|
+
}
|
|
119
|
+
this._up = value;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The time at which this cursor occurrence group starts.
|
|
123
|
+
*/
|
|
124
|
+
get startTime() {
|
|
125
|
+
return this._down.time;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* The time at which this cursor occurrence group ends.
|
|
129
|
+
*/
|
|
130
|
+
get endTime() {
|
|
131
|
+
return this._up?.time ?? this._moves.at(-1)?.time ?? this._down.time;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The duration this cursor occurrence group is active for.
|
|
135
|
+
*/
|
|
136
|
+
get duration() {
|
|
137
|
+
return this.endTime - this.startTime;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* All cursor occurrences in this group.
|
|
141
|
+
*
|
|
142
|
+
* This iterates all occurrences and as such should be used sparingly or stored locally.
|
|
143
|
+
*/
|
|
144
|
+
get allOccurrences() {
|
|
145
|
+
const cursors = [this._down, ...this._moves];
|
|
146
|
+
if (this._up) {
|
|
147
|
+
cursors.push(this._up);
|
|
148
|
+
}
|
|
149
|
+
return cursors;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The cursor occurrence of movement type `movementType.DOWN`.
|
|
153
|
+
*/
|
|
154
|
+
_down;
|
|
155
|
+
/**
|
|
156
|
+
* The cursor occurrences of movement type `movementType.MOVE`.
|
|
157
|
+
*/
|
|
158
|
+
_moves;
|
|
159
|
+
/**
|
|
160
|
+
* The cursor occurrence of movement type `movementType.UP`.
|
|
161
|
+
*
|
|
162
|
+
* May not exist, such as when the player holds their cursor until the end of a beatmap.
|
|
163
|
+
*/
|
|
164
|
+
_up;
|
|
165
|
+
constructor(down, moves, up) {
|
|
166
|
+
this._down = down;
|
|
167
|
+
this._moves = moves;
|
|
168
|
+
// Re-set down cursor occurrence for checking.
|
|
169
|
+
this.down = down;
|
|
170
|
+
this.up = up;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Determines whether this cursor occurrence group is active at the specified time.
|
|
174
|
+
*
|
|
175
|
+
* @param time The time.
|
|
176
|
+
* @returns Whether this cursor occurrence group is active at the specified time.
|
|
177
|
+
*/
|
|
178
|
+
isActiveAt(time) {
|
|
179
|
+
return time >= this.startTime && time <= this.endTime;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Finds the cursor occurrence that is active at a given time.
|
|
183
|
+
*
|
|
184
|
+
* @param time The time.
|
|
185
|
+
* @returns The cursor occurrence at the given time, `null` if not found.
|
|
186
|
+
*/
|
|
187
|
+
cursorAt(time) {
|
|
188
|
+
if (!this.isActiveAt(time)) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
if (this._down.time === time) {
|
|
192
|
+
return this._down;
|
|
193
|
+
}
|
|
194
|
+
if (this._up?.time === time) {
|
|
195
|
+
return this._up;
|
|
196
|
+
}
|
|
197
|
+
let l = 0;
|
|
198
|
+
let r = this._moves.length - 2;
|
|
199
|
+
while (l <= r) {
|
|
200
|
+
const pivot = l + ((r - l) >> 1);
|
|
201
|
+
if (this._moves[pivot].time < time) {
|
|
202
|
+
l = pivot + 1;
|
|
203
|
+
}
|
|
204
|
+
else if (this._moves[pivot].time > time) {
|
|
205
|
+
r = pivot - 1;
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
return this._moves[pivot];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// l will be the first cursor occurrence with time > this._moves[l].time, but we want the one before it
|
|
212
|
+
return this._moves[l - 1];
|
|
213
|
+
}
|
|
211
214
|
}
|
|
212
215
|
|
|
213
|
-
/**
|
|
214
|
-
* Represents a cursor instance in an osu!droid replay.
|
|
215
|
-
*
|
|
216
|
-
* Stores cursor movement data in the form of `CursorOccurrenceGroup`s.
|
|
217
|
-
*
|
|
218
|
-
* This is used when analyzing replays using replay analyzer.
|
|
219
|
-
*/
|
|
220
|
-
class CursorData {
|
|
221
|
-
/**
|
|
222
|
-
* The occurrence groups of this cursor instance.
|
|
223
|
-
*/
|
|
224
|
-
occurrenceGroups = [];
|
|
225
|
-
/**
|
|
226
|
-
* The time at which the first occurrence of this cursor instance occurs.
|
|
227
|
-
*
|
|
228
|
-
* Will return `null` if there are no occurrences.
|
|
229
|
-
*/
|
|
230
|
-
get earliestOccurrenceTime() {
|
|
231
|
-
return this.occurrenceGroups.at(0)?.startTime ?? null;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* The time at which the latest occurrence of this cursor instance occurs.
|
|
235
|
-
*
|
|
236
|
-
* Will return `null` if there are no occurrences.
|
|
237
|
-
*/
|
|
238
|
-
get latestOccurrenceTime() {
|
|
239
|
-
return this.occurrenceGroups.at(-1)?.endTime ?? null;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* The amount of cursor occurrences of this cursor instance.
|
|
243
|
-
*/
|
|
244
|
-
get totalOccurrences() {
|
|
245
|
-
return this.occurrenceGroups.reduce((a, v) => {
|
|
246
|
-
// Down cursor.
|
|
247
|
-
++a;
|
|
248
|
-
// Move cursors.
|
|
249
|
-
a += v.moves.length;
|
|
250
|
-
if (v.up) {
|
|
251
|
-
// Up cursor.
|
|
252
|
-
++a;
|
|
253
|
-
}
|
|
254
|
-
return a;
|
|
255
|
-
}, 0);
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* All cursor occurrences of this cursor instnace.
|
|
259
|
-
*
|
|
260
|
-
* This iterates all occurrence groups and as such should be used sparingly or stored locally.
|
|
261
|
-
*/
|
|
262
|
-
get allOccurrences() {
|
|
263
|
-
return this.occurrenceGroups.flatMap((v) => v.allOccurrences);
|
|
264
|
-
}
|
|
265
|
-
constructor(values) {
|
|
266
|
-
let downOccurrence = null;
|
|
267
|
-
let moveOccurrences = [];
|
|
268
|
-
for (let i = 0; i < values.size; ++i) {
|
|
269
|
-
const occurrence = new CursorOccurrence(values.time[i], values.x[i], values.y[i], values.id[i]);
|
|
270
|
-
switch (occurrence.id) {
|
|
271
|
-
case exports.
|
|
272
|
-
downOccurrence = occurrence;
|
|
273
|
-
break;
|
|
274
|
-
case exports.
|
|
275
|
-
moveOccurrences.push(occurrence);
|
|
276
|
-
break;
|
|
277
|
-
case exports.
|
|
278
|
-
if (downOccurrence) {
|
|
279
|
-
this.occurrenceGroups.push(new CursorOccurrenceGroup(downOccurrence, moveOccurrences, occurrence));
|
|
280
|
-
downOccurrence = null;
|
|
281
|
-
}
|
|
282
|
-
moveOccurrences = [];
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
// Add the final cursor occurrence group as the loop may not catch it for special cases.
|
|
286
|
-
if (downOccurrence && moveOccurrences.length > 0) {
|
|
287
|
-
this.occurrenceGroups.push(new CursorOccurrenceGroup(downOccurrence, moveOccurrences));
|
|
288
|
-
}
|
|
289
|
-
}
|
|
216
|
+
/**
|
|
217
|
+
* Represents a cursor instance in an osu!droid replay.
|
|
218
|
+
*
|
|
219
|
+
* Stores cursor movement data in the form of `CursorOccurrenceGroup`s.
|
|
220
|
+
*
|
|
221
|
+
* This is used when analyzing replays using replay analyzer.
|
|
222
|
+
*/
|
|
223
|
+
class CursorData {
|
|
224
|
+
/**
|
|
225
|
+
* The occurrence groups of this cursor instance.
|
|
226
|
+
*/
|
|
227
|
+
occurrenceGroups = [];
|
|
228
|
+
/**
|
|
229
|
+
* The time at which the first occurrence of this cursor instance occurs.
|
|
230
|
+
*
|
|
231
|
+
* Will return `null` if there are no occurrences.
|
|
232
|
+
*/
|
|
233
|
+
get earliestOccurrenceTime() {
|
|
234
|
+
return this.occurrenceGroups.at(0)?.startTime ?? null;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The time at which the latest occurrence of this cursor instance occurs.
|
|
238
|
+
*
|
|
239
|
+
* Will return `null` if there are no occurrences.
|
|
240
|
+
*/
|
|
241
|
+
get latestOccurrenceTime() {
|
|
242
|
+
return this.occurrenceGroups.at(-1)?.endTime ?? null;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The amount of cursor occurrences of this cursor instance.
|
|
246
|
+
*/
|
|
247
|
+
get totalOccurrences() {
|
|
248
|
+
return this.occurrenceGroups.reduce((a, v) => {
|
|
249
|
+
// Down cursor.
|
|
250
|
+
++a;
|
|
251
|
+
// Move cursors.
|
|
252
|
+
a += v.moves.length;
|
|
253
|
+
if (v.up) {
|
|
254
|
+
// Up cursor.
|
|
255
|
+
++a;
|
|
256
|
+
}
|
|
257
|
+
return a;
|
|
258
|
+
}, 0);
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* All cursor occurrences of this cursor instnace.
|
|
262
|
+
*
|
|
263
|
+
* This iterates all occurrence groups and as such should be used sparingly or stored locally.
|
|
264
|
+
*/
|
|
265
|
+
get allOccurrences() {
|
|
266
|
+
return this.occurrenceGroups.flatMap((v) => v.allOccurrences);
|
|
267
|
+
}
|
|
268
|
+
constructor(values) {
|
|
269
|
+
let downOccurrence = null;
|
|
270
|
+
let moveOccurrences = [];
|
|
271
|
+
for (let i = 0; i < values.size; ++i) {
|
|
272
|
+
const occurrence = new CursorOccurrence(values.time[i], values.x[i], values.y[i], values.id[i]);
|
|
273
|
+
switch (occurrence.id) {
|
|
274
|
+
case exports.MovementType.down:
|
|
275
|
+
downOccurrence = occurrence;
|
|
276
|
+
break;
|
|
277
|
+
case exports.MovementType.move:
|
|
278
|
+
moveOccurrences.push(occurrence);
|
|
279
|
+
break;
|
|
280
|
+
case exports.MovementType.up:
|
|
281
|
+
if (downOccurrence) {
|
|
282
|
+
this.occurrenceGroups.push(new CursorOccurrenceGroup(downOccurrence, moveOccurrences, occurrence));
|
|
283
|
+
downOccurrence = null;
|
|
284
|
+
}
|
|
285
|
+
moveOccurrences = [];
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
// Add the final cursor occurrence group as the loop may not catch it for special cases.
|
|
289
|
+
if (downOccurrence && moveOccurrences.length > 0) {
|
|
290
|
+
this.occurrenceGroups.push(new CursorOccurrenceGroup(downOccurrence, moveOccurrences));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
290
293
|
}
|
|
291
294
|
|
|
292
|
-
/**
|
|
293
|
-
* The result of a hit in an osu!droid replay.
|
|
294
|
-
*/
|
|
295
|
-
exports.
|
|
296
|
-
(function (
|
|
297
|
-
/**
|
|
298
|
-
* Miss (0).
|
|
299
|
-
*/
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Meh (50).
|
|
303
|
-
*/
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
*
|
|
307
|
-
*/
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
*
|
|
311
|
-
*/
|
|
312
|
-
|
|
313
|
-
})(exports.
|
|
295
|
+
/**
|
|
296
|
+
* The result of a hit in an osu!droid replay.
|
|
297
|
+
*/
|
|
298
|
+
exports.HitResult = void 0;
|
|
299
|
+
(function (HitResult) {
|
|
300
|
+
/**
|
|
301
|
+
* Miss (0).
|
|
302
|
+
*/
|
|
303
|
+
HitResult[HitResult["miss"] = 1] = "miss";
|
|
304
|
+
/**
|
|
305
|
+
* Meh (50).
|
|
306
|
+
*/
|
|
307
|
+
HitResult[HitResult["meh"] = 2] = "meh";
|
|
308
|
+
/**
|
|
309
|
+
* Good (100).
|
|
310
|
+
*/
|
|
311
|
+
HitResult[HitResult["good"] = 3] = "good";
|
|
312
|
+
/**
|
|
313
|
+
* Great (300).
|
|
314
|
+
*/
|
|
315
|
+
HitResult[HitResult["great"] = 4] = "great";
|
|
316
|
+
})(exports.HitResult || (exports.HitResult = {}));
|
|
314
317
|
|
|
315
|
-
/**
|
|
316
|
-
* Represents a replay data in an osu!droid replay.
|
|
317
|
-
*
|
|
318
|
-
* Stores generic information about an osu!droid replay such as player name, MD5 hash, time set, etc.
|
|
319
|
-
*
|
|
320
|
-
* This is used when analyzing replays using replay analyzer.
|
|
321
|
-
*/
|
|
322
|
-
class ReplayData {
|
|
323
|
-
replayVersion;
|
|
324
|
-
folderName;
|
|
325
|
-
fileName;
|
|
326
|
-
hash;
|
|
327
|
-
time;
|
|
328
|
-
hit300k;
|
|
329
|
-
hit100k;
|
|
330
|
-
score;
|
|
331
|
-
maxCombo;
|
|
332
|
-
accuracy;
|
|
333
|
-
isFullCombo;
|
|
334
|
-
playerName;
|
|
335
|
-
rawMods;
|
|
336
|
-
rank;
|
|
337
|
-
convertedMods;
|
|
338
|
-
cursorMovement;
|
|
339
|
-
hitObjectData;
|
|
340
|
-
speedModification;
|
|
341
|
-
forcedAR;
|
|
342
|
-
constructor(values) {
|
|
343
|
-
this.replayVersion = values.replayVersion;
|
|
344
|
-
this.folderName = values.folderName;
|
|
345
|
-
this.fileName = values.fileName;
|
|
346
|
-
this.hash = values.hash;
|
|
347
|
-
this.time = new Date(values.time || 0);
|
|
348
|
-
this.hit300k = values.hit300k || 0;
|
|
349
|
-
this.hit100k = values.hit100k || 0;
|
|
350
|
-
this.score = values.score || 0;
|
|
351
|
-
this.maxCombo = values.maxCombo || 0;
|
|
352
|
-
this.accuracy = values.accuracy || new osuBase.Accuracy({});
|
|
353
|
-
this.isFullCombo = values.isFullCombo || false;
|
|
354
|
-
this.playerName = values.playerName || "";
|
|
355
|
-
this.rawMods = values.rawMods || "";
|
|
356
|
-
this.rank = values.rank || "";
|
|
357
|
-
this.convertedMods = values.convertedMods || [];
|
|
358
|
-
this.cursorMovement = values.cursorMovement;
|
|
359
|
-
this.hitObjectData = values.hitObjectData;
|
|
360
|
-
this.speedModification = values.speedModification || 1;
|
|
361
|
-
this.forcedAR = values.forcedAR;
|
|
362
|
-
}
|
|
318
|
+
/**
|
|
319
|
+
* Represents a replay data in an osu!droid replay.
|
|
320
|
+
*
|
|
321
|
+
* Stores generic information about an osu!droid replay such as player name, MD5 hash, time set, etc.
|
|
322
|
+
*
|
|
323
|
+
* This is used when analyzing replays using replay analyzer.
|
|
324
|
+
*/
|
|
325
|
+
class ReplayData {
|
|
326
|
+
replayVersion;
|
|
327
|
+
folderName;
|
|
328
|
+
fileName;
|
|
329
|
+
hash;
|
|
330
|
+
time;
|
|
331
|
+
hit300k;
|
|
332
|
+
hit100k;
|
|
333
|
+
score;
|
|
334
|
+
maxCombo;
|
|
335
|
+
accuracy;
|
|
336
|
+
isFullCombo;
|
|
337
|
+
playerName;
|
|
338
|
+
rawMods;
|
|
339
|
+
rank;
|
|
340
|
+
convertedMods;
|
|
341
|
+
cursorMovement;
|
|
342
|
+
hitObjectData;
|
|
343
|
+
speedModification;
|
|
344
|
+
forcedAR;
|
|
345
|
+
constructor(values) {
|
|
346
|
+
this.replayVersion = values.replayVersion;
|
|
347
|
+
this.folderName = values.folderName;
|
|
348
|
+
this.fileName = values.fileName;
|
|
349
|
+
this.hash = values.hash;
|
|
350
|
+
this.time = new Date(values.time || 0);
|
|
351
|
+
this.hit300k = values.hit300k || 0;
|
|
352
|
+
this.hit100k = values.hit100k || 0;
|
|
353
|
+
this.score = values.score || 0;
|
|
354
|
+
this.maxCombo = values.maxCombo || 0;
|
|
355
|
+
this.accuracy = values.accuracy || new osuBase.Accuracy({});
|
|
356
|
+
this.isFullCombo = values.isFullCombo || false;
|
|
357
|
+
this.playerName = values.playerName || "";
|
|
358
|
+
this.rawMods = values.rawMods || "";
|
|
359
|
+
this.rank = values.rank || "";
|
|
360
|
+
this.convertedMods = values.convertedMods || [];
|
|
361
|
+
this.cursorMovement = values.cursorMovement;
|
|
362
|
+
this.hitObjectData = values.hitObjectData;
|
|
363
|
+
this.speedModification = values.speedModification || 1;
|
|
364
|
+
this.forcedAR = values.forcedAR;
|
|
365
|
+
}
|
|
363
366
|
}
|
|
364
367
|
|
|
365
|
-
/**
|
|
366
|
-
* A beatmap section generator that generates beatmap section based on aim/speed strain.
|
|
367
|
-
*/
|
|
368
|
-
class BeatmapSectionGenerator {
|
|
369
|
-
/**
|
|
370
|
-
* Generates `BeatmapSection`s for the specified beatmap.
|
|
371
|
-
*
|
|
372
|
-
* @param calculator The difficulty calculator to generate for.
|
|
373
|
-
* @param minSectionObjectCount The maximum delta time allowed between two beatmap sections.
|
|
374
|
-
* Increasing this number decreases the amount of beatmap sections in general. Note that this value does not account for the speed multiplier of
|
|
375
|
-
* the play, similar to the way replay object data is stored.
|
|
376
|
-
* @param maxSectionDeltaTime The minimum object count required to make a beatmap section. Increasing this number decreases the amount of beatmap sections.
|
|
377
|
-
*/
|
|
378
|
-
static generateSections(calculator, minSectionObjectCount, maxSectionDeltaTime) {
|
|
379
|
-
const beatmapSections = [];
|
|
380
|
-
let firstObjectIndex = 0;
|
|
381
|
-
for (let i = 0; i < calculator.objects.length - 1; ++i) {
|
|
382
|
-
const current = calculator.objects[i];
|
|
383
|
-
const next = calculator.objects[i + 1];
|
|
384
|
-
const realDeltaTime = next.object.startTime - current.object.endTime;
|
|
385
|
-
if (realDeltaTime >= maxSectionDeltaTime) {
|
|
386
|
-
// Ignore sections that don't meet object count requirement.
|
|
387
|
-
if (i - firstObjectIndex < minSectionObjectCount) {
|
|
388
|
-
firstObjectIndex = i + 1;
|
|
389
|
-
continue;
|
|
390
|
-
}
|
|
391
|
-
beatmapSections.push({
|
|
392
|
-
firstObjectIndex,
|
|
393
|
-
lastObjectIndex: i,
|
|
394
|
-
});
|
|
395
|
-
firstObjectIndex = i + 1;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
// Don't forget to manually add the last beatmap section, which would otherwise be ignored.
|
|
399
|
-
if (calculator.objects.length - firstObjectIndex >
|
|
400
|
-
minSectionObjectCount) {
|
|
401
|
-
beatmapSections.push({
|
|
402
|
-
firstObjectIndex,
|
|
403
|
-
lastObjectIndex: calculator.objects.length - 1,
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
return beatmapSections;
|
|
407
|
-
}
|
|
368
|
+
/**
|
|
369
|
+
* A beatmap section generator that generates beatmap section based on aim/speed strain.
|
|
370
|
+
*/
|
|
371
|
+
class BeatmapSectionGenerator {
|
|
372
|
+
/**
|
|
373
|
+
* Generates `BeatmapSection`s for the specified beatmap.
|
|
374
|
+
*
|
|
375
|
+
* @param calculator The difficulty calculator to generate for.
|
|
376
|
+
* @param minSectionObjectCount The maximum delta time allowed between two beatmap sections.
|
|
377
|
+
* Increasing this number decreases the amount of beatmap sections in general. Note that this value does not account for the speed multiplier of
|
|
378
|
+
* the play, similar to the way replay object data is stored.
|
|
379
|
+
* @param maxSectionDeltaTime The minimum object count required to make a beatmap section. Increasing this number decreases the amount of beatmap sections.
|
|
380
|
+
*/
|
|
381
|
+
static generateSections(calculator, minSectionObjectCount, maxSectionDeltaTime) {
|
|
382
|
+
const beatmapSections = [];
|
|
383
|
+
let firstObjectIndex = 0;
|
|
384
|
+
for (let i = 0; i < calculator.objects.length - 1; ++i) {
|
|
385
|
+
const current = calculator.objects[i];
|
|
386
|
+
const next = calculator.objects[i + 1];
|
|
387
|
+
const realDeltaTime = next.object.startTime - current.object.endTime;
|
|
388
|
+
if (realDeltaTime >= maxSectionDeltaTime) {
|
|
389
|
+
// Ignore sections that don't meet object count requirement.
|
|
390
|
+
if (i - firstObjectIndex < minSectionObjectCount) {
|
|
391
|
+
firstObjectIndex = i + 1;
|
|
392
|
+
continue;
|
|
393
|
+
}
|
|
394
|
+
beatmapSections.push({
|
|
395
|
+
firstObjectIndex,
|
|
396
|
+
lastObjectIndex: i,
|
|
397
|
+
});
|
|
398
|
+
firstObjectIndex = i + 1;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
// Don't forget to manually add the last beatmap section, which would otherwise be ignored.
|
|
402
|
+
if (calculator.objects.length - firstObjectIndex >
|
|
403
|
+
minSectionObjectCount) {
|
|
404
|
+
beatmapSections.push({
|
|
405
|
+
firstObjectIndex,
|
|
406
|
+
lastObjectIndex: calculator.objects.length - 1,
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
return beatmapSections;
|
|
410
|
+
}
|
|
408
411
|
}
|
|
409
412
|
|
|
410
|
-
/**
|
|
411
|
-
* Represents a section of a beatmap.
|
|
412
|
-
*/
|
|
413
|
-
class BeatmapSection {
|
|
414
|
-
/**
|
|
415
|
-
* The index of the first `DifficultyHitObject` of this beatmap section.
|
|
416
|
-
*/
|
|
417
|
-
firstObjectIndex;
|
|
418
|
-
/**
|
|
419
|
-
* The index of the last `DifficultyHitObject` of this beatmap section.
|
|
420
|
-
*/
|
|
421
|
-
lastObjectIndex;
|
|
422
|
-
/**
|
|
423
|
-
* @param firstObjectIndex The index of the first `DifficultyHitObject` of this beatmap section.
|
|
424
|
-
* @param lastObjectIndex The index of the last `DifficultyHitObject` of this beatmap section.
|
|
425
|
-
*/
|
|
426
|
-
constructor(firstObjectIndex, lastObjectIndex) {
|
|
427
|
-
this.firstObjectIndex = firstObjectIndex;
|
|
428
|
-
this.lastObjectIndex = lastObjectIndex;
|
|
429
|
-
}
|
|
413
|
+
/**
|
|
414
|
+
* Represents a section of a beatmap.
|
|
415
|
+
*/
|
|
416
|
+
class BeatmapSection {
|
|
417
|
+
/**
|
|
418
|
+
* The index of the first `DifficultyHitObject` of this beatmap section.
|
|
419
|
+
*/
|
|
420
|
+
firstObjectIndex;
|
|
421
|
+
/**
|
|
422
|
+
* The index of the last `DifficultyHitObject` of this beatmap section.
|
|
423
|
+
*/
|
|
424
|
+
lastObjectIndex;
|
|
425
|
+
/**
|
|
426
|
+
* @param firstObjectIndex The index of the first `DifficultyHitObject` of this beatmap section.
|
|
427
|
+
* @param lastObjectIndex The index of the last `DifficultyHitObject` of this beatmap section.
|
|
428
|
+
*/
|
|
429
|
+
constructor(firstObjectIndex, lastObjectIndex) {
|
|
430
|
+
this.firstObjectIndex = firstObjectIndex;
|
|
431
|
+
this.lastObjectIndex = lastObjectIndex;
|
|
432
|
+
}
|
|
430
433
|
}
|
|
431
434
|
|
|
432
|
-
/**
|
|
433
|
-
* A section of a beatmap with extra information used for detecting three-finger usage.
|
|
434
|
-
*/
|
|
435
|
-
class ThreeFingerBeatmapSection extends BeatmapSection {
|
|
436
|
-
/**
|
|
437
|
-
* Whether or not this beatmap section is dragged.
|
|
438
|
-
*/
|
|
439
|
-
isDragged;
|
|
440
|
-
/**
|
|
441
|
-
* The index of the cursor that is dragging this section.
|
|
442
|
-
*/
|
|
443
|
-
dragFingerIndex;
|
|
444
|
-
constructor(values) {
|
|
445
|
-
super(values.firstObjectIndex, values.lastObjectIndex);
|
|
446
|
-
this.isDragged = values.isDragged;
|
|
447
|
-
this.dragFingerIndex = values.dragFingerIndex;
|
|
448
|
-
}
|
|
435
|
+
/**
|
|
436
|
+
* A section of a beatmap with extra information used for detecting three-finger usage.
|
|
437
|
+
*/
|
|
438
|
+
class ThreeFingerBeatmapSection extends BeatmapSection {
|
|
439
|
+
/**
|
|
440
|
+
* Whether or not this beatmap section is dragged.
|
|
441
|
+
*/
|
|
442
|
+
isDragged;
|
|
443
|
+
/**
|
|
444
|
+
* The index of the cursor that is dragging this section.
|
|
445
|
+
*/
|
|
446
|
+
dragFingerIndex;
|
|
447
|
+
constructor(values) {
|
|
448
|
+
super(values.firstObjectIndex, values.lastObjectIndex);
|
|
449
|
+
this.isDragged = values.isDragged;
|
|
450
|
+
this.dragFingerIndex = values.dragFingerIndex;
|
|
451
|
+
}
|
|
449
452
|
}
|
|
450
453
|
|
|
451
|
-
/**
|
|
452
|
-
* Utility to check whether or not a beatmap is three-fingered.
|
|
453
|
-
*/
|
|
454
|
-
class ThreeFingerChecker {
|
|
455
|
-
/**
|
|
456
|
-
* The difficulty calculator that is being analyzed.
|
|
457
|
-
*/
|
|
458
|
-
calculator;
|
|
459
|
-
/**
|
|
460
|
-
* The data of the replay.
|
|
461
|
-
*/
|
|
462
|
-
data;
|
|
463
|
-
/**
|
|
464
|
-
* The strain threshold to start detecting for 3-fingered section.
|
|
465
|
-
*
|
|
466
|
-
* Increasing this number will result in less sections being flagged.
|
|
467
|
-
*/
|
|
468
|
-
static strainThreshold = 175;
|
|
469
|
-
/**
|
|
470
|
-
* The distance threshold between cursors to assume that two cursors are
|
|
471
|
-
* actually pressed with 1 finger in osu!pixels.
|
|
472
|
-
*
|
|
473
|
-
* This is used to prevent cases where a player would lift their finger
|
|
474
|
-
* too fast to the point where the 4th cursor instance or beyond is recorded
|
|
475
|
-
* as 1st, 2nd, or 3rd cursor instance.
|
|
476
|
-
*/
|
|
477
|
-
cursorDistancingDistanceThreshold = 60;
|
|
478
|
-
/**
|
|
479
|
-
* The threshold for the amount of cursors that are assumed to be pressed
|
|
480
|
-
* by a single finger.
|
|
481
|
-
*/
|
|
482
|
-
cursorDistancingCountThreshold = 10;
|
|
483
|
-
/**
|
|
484
|
-
* The threshold for the time difference of cursors that are assumed to be pressed
|
|
485
|
-
* by a single finger, in milliseconds.
|
|
486
|
-
*/
|
|
487
|
-
cursorDistancingTimeThreshold = 1000;
|
|
488
|
-
/**
|
|
489
|
-
* The amount of notes that has a tap strain exceeding `strainThreshold`.
|
|
490
|
-
*/
|
|
491
|
-
strainNoteCount;
|
|
492
|
-
/**
|
|
493
|
-
* The ratio threshold between non-3 finger cursors and 3-finger cursors.
|
|
494
|
-
*
|
|
495
|
-
* Increasing this number will increase detection accuracy, however
|
|
496
|
-
* it also increases the chance of falsely flagged plays.
|
|
497
|
-
*/
|
|
498
|
-
threeFingerRatioThreshold = 0.01;
|
|
499
|
-
/**
|
|
500
|
-
* The maximum delta time allowed between two beatmap sections.
|
|
501
|
-
*
|
|
502
|
-
* Increasing this number decreases the amount of beatmap sections in general.
|
|
503
|
-
*
|
|
504
|
-
* Note that this value does not account for the speed multiplier of
|
|
505
|
-
* the play, similar to the way replay object data is stored.
|
|
506
|
-
*/
|
|
507
|
-
maxSectionDeltaTime = 2000;
|
|
508
|
-
/**
|
|
509
|
-
* The minimum object count required to make a beatmap section.
|
|
510
|
-
*
|
|
511
|
-
* Increasing this number decreases the amount of beatmap sections.
|
|
512
|
-
*/
|
|
513
|
-
minSectionObjectCount = 5;
|
|
514
|
-
/**
|
|
515
|
-
* The sections of the beatmap that was cut based on `maxSectionDeltaTime` and `minSectionObjectCount`.
|
|
516
|
-
*/
|
|
517
|
-
beatmapSections = [];
|
|
518
|
-
/**
|
|
519
|
-
* This threshold is used to filter out accidental taps.
|
|
520
|
-
*
|
|
521
|
-
* Increasing this number makes the filtration more sensitive, however it
|
|
522
|
-
* will also increase the chance of 3-fingered plays getting out from
|
|
523
|
-
* being flagged.
|
|
524
|
-
*/
|
|
525
|
-
accidentalTapThreshold = 400;
|
|
526
|
-
/**
|
|
527
|
-
* The hit window of this beatmap. Keep in mind that speed-changing mods do not change hit window length in game logic.
|
|
528
|
-
*/
|
|
529
|
-
hitWindow;
|
|
530
|
-
/**
|
|
531
|
-
* A reprocessed break points to match right on object time.
|
|
532
|
-
*
|
|
533
|
-
* This is used to increase detection accuracy since break points do not start right at the
|
|
534
|
-
* start of the hitobject before it and do not end right at the first hitobject after it.
|
|
535
|
-
*/
|
|
536
|
-
breakPointAccurateTimes = [];
|
|
537
|
-
/**
|
|
538
|
-
* A cursor occurrence nested array that only contains `movementType.DOWN` movement ID occurrences.
|
|
539
|
-
*
|
|
540
|
-
* Each index represents the cursor index.
|
|
541
|
-
*/
|
|
542
|
-
downCursorInstances = [];
|
|
543
|
-
/**
|
|
544
|
-
* All cursor occurrences in the replay.
|
|
545
|
-
*
|
|
546
|
-
* Each index represents the cursor index.
|
|
547
|
-
*/
|
|
548
|
-
allCursorInstances;
|
|
549
|
-
/**
|
|
550
|
-
* Nerf factors from all sections that were three-fingered.
|
|
551
|
-
*/
|
|
552
|
-
nerfFactors = [];
|
|
553
|
-
/**
|
|
554
|
-
* @param calculator The difficulty calculator to analyze.
|
|
555
|
-
* @param data The data of the replay.
|
|
556
|
-
*/
|
|
557
|
-
constructor(calculator, data) {
|
|
558
|
-
this.calculator = calculator;
|
|
559
|
-
this.data = data;
|
|
560
|
-
this.allCursorInstances = data.cursorMovement.map((v) => v.allOccurrences);
|
|
561
|
-
const stats = new osuBase.MapStats({
|
|
562
|
-
od: this.calculator.beatmap.difficulty.od,
|
|
563
|
-
mods: this.calculator.mods.filter((m) => m.isApplicableToDroid() &&
|
|
564
|
-
!osuBase.ModUtil.speedChangingMods.some((v) => v.acronym === m.acronym)
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
*
|
|
581
|
-
*
|
|
582
|
-
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
this.
|
|
599
|
-
this.
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
*
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
const
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
const
|
|
669
|
-
const
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
const
|
|
764
|
-
const
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
sectionReplayObjectData[i]
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
if (
|
|
919
|
-
objects[i].originalTapStrain
|
|
920
|
-
ThreeFingerChecker.strainThreshold) {
|
|
921
|
-
inSpeedSection =
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
.reduce((acc, value) => acc +
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
//
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
fingerFactor,
|
|
1112
|
-
|
|
1113
|
-
});
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
/**
|
|
1118
|
-
* Calculates the final penalty.
|
|
1119
|
-
*/
|
|
1120
|
-
calculateFinalPenalty() {
|
|
1121
|
-
return (1 +
|
|
1122
|
-
this.nerfFactors.reduce((a, n) => a +
|
|
1123
|
-
0.015 *
|
|
1124
|
-
Math.pow(n.strainFactor * n.fingerFactor * n.lengthFactor, 1.05), 0));
|
|
1125
|
-
}
|
|
454
|
+
/**
|
|
455
|
+
* Utility to check whether or not a beatmap is three-fingered.
|
|
456
|
+
*/
|
|
457
|
+
class ThreeFingerChecker {
|
|
458
|
+
/**
|
|
459
|
+
* The difficulty calculator that is being analyzed.
|
|
460
|
+
*/
|
|
461
|
+
calculator;
|
|
462
|
+
/**
|
|
463
|
+
* The data of the replay.
|
|
464
|
+
*/
|
|
465
|
+
data;
|
|
466
|
+
/**
|
|
467
|
+
* The strain threshold to start detecting for 3-fingered section.
|
|
468
|
+
*
|
|
469
|
+
* Increasing this number will result in less sections being flagged.
|
|
470
|
+
*/
|
|
471
|
+
static strainThreshold = 175;
|
|
472
|
+
/**
|
|
473
|
+
* The distance threshold between cursors to assume that two cursors are
|
|
474
|
+
* actually pressed with 1 finger in osu!pixels.
|
|
475
|
+
*
|
|
476
|
+
* This is used to prevent cases where a player would lift their finger
|
|
477
|
+
* too fast to the point where the 4th cursor instance or beyond is recorded
|
|
478
|
+
* as 1st, 2nd, or 3rd cursor instance.
|
|
479
|
+
*/
|
|
480
|
+
cursorDistancingDistanceThreshold = 60;
|
|
481
|
+
/**
|
|
482
|
+
* The threshold for the amount of cursors that are assumed to be pressed
|
|
483
|
+
* by a single finger.
|
|
484
|
+
*/
|
|
485
|
+
cursorDistancingCountThreshold = 10;
|
|
486
|
+
/**
|
|
487
|
+
* The threshold for the time difference of cursors that are assumed to be pressed
|
|
488
|
+
* by a single finger, in milliseconds.
|
|
489
|
+
*/
|
|
490
|
+
cursorDistancingTimeThreshold = 1000;
|
|
491
|
+
/**
|
|
492
|
+
* The amount of notes that has a tap strain exceeding `strainThreshold`.
|
|
493
|
+
*/
|
|
494
|
+
strainNoteCount;
|
|
495
|
+
/**
|
|
496
|
+
* The ratio threshold between non-3 finger cursors and 3-finger cursors.
|
|
497
|
+
*
|
|
498
|
+
* Increasing this number will increase detection accuracy, however
|
|
499
|
+
* it also increases the chance of falsely flagged plays.
|
|
500
|
+
*/
|
|
501
|
+
threeFingerRatioThreshold = 0.01;
|
|
502
|
+
/**
|
|
503
|
+
* The maximum delta time allowed between two beatmap sections.
|
|
504
|
+
*
|
|
505
|
+
* Increasing this number decreases the amount of beatmap sections in general.
|
|
506
|
+
*
|
|
507
|
+
* Note that this value does not account for the speed multiplier of
|
|
508
|
+
* the play, similar to the way replay object data is stored.
|
|
509
|
+
*/
|
|
510
|
+
maxSectionDeltaTime = 2000;
|
|
511
|
+
/**
|
|
512
|
+
* The minimum object count required to make a beatmap section.
|
|
513
|
+
*
|
|
514
|
+
* Increasing this number decreases the amount of beatmap sections.
|
|
515
|
+
*/
|
|
516
|
+
minSectionObjectCount = 5;
|
|
517
|
+
/**
|
|
518
|
+
* The sections of the beatmap that was cut based on `maxSectionDeltaTime` and `minSectionObjectCount`.
|
|
519
|
+
*/
|
|
520
|
+
beatmapSections = [];
|
|
521
|
+
/**
|
|
522
|
+
* This threshold is used to filter out accidental taps.
|
|
523
|
+
*
|
|
524
|
+
* Increasing this number makes the filtration more sensitive, however it
|
|
525
|
+
* will also increase the chance of 3-fingered plays getting out from
|
|
526
|
+
* being flagged.
|
|
527
|
+
*/
|
|
528
|
+
accidentalTapThreshold = 400;
|
|
529
|
+
/**
|
|
530
|
+
* The hit window of this beatmap. Keep in mind that speed-changing mods do not change hit window length in game logic.
|
|
531
|
+
*/
|
|
532
|
+
hitWindow;
|
|
533
|
+
/**
|
|
534
|
+
* A reprocessed break points to match right on object time.
|
|
535
|
+
*
|
|
536
|
+
* This is used to increase detection accuracy since break points do not start right at the
|
|
537
|
+
* start of the hitobject before it and do not end right at the first hitobject after it.
|
|
538
|
+
*/
|
|
539
|
+
breakPointAccurateTimes = [];
|
|
540
|
+
/**
|
|
541
|
+
* A cursor occurrence nested array that only contains `movementType.DOWN` movement ID occurrences.
|
|
542
|
+
*
|
|
543
|
+
* Each index represents the cursor index.
|
|
544
|
+
*/
|
|
545
|
+
downCursorInstances = [];
|
|
546
|
+
/**
|
|
547
|
+
* All cursor occurrences in the replay.
|
|
548
|
+
*
|
|
549
|
+
* Each index represents the cursor index.
|
|
550
|
+
*/
|
|
551
|
+
allCursorInstances;
|
|
552
|
+
/**
|
|
553
|
+
* Nerf factors from all sections that were three-fingered.
|
|
554
|
+
*/
|
|
555
|
+
nerfFactors = [];
|
|
556
|
+
/**
|
|
557
|
+
* @param calculator The difficulty calculator to analyze.
|
|
558
|
+
* @param data The data of the replay.
|
|
559
|
+
*/
|
|
560
|
+
constructor(calculator, data) {
|
|
561
|
+
this.calculator = calculator;
|
|
562
|
+
this.data = data;
|
|
563
|
+
this.allCursorInstances = data.cursorMovement.map((v) => v.allOccurrences);
|
|
564
|
+
const stats = new osuBase.MapStats({
|
|
565
|
+
od: this.calculator.beatmap.difficulty.od,
|
|
566
|
+
mods: this.calculator.mods.filter((m) => m.isApplicableToDroid() &&
|
|
567
|
+
!osuBase.ModUtil.speedChangingMods.some((v) => v.acronym === m.acronym)),
|
|
568
|
+
}).calculate();
|
|
569
|
+
this.hitWindow = new osuBase.DroidHitWindow(stats.od);
|
|
570
|
+
const strainNotes = (calculator.objects).filter((v) => v.originalTapStrain >= ThreeFingerChecker.strainThreshold);
|
|
571
|
+
this.strainNoteCount = strainNotes.length;
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Checks whether a beatmap is eligible to be detected for 3-finger.
|
|
575
|
+
*/
|
|
576
|
+
static isEligibleToDetect(map) {
|
|
577
|
+
return map.objects.some((v) => v.originalTapStrain >= this.strainThreshold);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Checks if the given beatmap is 3-fingered and also returns the final penalty.
|
|
581
|
+
*
|
|
582
|
+
* The beatmap will be separated into sections and each section will be determined
|
|
583
|
+
* whether or not it is dragged.
|
|
584
|
+
*
|
|
585
|
+
* After that, each section will be assigned a nerf factor based on whether or not
|
|
586
|
+
* the section is 3-fingered. These nerf factors will be summed up into a final
|
|
587
|
+
* nerf factor, taking beatmap difficulty into account.
|
|
588
|
+
*/
|
|
589
|
+
check() {
|
|
590
|
+
if (this.strainNoteCount === 0) {
|
|
591
|
+
return { is3Finger: false, penalty: 1 };
|
|
592
|
+
}
|
|
593
|
+
this.getAccurateBreakPoints();
|
|
594
|
+
this.filterCursorInstances();
|
|
595
|
+
if (this.downCursorInstances.filter((v) => v.length > 0).length <= 3) {
|
|
596
|
+
return { is3Finger: false, penalty: 1 };
|
|
597
|
+
}
|
|
598
|
+
this.getBeatmapSections();
|
|
599
|
+
this.detectDragPlay();
|
|
600
|
+
this.getDetailedBeatmapSections();
|
|
601
|
+
this.preventAccidentalTaps();
|
|
602
|
+
if (this.downCursorInstances.filter((v) => v.length > 0).length <= 3) {
|
|
603
|
+
return { is3Finger: false, penalty: 1 };
|
|
604
|
+
}
|
|
605
|
+
this.calculateNerfFactors();
|
|
606
|
+
const finalPenalty = this.calculateFinalPenalty();
|
|
607
|
+
return { is3Finger: finalPenalty > 1, penalty: finalPenalty };
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Generates a new set of "accurate break points".
|
|
611
|
+
*
|
|
612
|
+
* This is done to increase detection accuracy since break points do not start right at the
|
|
613
|
+
* start of the hitobject before it and do not end right at the first hitobject after it.
|
|
614
|
+
*/
|
|
615
|
+
getAccurateBreakPoints() {
|
|
616
|
+
const objects = this.calculator.objects;
|
|
617
|
+
const objectData = this.data.hitObjectData;
|
|
618
|
+
const isPrecise = this.calculator.mods.some((m) => m instanceof osuBase.ModPrecise);
|
|
619
|
+
for (const breakPoint of this.calculator.beatmap.events.breaks) {
|
|
620
|
+
const beforeIndex = osuBase.MathUtils.clamp(objects.findIndex((o) => o.object.endTime >= breakPoint.startTime) - 1, 0, objects.length - 2);
|
|
621
|
+
let timeBefore = objects[beforeIndex].object.endTime;
|
|
622
|
+
// For sliders and spinners, automatically set hit window length to be as lenient as possible.
|
|
623
|
+
let beforeIndexHitWindowLength = this.hitWindow.hitWindowFor50(isPrecise);
|
|
624
|
+
switch (objectData[beforeIndex].result) {
|
|
625
|
+
case exports.HitResult.great:
|
|
626
|
+
beforeIndexHitWindowLength =
|
|
627
|
+
this.hitWindow.hitWindowFor300(isPrecise);
|
|
628
|
+
break;
|
|
629
|
+
case exports.HitResult.good:
|
|
630
|
+
beforeIndexHitWindowLength =
|
|
631
|
+
this.hitWindow.hitWindowFor100(isPrecise);
|
|
632
|
+
break;
|
|
633
|
+
default:
|
|
634
|
+
beforeIndexHitWindowLength =
|
|
635
|
+
this.hitWindow.hitWindowFor50(isPrecise);
|
|
636
|
+
}
|
|
637
|
+
timeBefore += beforeIndexHitWindowLength;
|
|
638
|
+
const afterIndex = beforeIndex + 1;
|
|
639
|
+
let timeAfter = objects[afterIndex].object.startTime;
|
|
640
|
+
// For sliders and spinners, automatically set hit window length to be as lenient as possible.
|
|
641
|
+
let afterIndexHitWindowLength = this.hitWindow.hitWindowFor50(isPrecise);
|
|
642
|
+
switch (objectData[afterIndex].result) {
|
|
643
|
+
case exports.HitResult.great:
|
|
644
|
+
afterIndexHitWindowLength =
|
|
645
|
+
this.hitWindow.hitWindowFor300(isPrecise);
|
|
646
|
+
break;
|
|
647
|
+
case exports.HitResult.good:
|
|
648
|
+
afterIndexHitWindowLength =
|
|
649
|
+
this.hitWindow.hitWindowFor100(isPrecise);
|
|
650
|
+
break;
|
|
651
|
+
default:
|
|
652
|
+
afterIndexHitWindowLength =
|
|
653
|
+
this.hitWindow.hitWindowFor50(isPrecise);
|
|
654
|
+
}
|
|
655
|
+
timeAfter += afterIndexHitWindowLength;
|
|
656
|
+
this.breakPointAccurateTimes.push({
|
|
657
|
+
startTime: timeBefore,
|
|
658
|
+
endTime: timeAfter,
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
/**
|
|
663
|
+
* Filters the original cursor instances, returning only those with `movementType.DOWN` movement ID.
|
|
664
|
+
*
|
|
665
|
+
* This also filters cursors that are in break period or happen before start/after end of the beatmap.
|
|
666
|
+
*/
|
|
667
|
+
filterCursorInstances() {
|
|
668
|
+
const objects = this.calculator.objects;
|
|
669
|
+
const objectData = this.data.hitObjectData;
|
|
670
|
+
const firstObjectResult = objectData[0].result;
|
|
671
|
+
const lastObjectResult = objectData.at(-1).result;
|
|
672
|
+
const isPrecise = this.calculator.mods.some((m) => m instanceof osuBase.ModPrecise);
|
|
673
|
+
// For sliders, automatically set hit window length to be as lenient as possible.
|
|
674
|
+
let firstObjectHitWindow = this.hitWindow.hitWindowFor50(isPrecise);
|
|
675
|
+
if (objects[0].object instanceof osuBase.Circle) {
|
|
676
|
+
switch (firstObjectResult) {
|
|
677
|
+
case exports.HitResult.great:
|
|
678
|
+
firstObjectHitWindow =
|
|
679
|
+
this.hitWindow.hitWindowFor300(isPrecise);
|
|
680
|
+
break;
|
|
681
|
+
case exports.HitResult.good:
|
|
682
|
+
firstObjectHitWindow =
|
|
683
|
+
this.hitWindow.hitWindowFor100(isPrecise);
|
|
684
|
+
break;
|
|
685
|
+
default:
|
|
686
|
+
firstObjectHitWindow =
|
|
687
|
+
this.hitWindow.hitWindowFor50(isPrecise);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
// For sliders, automatically set hit window length to be as lenient as possible.
|
|
691
|
+
let lastObjectHitWindow = this.hitWindow.hitWindowFor50(isPrecise);
|
|
692
|
+
if (objects.at(-1).object instanceof osuBase.Circle) {
|
|
693
|
+
switch (lastObjectResult) {
|
|
694
|
+
case exports.HitResult.great:
|
|
695
|
+
lastObjectHitWindow =
|
|
696
|
+
this.hitWindow.hitWindowFor300(isPrecise);
|
|
697
|
+
break;
|
|
698
|
+
case exports.HitResult.good:
|
|
699
|
+
lastObjectHitWindow =
|
|
700
|
+
this.hitWindow.hitWindowFor100(isPrecise);
|
|
701
|
+
break;
|
|
702
|
+
default:
|
|
703
|
+
lastObjectHitWindow =
|
|
704
|
+
this.hitWindow.hitWindowFor50(isPrecise);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
// These hit time uses hit window length as threshold.
|
|
708
|
+
// This is because cursors aren't recorded exactly at hit time,
|
|
709
|
+
// probably due to the game's behavior.
|
|
710
|
+
const firstObjectHitTime = objects[0].object.startTime - firstObjectHitWindow;
|
|
711
|
+
const lastObjectHitTime = objects.at(-1).object.startTime + lastObjectHitWindow;
|
|
712
|
+
for (let i = 0; i < this.data.cursorMovement.length; ++i) {
|
|
713
|
+
const cursorInstance = this.data.cursorMovement[i];
|
|
714
|
+
const validOccurrences = [];
|
|
715
|
+
for (let j = 0; j < cursorInstance.occurrenceGroups.length; ++j) {
|
|
716
|
+
const group = cursorInstance.occurrenceGroups[j];
|
|
717
|
+
if (group.startTime < firstObjectHitTime ||
|
|
718
|
+
group.endTime > lastObjectHitTime) {
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
721
|
+
if (this.breakPointAccurateTimes.some((v) => group.startTime >= v.startTime &&
|
|
722
|
+
group.endTime <= v.endTime)) {
|
|
723
|
+
continue;
|
|
724
|
+
}
|
|
725
|
+
validOccurrences.push(group.down);
|
|
726
|
+
}
|
|
727
|
+
this.downCursorInstances.push(validOccurrences);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* Divides the beatmap into sections, which will be used to
|
|
732
|
+
* detect dragged sections and improve detection speed.
|
|
733
|
+
*/
|
|
734
|
+
getBeatmapSections() {
|
|
735
|
+
const beatmapSections = BeatmapSectionGenerator.generateSections(this.calculator, this.minSectionObjectCount, this.maxSectionDeltaTime);
|
|
736
|
+
for (const beatmapSection of beatmapSections) {
|
|
737
|
+
this.beatmapSections.push(new ThreeFingerBeatmapSection({
|
|
738
|
+
firstObjectIndex: beatmapSection.firstObjectIndex,
|
|
739
|
+
lastObjectIndex: beatmapSection.lastObjectIndex,
|
|
740
|
+
isDragged: false,
|
|
741
|
+
dragFingerIndex: -1,
|
|
742
|
+
}));
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
/**
|
|
746
|
+
* Checks whether or not each beatmap sections is dragged.
|
|
747
|
+
*/
|
|
748
|
+
detectDragPlay() {
|
|
749
|
+
for (let i = 0; i < this.beatmapSections.length; ++i) {
|
|
750
|
+
const dragIndex = this.checkDrag(this.beatmapSections[i]);
|
|
751
|
+
this.beatmapSections[i].dragFingerIndex = dragIndex;
|
|
752
|
+
this.beatmapSections[i].isDragged = dragIndex !== -1;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* Checks if a section is dragged and returns the index of the drag finger.
|
|
757
|
+
*
|
|
758
|
+
* If the section is not dragged, -1 will be returned.
|
|
759
|
+
*
|
|
760
|
+
* @param section The section to check.
|
|
761
|
+
*/
|
|
762
|
+
checkDrag(section) {
|
|
763
|
+
const objects = this.calculator.objects;
|
|
764
|
+
const objectData = this.data.hitObjectData;
|
|
765
|
+
const isPrecise = this.calculator.mods.some((m) => m instanceof osuBase.ModPrecise);
|
|
766
|
+
const firstObject = objects[section.firstObjectIndex];
|
|
767
|
+
const lastObject = objects[section.lastObjectIndex];
|
|
768
|
+
let firstObjectMinHitTime = firstObject.object.startTime;
|
|
769
|
+
if (firstObject.object instanceof osuBase.Circle) {
|
|
770
|
+
switch (objectData[section.firstObjectIndex].result) {
|
|
771
|
+
case exports.HitResult.great:
|
|
772
|
+
firstObjectMinHitTime -=
|
|
773
|
+
this.hitWindow.hitWindowFor300(isPrecise);
|
|
774
|
+
break;
|
|
775
|
+
case exports.HitResult.good:
|
|
776
|
+
firstObjectMinHitTime -=
|
|
777
|
+
this.hitWindow.hitWindowFor100(isPrecise);
|
|
778
|
+
break;
|
|
779
|
+
default:
|
|
780
|
+
firstObjectMinHitTime -=
|
|
781
|
+
this.hitWindow.hitWindowFor50(isPrecise);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
else {
|
|
785
|
+
firstObjectMinHitTime -= this.hitWindow.hitWindowFor50(isPrecise);
|
|
786
|
+
}
|
|
787
|
+
let lastObjectMaxHitTime = lastObject.object.startTime;
|
|
788
|
+
if (lastObject.object instanceof osuBase.Circle) {
|
|
789
|
+
switch (objectData[section.lastObjectIndex].result) {
|
|
790
|
+
case exports.HitResult.great:
|
|
791
|
+
lastObjectMaxHitTime +=
|
|
792
|
+
this.hitWindow.hitWindowFor300(isPrecise);
|
|
793
|
+
break;
|
|
794
|
+
case exports.HitResult.good:
|
|
795
|
+
lastObjectMaxHitTime +=
|
|
796
|
+
this.hitWindow.hitWindowFor100(isPrecise);
|
|
797
|
+
break;
|
|
798
|
+
default:
|
|
799
|
+
lastObjectMaxHitTime +=
|
|
800
|
+
this.hitWindow.hitWindowFor50(isPrecise);
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
else {
|
|
804
|
+
lastObjectMaxHitTime += this.hitWindow.hitWindowFor50(isPrecise);
|
|
805
|
+
}
|
|
806
|
+
// Since there may be more than 1 cursor instance index,
|
|
807
|
+
// we check which cursor instance follows hitobjects all over.
|
|
808
|
+
const cursorIndexes = [];
|
|
809
|
+
for (let i = 0; i < this.data.cursorMovement.length; ++i) {
|
|
810
|
+
const c = this.data.cursorMovement[i];
|
|
811
|
+
if (c.occurrenceGroups.length === 0) {
|
|
812
|
+
continue;
|
|
813
|
+
}
|
|
814
|
+
// Do not include cursors that don't have an occurence in this section
|
|
815
|
+
// this speeds up checking process.
|
|
816
|
+
if (c.occurrenceGroups.filter((v) => v.startTime >= firstObjectMinHitTime &&
|
|
817
|
+
v.endTime <= lastObjectMaxHitTime).length === 0) {
|
|
818
|
+
continue;
|
|
819
|
+
}
|
|
820
|
+
// If this cursor instance doesn't move, it's not the cursor instance we want.
|
|
821
|
+
if (c.occurrenceGroups.filter((v) => v.moves.length > 0).length ===
|
|
822
|
+
0) {
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
cursorIndexes.push(i);
|
|
826
|
+
}
|
|
827
|
+
return this.findDragIndex(objects.slice(section.firstObjectIndex, section.lastObjectIndex + 1), objectData.slice(section.firstObjectIndex, section.lastObjectIndex + 1), cursorIndexes);
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Finds the drag index of the section.
|
|
831
|
+
*
|
|
832
|
+
* @param sectionObjects The objects in the section.
|
|
833
|
+
* @param sectionReplayObjectData The hitobject data of all objects in the section.
|
|
834
|
+
* @param cursorIndexes The indexes of the cursor instance that has at least an occurrence in the section.
|
|
835
|
+
*/
|
|
836
|
+
findDragIndex(sectionObjects, sectionReplayObjectData, cursorIndexes) {
|
|
837
|
+
const isPrecise = this.calculator.mods.some((m) => m instanceof osuBase.ModPrecise);
|
|
838
|
+
const hitWindow50 = this.hitWindow.hitWindowFor50(isPrecise);
|
|
839
|
+
for (let i = 0; i < sectionObjects.length && cursorIndexes.every((v) => v !== -1); ++i) {
|
|
840
|
+
const object = sectionObjects[i];
|
|
841
|
+
const objectData = sectionReplayObjectData[i];
|
|
842
|
+
if (object.object instanceof osuBase.Spinner ||
|
|
843
|
+
objectData.result === exports.HitResult.miss) {
|
|
844
|
+
continue;
|
|
845
|
+
}
|
|
846
|
+
// Exclude sliderbreaks.
|
|
847
|
+
if (object.object instanceof osuBase.Slider &&
|
|
848
|
+
objectData.accuracy === Math.floor(hitWindow50) + 13) {
|
|
849
|
+
continue;
|
|
850
|
+
}
|
|
851
|
+
const objectPosition = object.object.getStackedPosition(osuBase.Modes.droid);
|
|
852
|
+
const hitTime = object.object.startTime + objectData.accuracy;
|
|
853
|
+
// Observe the cursor position at the object's hit time.
|
|
854
|
+
for (let j = 0; j < cursorIndexes.length; ++j) {
|
|
855
|
+
if (cursorIndexes[j] === -1) {
|
|
856
|
+
continue;
|
|
857
|
+
}
|
|
858
|
+
const cursorData = this.data.cursorMovement[cursorIndexes[j]];
|
|
859
|
+
const cursorGroup = cursorData.occurrenceGroups.find((v) => v.isActiveAt(hitTime));
|
|
860
|
+
if (!cursorGroup) {
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
const cursors = cursorGroup.allOccurrences;
|
|
864
|
+
for (let k = 1; k < cursors.length; ++k) {
|
|
865
|
+
const cursor = cursors[k];
|
|
866
|
+
const prevCursor = cursors[k - 1];
|
|
867
|
+
if (prevCursor.time <
|
|
868
|
+
object.object.startTime - hitWindow50) {
|
|
869
|
+
continue;
|
|
870
|
+
}
|
|
871
|
+
if (prevCursor.time >
|
|
872
|
+
object.object.startTime + hitWindow50) {
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
let isInObject = false;
|
|
876
|
+
switch (cursor.id) {
|
|
877
|
+
case exports.MovementType.up:
|
|
878
|
+
isInObject =
|
|
879
|
+
prevCursor.position.getDistance(objectPosition) <= object.object.getRadius(osuBase.Modes.droid);
|
|
880
|
+
break;
|
|
881
|
+
case exports.MovementType.move:
|
|
882
|
+
// Interpolate movement.
|
|
883
|
+
for (let mSecPassed = prevCursor.time; !isInObject &&
|
|
884
|
+
mSecPassed <=
|
|
885
|
+
Math.min(cursor.time, object.object.startTime + hitWindow50); ++mSecPassed) {
|
|
886
|
+
const t = (mSecPassed - prevCursor.time) /
|
|
887
|
+
(cursor.time - prevCursor.time);
|
|
888
|
+
const cursorPosition = new osuBase.Vector2(osuBase.Interpolation.lerp(prevCursor.position.x, cursor.position.x, t), osuBase.Interpolation.lerp(prevCursor.position.y, cursor.position.y, t));
|
|
889
|
+
isInObject =
|
|
890
|
+
objectPosition.getDistance(cursorPosition) <= object.object.getRadius(osuBase.Modes.droid);
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
if (!isInObject) {
|
|
894
|
+
cursorIndexes[j] = -1;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
return cursorIndexes.find((v) => v !== -1) ?? -1;
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* Redivides the beatmap into sections.
|
|
903
|
+
*
|
|
904
|
+
* The result will be used to detect for three-fingered
|
|
905
|
+
* sections.
|
|
906
|
+
*/
|
|
907
|
+
getDetailedBeatmapSections() {
|
|
908
|
+
const objects = this.calculator.objects;
|
|
909
|
+
const newBeatmapSections = [];
|
|
910
|
+
for (const beatmapSection of this.beatmapSections) {
|
|
911
|
+
let inSpeedSection = false;
|
|
912
|
+
let newFirstObjectIndex = beatmapSection.firstObjectIndex;
|
|
913
|
+
for (let i = beatmapSection.firstObjectIndex; i <= beatmapSection.lastObjectIndex; ++i) {
|
|
914
|
+
if (!inSpeedSection &&
|
|
915
|
+
objects[i].originalTapStrain >=
|
|
916
|
+
ThreeFingerChecker.strainThreshold) {
|
|
917
|
+
inSpeedSection = true;
|
|
918
|
+
newFirstObjectIndex = i;
|
|
919
|
+
continue;
|
|
920
|
+
}
|
|
921
|
+
if (inSpeedSection &&
|
|
922
|
+
objects[i].originalTapStrain <
|
|
923
|
+
ThreeFingerChecker.strainThreshold) {
|
|
924
|
+
inSpeedSection = false;
|
|
925
|
+
newBeatmapSections.push({
|
|
926
|
+
firstObjectIndex: newFirstObjectIndex,
|
|
927
|
+
lastObjectIndex: i,
|
|
928
|
+
isDragged: beatmapSection.isDragged,
|
|
929
|
+
dragFingerIndex: beatmapSection.dragFingerIndex,
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
// Don't forget to manually add the last beatmap section, which would otherwise be ignored.
|
|
934
|
+
if (inSpeedSection) {
|
|
935
|
+
newBeatmapSections.push({
|
|
936
|
+
firstObjectIndex: newFirstObjectIndex,
|
|
937
|
+
lastObjectIndex: beatmapSection.lastObjectIndex,
|
|
938
|
+
isDragged: beatmapSection.isDragged,
|
|
939
|
+
dragFingerIndex: beatmapSection.dragFingerIndex,
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
this.beatmapSections.length = 0;
|
|
944
|
+
this.beatmapSections.push(...newBeatmapSections);
|
|
945
|
+
}
|
|
946
|
+
/**
|
|
947
|
+
* Attempts to prevent accidental taps from being flagged.
|
|
948
|
+
*
|
|
949
|
+
* This detection will filter cursors that don't hit
|
|
950
|
+
* any object in beatmap sections, thus eliminating any
|
|
951
|
+
* unnecessary taps.
|
|
952
|
+
*/
|
|
953
|
+
preventAccidentalTaps() {
|
|
954
|
+
let filledCursorAmount = this.downCursorInstances.filter((v) => v.length > 0).length;
|
|
955
|
+
if (filledCursorAmount <= 3) {
|
|
956
|
+
return;
|
|
957
|
+
}
|
|
958
|
+
const objects = this.calculator.objects;
|
|
959
|
+
const totalCursorAmount = this.downCursorInstances.reduce((acc, value) => acc + value.length, 0);
|
|
960
|
+
for (let i = 0; i < this.downCursorInstances.length; ++i) {
|
|
961
|
+
if (filledCursorAmount <= 3) {
|
|
962
|
+
break;
|
|
963
|
+
}
|
|
964
|
+
const cursorInstances = this.downCursorInstances[i];
|
|
965
|
+
// Use an estimation for accidental tap threshold.
|
|
966
|
+
if (cursorInstances.length <=
|
|
967
|
+
Math.ceil(objects.length / this.accidentalTapThreshold) &&
|
|
968
|
+
cursorInstances.length / totalCursorAmount <
|
|
969
|
+
this.threeFingerRatioThreshold * 2) {
|
|
970
|
+
--filledCursorAmount;
|
|
971
|
+
cursorInstances.length = 0;
|
|
972
|
+
}
|
|
973
|
+
this.downCursorInstances[i] = cursorInstances;
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Creates nerf factors by scanning through objects.
|
|
978
|
+
*
|
|
979
|
+
* This check will ignore all objects with speed strain below `strainThreshold`.
|
|
980
|
+
*/
|
|
981
|
+
calculateNerfFactors() {
|
|
982
|
+
const objects = this.calculator.objects;
|
|
983
|
+
const objectData = this.data.hitObjectData;
|
|
984
|
+
const isPrecise = this.data.convertedMods.some((m) => m instanceof osuBase.ModPrecise);
|
|
985
|
+
// We only filter cursor instances that are above the strain threshold.
|
|
986
|
+
// This minimalizes the amount of cursor instances to analyze.
|
|
987
|
+
for (const beatmapSection of this.beatmapSections) {
|
|
988
|
+
const dragIndex = beatmapSection.dragFingerIndex;
|
|
989
|
+
const startTime = objects[beatmapSection.firstObjectIndex].object.startTime +
|
|
990
|
+
(objectData[beatmapSection.firstObjectIndex].result !==
|
|
991
|
+
exports.HitResult.miss
|
|
992
|
+
? objectData[beatmapSection.firstObjectIndex].accuracy
|
|
993
|
+
: -this.hitWindow.hitWindowFor50(isPrecise));
|
|
994
|
+
const endTime = objects[beatmapSection.lastObjectIndex].object.endTime +
|
|
995
|
+
(objectData[beatmapSection.lastObjectIndex].result !==
|
|
996
|
+
exports.HitResult.miss
|
|
997
|
+
? objectData[beatmapSection.lastObjectIndex].accuracy
|
|
998
|
+
: this.hitWindow.hitWindowFor50(isPrecise));
|
|
999
|
+
const cursorAmounts = [];
|
|
1000
|
+
const cursorVectorTimes = [];
|
|
1001
|
+
for (let i = 0; i < this.downCursorInstances.length; ++i) {
|
|
1002
|
+
// Do not include drag cursor instance.
|
|
1003
|
+
if (i === dragIndex) {
|
|
1004
|
+
continue;
|
|
1005
|
+
}
|
|
1006
|
+
const cursors = this.downCursorInstances[i];
|
|
1007
|
+
let amount = 0;
|
|
1008
|
+
for (let j = 0; j < cursors.length; ++j) {
|
|
1009
|
+
if (cursors[j].time >= startTime &&
|
|
1010
|
+
cursors[j].time <= endTime) {
|
|
1011
|
+
++amount;
|
|
1012
|
+
cursorVectorTimes.push({
|
|
1013
|
+
vector: new osuBase.Vector2(cursors[j].position.x, cursors[j].position.y),
|
|
1014
|
+
time: cursors[j].time,
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
cursorAmounts.push(amount);
|
|
1019
|
+
}
|
|
1020
|
+
// This index will be used to detect if a section is 3-fingered.
|
|
1021
|
+
// If the section is dragged, the dragged instance will be ignored,
|
|
1022
|
+
// hence why the index is 1 less than nondragged section.
|
|
1023
|
+
const fingerSplitIndex = dragIndex !== -1 ? 2 : 3;
|
|
1024
|
+
// Divide >=4th (3rd for drag) cursor instances with 1st + 2nd (+ 3rd for nondrag)
|
|
1025
|
+
// to check if the section is 3-fingered.
|
|
1026
|
+
const threeFingerRatio = cursorAmounts
|
|
1027
|
+
.slice(fingerSplitIndex)
|
|
1028
|
+
.reduce((acc, value) => acc + value, 0) /
|
|
1029
|
+
cursorAmounts
|
|
1030
|
+
.slice(0, fingerSplitIndex)
|
|
1031
|
+
.reduce((acc, value) => acc + value, 0);
|
|
1032
|
+
const similarPresses = [];
|
|
1033
|
+
for (const cursorVectorTime of cursorVectorTimes) {
|
|
1034
|
+
const pressIndex = similarPresses.findIndex((v) => v.vector.getDistance(cursorVectorTime.vector) <=
|
|
1035
|
+
this.cursorDistancingDistanceThreshold);
|
|
1036
|
+
if (pressIndex !== -1) {
|
|
1037
|
+
if (cursorVectorTime.time -
|
|
1038
|
+
similarPresses[pressIndex].lastTime >=
|
|
1039
|
+
this.cursorDistancingTimeThreshold) {
|
|
1040
|
+
similarPresses.splice(pressIndex, 1);
|
|
1041
|
+
similarPresses.push({
|
|
1042
|
+
vector: cursorVectorTime.vector,
|
|
1043
|
+
count: 1,
|
|
1044
|
+
lastTime: cursorVectorTime.time,
|
|
1045
|
+
});
|
|
1046
|
+
continue;
|
|
1047
|
+
}
|
|
1048
|
+
similarPresses[pressIndex].vector = cursorVectorTime.vector;
|
|
1049
|
+
similarPresses[pressIndex].lastTime = cursorVectorTime.time;
|
|
1050
|
+
++similarPresses[pressIndex].count;
|
|
1051
|
+
}
|
|
1052
|
+
else {
|
|
1053
|
+
similarPresses.push({
|
|
1054
|
+
vector: cursorVectorTime.vector,
|
|
1055
|
+
count: 1,
|
|
1056
|
+
lastTime: cursorVectorTime.time,
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
// Sort by highest count; assume the order is 3rd, 4th, 5th, ... finger
|
|
1061
|
+
const validPresses = similarPresses
|
|
1062
|
+
.filter((v) => v.count >= this.cursorDistancingCountThreshold)
|
|
1063
|
+
.sort((a, b) => b.count - a.count)
|
|
1064
|
+
.slice(2);
|
|
1065
|
+
// Ignore cursor presses that are only 1 for now since they are very likely to be accidental
|
|
1066
|
+
if ((threeFingerRatio > this.threeFingerRatioThreshold &&
|
|
1067
|
+
cursorAmounts.filter((v) => v > 1).length >
|
|
1068
|
+
fingerSplitIndex) ||
|
|
1069
|
+
validPresses.length > 0) {
|
|
1070
|
+
// Strain factor
|
|
1071
|
+
const objectCount = beatmapSection.lastObjectIndex -
|
|
1072
|
+
beatmapSection.firstObjectIndex +
|
|
1073
|
+
1;
|
|
1074
|
+
const strainFactor = Math.pow(objects
|
|
1075
|
+
.slice(beatmapSection.firstObjectIndex, beatmapSection.lastObjectIndex)
|
|
1076
|
+
.reduce((acc, value) => acc +
|
|
1077
|
+
value.originalTapStrain /
|
|
1078
|
+
ThreeFingerChecker.strainThreshold, 0), 0.75);
|
|
1079
|
+
// We can ignore the first 3 (2 for drag) filled cursor instances
|
|
1080
|
+
// since they are guaranteed not 3 finger.
|
|
1081
|
+
const threeFingerCursorAmounts = cursorAmounts
|
|
1082
|
+
.slice(fingerSplitIndex)
|
|
1083
|
+
.filter((amount) => amount > 0);
|
|
1084
|
+
// Finger factor applies more penalty if more fingers were used.
|
|
1085
|
+
const fingerFactor = threeFingerRatio > this.threeFingerRatioThreshold
|
|
1086
|
+
? threeFingerCursorAmounts.reduce((acc, value, index) => acc +
|
|
1087
|
+
Math.pow(((index + 1) * value * objectCount) /
|
|
1088
|
+
this.strainNoteCount, 0.9), 1)
|
|
1089
|
+
: Math.pow(validPresses.reduce((acc, value, index) => acc +
|
|
1090
|
+
Math.pow(((index + 1) *
|
|
1091
|
+
(value.count /
|
|
1092
|
+
(this
|
|
1093
|
+
.cursorDistancingCountThreshold *
|
|
1094
|
+
2)) *
|
|
1095
|
+
objectCount) /
|
|
1096
|
+
this.strainNoteCount, 0.2), 1), 0.2);
|
|
1097
|
+
// Length factor applies more penalty if there are more 3-fingered object.
|
|
1098
|
+
const lengthFactor = 1 + Math.pow(objectCount / this.strainNoteCount, 1.2);
|
|
1099
|
+
this.nerfFactors.push({
|
|
1100
|
+
strainFactor: Math.max(1, strainFactor),
|
|
1101
|
+
fingerFactor,
|
|
1102
|
+
lengthFactor,
|
|
1103
|
+
});
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* Calculates the final penalty.
|
|
1109
|
+
*/
|
|
1110
|
+
calculateFinalPenalty() {
|
|
1111
|
+
return (1 +
|
|
1112
|
+
this.nerfFactors.reduce((a, n) => a +
|
|
1113
|
+
0.015 *
|
|
1114
|
+
Math.pow(n.strainFactor * n.fingerFactor * n.lengthFactor, 1.05), 0));
|
|
1115
|
+
}
|
|
1126
1116
|
}
|
|
1127
1117
|
|
|
1128
|
-
/**
|
|
1129
|
-
* Contains information about which cursor index hits a hitobject.
|
|
1130
|
-
*/
|
|
1131
|
-
class IndexedHitObject {
|
|
1132
|
-
/**
|
|
1133
|
-
* The
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
*
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
*
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
*
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1118
|
+
/**
|
|
1119
|
+
* Contains information about which cursor index hits a hitobject.
|
|
1120
|
+
*/
|
|
1121
|
+
class IndexedHitObject {
|
|
1122
|
+
/**
|
|
1123
|
+
* The cursor index that hits the hitobject.
|
|
1124
|
+
*
|
|
1125
|
+
* If -1, the detection was unable to find any cursor that attempted to hit
|
|
1126
|
+
* the hitobject or it did not meet the criteria for detection.
|
|
1127
|
+
*/
|
|
1128
|
+
cursorIndex;
|
|
1129
|
+
/**
|
|
1130
|
+
* The group index of the cursor within the cursor index that hits the hitobject.
|
|
1131
|
+
*
|
|
1132
|
+
* If -1, the detection was unable to find any cursor that attempted to hit
|
|
1133
|
+
* the hitobject or it did not meet the criteria for detection.
|
|
1134
|
+
*/
|
|
1135
|
+
groupIndex;
|
|
1136
|
+
/**
|
|
1137
|
+
* The occurrence index within the group of the cursor within the cursor index that hits the hitobject.
|
|
1138
|
+
*
|
|
1139
|
+
* If -1, the detection was unable to find any cursor that attempted to hit
|
|
1140
|
+
* the hitobject or it did not meet the criteria for detection.
|
|
1141
|
+
*/
|
|
1142
|
+
occurrenceIndex;
|
|
1143
|
+
/**
|
|
1144
|
+
* The angle of the movement of the cursor towards the next hitobject.
|
|
1145
|
+
*/
|
|
1146
|
+
angle;
|
|
1147
|
+
/**
|
|
1148
|
+
* If this is a slider, whether the slider was cheesed.
|
|
1149
|
+
*/
|
|
1150
|
+
sliderCheesed = false;
|
|
1151
|
+
/**
|
|
1152
|
+
* The underlying difficulty hitobject.
|
|
1153
|
+
*/
|
|
1154
|
+
object;
|
|
1155
|
+
/**
|
|
1156
|
+
* The position of the cursor at the end of this hitobject.
|
|
1157
|
+
*
|
|
1158
|
+
* Will be altered during detection.
|
|
1159
|
+
*/
|
|
1160
|
+
endCursorPosition;
|
|
1161
|
+
/**
|
|
1162
|
+
* Whether the hitobject is likely two-handed.
|
|
1163
|
+
*/
|
|
1164
|
+
is2Handed;
|
|
1165
|
+
/**
|
|
1166
|
+
* @param object The underlying difficulty hitobject.
|
|
1167
|
+
* @param cursorIndex The cursor index that moves towards the hitobject.
|
|
1168
|
+
* @param groupIndex The group index of the cursor within the cursor index that hits the hitobject.
|
|
1169
|
+
* @param occurrenceIndex The occurrence index within the group of the cursor within the cursor index that hits the hitobject.
|
|
1170
|
+
* @param angle The angle of the movement of the cursor that moves towards the hitobject.
|
|
1171
|
+
*/
|
|
1172
|
+
constructor(object, cursorIndex, groupIndex, occurrenceIndex, angle, is2Handed) {
|
|
1173
|
+
this.object = object;
|
|
1174
|
+
this.cursorIndex = cursorIndex;
|
|
1175
|
+
this.groupIndex = groupIndex;
|
|
1176
|
+
this.occurrenceIndex = occurrenceIndex;
|
|
1177
|
+
this.angle = angle;
|
|
1178
|
+
this.is2Handed = is2Handed;
|
|
1179
|
+
this.endCursorPosition = this.object.object.getStackedEndPosition(osuBase.Modes.droid);
|
|
1180
|
+
}
|
|
1164
1181
|
}
|
|
1165
1182
|
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
*
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
*
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
this.
|
|
1206
|
-
this.
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
}
|
|
1216
|
-
/**
|
|
1217
|
-
* Checks if a beatmap is two-handed.
|
|
1218
|
-
*/
|
|
1219
|
-
check() {
|
|
1220
|
-
if (this.data.cursorMovement.filter((v) => v.occurrenceGroups.length > 0).length <= 1) {
|
|
1221
|
-
return { is2Hand: false,
|
|
1222
|
-
}
|
|
1223
|
-
this.indexHitObjects();
|
|
1224
|
-
this.applyPenalty();
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
}
|
|
1262
|
-
//
|
|
1263
|
-
//
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
//
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1183
|
+
// import { writeFileSync } from "fs";
|
|
1184
|
+
/**
|
|
1185
|
+
* Utility to check whether or not a beatmap is two-handed.
|
|
1186
|
+
*/
|
|
1187
|
+
class TwoHandChecker {
|
|
1188
|
+
/**
|
|
1189
|
+
* The difficulty calculator that is being analyzed.
|
|
1190
|
+
*/
|
|
1191
|
+
calculator;
|
|
1192
|
+
/**
|
|
1193
|
+
* The data of the replay.
|
|
1194
|
+
*/
|
|
1195
|
+
data;
|
|
1196
|
+
/**
|
|
1197
|
+
* The hitobjects of the beatmap that have been assigned with their respective cursor index.
|
|
1198
|
+
*/
|
|
1199
|
+
indexedHitObjects = [];
|
|
1200
|
+
/**
|
|
1201
|
+
* The osu!droid hitwindow of the analyzed beatmap.
|
|
1202
|
+
*/
|
|
1203
|
+
hitWindow;
|
|
1204
|
+
/**
|
|
1205
|
+
* The 50 osu!droid hit window of the analyzed beatmap.
|
|
1206
|
+
*/
|
|
1207
|
+
hitWindow50;
|
|
1208
|
+
// private csvString: string;
|
|
1209
|
+
/**
|
|
1210
|
+
* @param calculator The difficulty calculator to analyze.
|
|
1211
|
+
* @param data The data of the replay.
|
|
1212
|
+
*/
|
|
1213
|
+
constructor(calculator, data) {
|
|
1214
|
+
this.calculator = calculator;
|
|
1215
|
+
this.data = data;
|
|
1216
|
+
const stats = new osuBase.MapStats({
|
|
1217
|
+
od: this.calculator.beatmap.difficulty.od,
|
|
1218
|
+
mods: this.calculator.mods.filter((m) => m.isApplicableToDroid() &&
|
|
1219
|
+
!osuBase.ModUtil.speedChangingMods.some((v) => v.acronym === m.acronym)),
|
|
1220
|
+
}).calculate();
|
|
1221
|
+
this.hitWindow = new osuBase.DroidHitWindow(stats.od);
|
|
1222
|
+
this.hitWindow50 = this.hitWindow.hitWindowFor50(calculator.mods.some((m) => m instanceof osuBase.ModPrecise));
|
|
1223
|
+
// this.csvString = `Mods,${
|
|
1224
|
+
// data.convertedMods.reduce((a, m) => a + m.acronym, "") || "NM"
|
|
1225
|
+
// }\nCombo,${data.maxCombo}\nAccuracy,"${(
|
|
1226
|
+
// data.accuracy.value() * 100
|
|
1227
|
+
// ).toFixed(2)}% [${data.accuracy.n300}/${data.accuracy.n100}/${
|
|
1228
|
+
// data.accuracy.n50
|
|
1229
|
+
// }/${
|
|
1230
|
+
// data.accuracy.nmiss
|
|
1231
|
+
// }]"\n\nIndex,Type,StartTime,EndTime,DeltaTime,CursorIndex,GroupIndex,CursorDuration\n`;
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Checks if a beatmap is two-handed.
|
|
1235
|
+
*/
|
|
1236
|
+
check() {
|
|
1237
|
+
if (this.data.cursorMovement.filter((v) => v.occurrenceGroups.length > 0).length <= 1) {
|
|
1238
|
+
return { is2Hand: false, twoHandedNoteCount: 0 };
|
|
1239
|
+
}
|
|
1240
|
+
this.indexHitObjects();
|
|
1241
|
+
// this.applyPenalty();
|
|
1242
|
+
// for (let i = 0; i < this.calculator.objects.length; ++i) {
|
|
1243
|
+
// const object: PlaceableHitObject =
|
|
1244
|
+
// this.calculator.objects[i].object;
|
|
1245
|
+
// if (object instanceof Spinner) {
|
|
1246
|
+
// continue;
|
|
1247
|
+
// }
|
|
1248
|
+
// let deltaTime: number = 0;
|
|
1249
|
+
// if (i > 0) {
|
|
1250
|
+
// const prevObject: PlaceableHitObject =
|
|
1251
|
+
// this.calculator.objects[i - 1].object;
|
|
1252
|
+
// deltaTime = Math.max(
|
|
1253
|
+
// object.startTime - prevObject.startTime,
|
|
1254
|
+
// 25
|
|
1255
|
+
// );
|
|
1256
|
+
// if (prevObject instanceof Slider) {
|
|
1257
|
+
// deltaTime = Math.max(
|
|
1258
|
+
// deltaTime - prevObject.lazyTravelTime,
|
|
1259
|
+
// 25
|
|
1260
|
+
// );
|
|
1261
|
+
// }
|
|
1262
|
+
// }
|
|
1263
|
+
// const objectInfo = this.getCursorPositionForObjectStart(i);
|
|
1264
|
+
// this.csvString += `${i},${object.typeStr()},${object.startTime},${
|
|
1265
|
+
// object instanceof Slider
|
|
1266
|
+
// ? object.startTime + object.lazyTravelTime
|
|
1267
|
+
// : object.endTime
|
|
1268
|
+
// },${deltaTime},${objectInfo.cursorIndex},${objectInfo.groupIndex},${
|
|
1269
|
+
// this.data.cursorMovement[objectInfo.cursorIndex]
|
|
1270
|
+
// ?.occurrenceGroups[objectInfo.groupIndex]?.duration ??
|
|
1271
|
+
// Number.POSITIVE_INFINITY
|
|
1272
|
+
// }\n`;
|
|
1273
|
+
// }
|
|
1274
|
+
// writeFileSync(
|
|
1275
|
+
// join(
|
|
1276
|
+
// process.cwd(),
|
|
1277
|
+
// "files",
|
|
1278
|
+
// `${this.data.playerName} - ${this.calculator.beatmap.metadata.fullTitle}.csv`
|
|
1279
|
+
// ),
|
|
1280
|
+
// this.csvString
|
|
1281
|
+
// );
|
|
1282
|
+
let twoHandedNoteCount = 0;
|
|
1283
|
+
const maxStrain = Math.max(...this.calculator.objects.map((v) => v.aimStrainWithSliders));
|
|
1284
|
+
if (maxStrain) {
|
|
1285
|
+
twoHandedNoteCount = this.indexedHitObjects.reduce((total, object) => {
|
|
1286
|
+
if (!object.is2Handed) {
|
|
1287
|
+
return total;
|
|
1288
|
+
}
|
|
1289
|
+
return (total +
|
|
1290
|
+
1 /
|
|
1291
|
+
(1 +
|
|
1292
|
+
Math.exp(-((object.object.aimStrainWithSliders /
|
|
1293
|
+
maxStrain) *
|
|
1294
|
+
12 -
|
|
1295
|
+
6))));
|
|
1296
|
+
}, 0);
|
|
1297
|
+
}
|
|
1298
|
+
return {
|
|
1299
|
+
is2Hand: twoHandedNoteCount >
|
|
1300
|
+
this.calculator.attributes.aimNoteCount * 0.15,
|
|
1301
|
+
twoHandedNoteCount: twoHandedNoteCount,
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
/**
|
|
1305
|
+
* Converts hitobjects into indexed hit objects.
|
|
1306
|
+
*/
|
|
1307
|
+
indexHitObjects() {
|
|
1308
|
+
const indexes = [];
|
|
1309
|
+
for (let i = 0; i < this.calculator.objects.length; ++i) {
|
|
1310
|
+
const indexedHitObject = this.getIndexedHitObject(i);
|
|
1311
|
+
indexedHitObject.sliderCheesed = this.checkSliderCheesing(indexedHitObject, this.data.hitObjectData[i]);
|
|
1312
|
+
indexes.push(indexedHitObject.cursorIndex);
|
|
1313
|
+
this.indexedHitObjects.push(indexedHitObject);
|
|
1314
|
+
}
|
|
1315
|
+
// console.log("Aim note count:", this.calculator.attributes.aimNoteCount);
|
|
1316
|
+
// console.log(
|
|
1317
|
+
// this.indexedHitObjects.filter((v) => v.cursorIndex !== -1).length +
|
|
1318
|
+
// 1,
|
|
1319
|
+
// "indexes found,",
|
|
1320
|
+
// this.indexedHitObjects.filter((v) => v.cursorIndex === -1).length -
|
|
1321
|
+
// 1,
|
|
1322
|
+
// "not found,",
|
|
1323
|
+
// this.indexedHitObjects.filter((v) => v.is2Handed).length,
|
|
1324
|
+
// "2 handed,",
|
|
1325
|
+
// this.indexedHitObjects.filter((v) => !v.is2Handed).length,
|
|
1326
|
+
// "not 2 handed"
|
|
1327
|
+
// );
|
|
1328
|
+
// for (let i = 0; i < this.data.cursorMovement.length; ++i) {
|
|
1329
|
+
// console.log(
|
|
1330
|
+
// "Index",
|
|
1331
|
+
// i,
|
|
1332
|
+
// "count:",
|
|
1333
|
+
// this.indexedHitObjects.filter((v) => v.cursorIndex === i).length
|
|
1334
|
+
// );
|
|
1335
|
+
// }
|
|
1336
|
+
// TODO: solve -1 cursor indexes
|
|
1337
|
+
// console.table(
|
|
1338
|
+
// this.indexedHitObjects
|
|
1339
|
+
// .filter(
|
|
1340
|
+
// (v) =>
|
|
1341
|
+
// // v.cursorIndex === -1 &&
|
|
1342
|
+
// // v.object.aimStrainWithSliders > 200 &&
|
|
1343
|
+
// v.object.deltaTime > 75 && v.is2Handed
|
|
1344
|
+
// )
|
|
1345
|
+
// .map((v) => {
|
|
1346
|
+
// return {
|
|
1347
|
+
// startTime: v.object.object.startTime,
|
|
1348
|
+
// type: v.object.object.typeStr(),
|
|
1349
|
+
// strain: v.object.aimStrainWithSliders,
|
|
1350
|
+
// hitAngle:
|
|
1351
|
+
// v.angle !== null
|
|
1352
|
+
// ? MathUtils.radiansToDegrees(v.angle)
|
|
1353
|
+
// : null,
|
|
1354
|
+
// objectAngle:
|
|
1355
|
+
// v.object.angle !== null
|
|
1356
|
+
// ? MathUtils.radiansToDegrees(v.object.angle)
|
|
1357
|
+
// : null,
|
|
1358
|
+
// cursorIndex: v.cursorIndex,
|
|
1359
|
+
// };
|
|
1360
|
+
// })
|
|
1361
|
+
// );
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* Gets the cursor index that hits the given object.
|
|
1365
|
+
*
|
|
1366
|
+
* @param objectIndex The index of the object to check.
|
|
1367
|
+
* @returns The cursor index that hits the given object, -1 if the index is not found, the object is a spinner, or the object was missed.
|
|
1368
|
+
*/
|
|
1369
|
+
getIndexedHitObject(objectIndex) {
|
|
1370
|
+
const diffObject = this.calculator.objects[objectIndex];
|
|
1371
|
+
const { object } = diffObject;
|
|
1372
|
+
// We don't care about the first object and spinners.
|
|
1373
|
+
if (objectIndex === 0 || object instanceof osuBase.Spinner) {
|
|
1374
|
+
return new IndexedHitObject(diffObject, -1, -1, -1, null, false);
|
|
1375
|
+
}
|
|
1376
|
+
// We don't care if the aim strain is too low.
|
|
1377
|
+
// if (diffObject.aimStrainWithSliders < 200) {
|
|
1378
|
+
// return new IndexedHitObject(diffObject, -1, -1, -1, null, false);
|
|
1379
|
+
// }
|
|
1380
|
+
const prevObject = this.calculator.beatmap.hitObjects.objects[objectIndex - 1];
|
|
1381
|
+
const prevObjectData = this.data.hitObjectData[objectIndex - 1];
|
|
1382
|
+
if (prevObject instanceof osuBase.Spinner ||
|
|
1383
|
+
prevObjectData.result === exports.HitResult.miss) {
|
|
1384
|
+
return new IndexedHitObject(diffObject, -1, -1, -1, null, false);
|
|
1385
|
+
}
|
|
1386
|
+
const objectStartPosition = object.getStackedPosition(osuBase.Modes.droid);
|
|
1387
|
+
let prevObjectEndPosition = prevObject.getStackedEndPosition(osuBase.Modes.droid);
|
|
1388
|
+
if (prevObject instanceof osuBase.Slider) {
|
|
1389
|
+
if (prevObject.lazyTravelDistance > 0) {
|
|
1390
|
+
const lazyEndMovement = objectStartPosition.subtract(prevObject.lazyEndPosition);
|
|
1391
|
+
const actualEndMovement = objectStartPosition.subtract(prevObjectEndPosition);
|
|
1392
|
+
if (lazyEndMovement.length < actualEndMovement.length) {
|
|
1393
|
+
prevObjectEndPosition = prevObject.lazyEndPosition;
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
else {
|
|
1397
|
+
prevObjectEndPosition = prevObject.getStackedPosition(osuBase.Modes.droid);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
const prevToCurrentMovement = object
|
|
1401
|
+
.getStackedPosition(osuBase.Modes.droid)
|
|
1402
|
+
.subtract(prevObjectEndPosition);
|
|
1403
|
+
const radius = object.getRadius(osuBase.Modes.droid);
|
|
1404
|
+
// Don't consider objects that are too close to each other.
|
|
1405
|
+
if (prevToCurrentMovement.length <= radius) {
|
|
1406
|
+
return new IndexedHitObject(diffObject, -1, -1, -1, null, false);
|
|
1407
|
+
}
|
|
1408
|
+
// The case for a one-handed object is that there will be a slight movement in the cursor towards
|
|
1409
|
+
// the next object in fast patterns. We should not be worried about slow patterns as they will only
|
|
1410
|
+
// make a minimal difference and aim strain threshold should filter them out.
|
|
1411
|
+
// In order to verify if the player does that, we check if the movement towards the current
|
|
1412
|
+
// object is sufficient enough to be two-handed. This is done by first gathering info about two cursor positions:
|
|
1413
|
+
// 1. The cursor position at the end of the previous object
|
|
1414
|
+
// 2. The cursor position that presses the current object
|
|
1415
|
+
// and then get the movement vector between both positions, then see if the cursor movement after the previous object
|
|
1416
|
+
// was pressed produces an angle that is acute enough with respect to the aforementioned movement vector.
|
|
1417
|
+
// If the angle isn't fulfilled, check for the "initial velocity", which is the movement velocity from the
|
|
1418
|
+
// previous object's end time to the current object's start time and the "air velocity", which is the
|
|
1419
|
+
// velocity from the previous object's cursor release time to the next object's cursor press time. If the velocity
|
|
1420
|
+
// during the held tap is significantly less than the estimated velocity, it's considered two hand.
|
|
1421
|
+
const objectInformation = this.getCursorPositionForObjectStart(objectIndex);
|
|
1422
|
+
const prevObjectInformation = this.getCursorPositionForObjectEnd(objectIndex - 1);
|
|
1423
|
+
this.indexedHitObjects[objectIndex - 1].endCursorPosition =
|
|
1424
|
+
prevObjectInformation.position;
|
|
1425
|
+
if (prevObjectInformation.position.x === Number.POSITIVE_INFINITY) {
|
|
1426
|
+
return new IndexedHitObject(diffObject, -1, -1, -1, null, false);
|
|
1427
|
+
}
|
|
1428
|
+
if (prevObjectInformation.cursorIndex ===
|
|
1429
|
+
objectInformation.cursorIndex &&
|
|
1430
|
+
prevObjectInformation.groupIndex === objectInformation.groupIndex) {
|
|
1431
|
+
return new IndexedHitObject(diffObject, objectInformation.cursorIndex, objectInformation.groupIndex, prevObjectInformation.occurrenceIndex, 0, false);
|
|
1432
|
+
}
|
|
1433
|
+
const cursorData = this.data.cursorMovement[prevObjectInformation.cursorIndex];
|
|
1434
|
+
// There can be multiple angles to which the cursor moves towards the next object.
|
|
1435
|
+
// For this, we take the smallest angle.
|
|
1436
|
+
let finalAngle = Number.POSITIVE_INFINITY;
|
|
1437
|
+
const cursorGroup = cursorData.occurrenceGroups[prevObjectInformation.groupIndex];
|
|
1438
|
+
const cursors = cursorGroup.allOccurrences;
|
|
1439
|
+
const prevToCurrentCursorMovement = objectInformation.position.subtract(prevObjectInformation.position);
|
|
1440
|
+
for (let i = prevObjectInformation.occurrenceIndex + 1; i < cursors.length; ++i) {
|
|
1441
|
+
const cursor = cursors[i];
|
|
1442
|
+
const prevCursor = cursors[i - 1];
|
|
1443
|
+
if (cursor.position.equals(prevCursor.position)) {
|
|
1444
|
+
continue;
|
|
1445
|
+
}
|
|
1446
|
+
if (cursor.id === exports.MovementType.up) {
|
|
1447
|
+
break;
|
|
1448
|
+
}
|
|
1449
|
+
const currentMovement = cursor.position.subtract(prevCursor.position);
|
|
1450
|
+
const dot = prevToCurrentCursorMovement.dot(currentMovement);
|
|
1451
|
+
const det = prevToCurrentCursorMovement.x * currentMovement.y -
|
|
1452
|
+
prevToCurrentCursorMovement.y * currentMovement.x;
|
|
1453
|
+
const movementAngle = Math.abs(Math.atan2(det, dot));
|
|
1454
|
+
finalAngle = Math.min(finalAngle, movementAngle);
|
|
1455
|
+
}
|
|
1456
|
+
const is2Handed = finalAngle >= Math.PI / 6;
|
|
1457
|
+
// if (is2Handed) {
|
|
1458
|
+
// // If angle isn't fulfilled, check for cursor velocity.
|
|
1459
|
+
// let deltaTime: number = Math.max(
|
|
1460
|
+
// object.startTime - prevObject.startTime,
|
|
1461
|
+
// 25
|
|
1462
|
+
// );
|
|
1463
|
+
// if (prevObject instanceof Slider) {
|
|
1464
|
+
// deltaTime = Math.max(deltaTime - prevObject.lazyTravelTime, 25);
|
|
1465
|
+
// }
|
|
1466
|
+
// // "Initial velocity" is the movement velocity from the previous object's end time to the current object's start time.
|
|
1467
|
+
// const initialVelocity: number =
|
|
1468
|
+
// objectStartPosition.getDistance(prevObjectEndPosition) /
|
|
1469
|
+
// deltaTime;
|
|
1470
|
+
// // const finalCursor: CursorOccurrence =
|
|
1471
|
+
// // cursorGroup.moves.at(-1) ?? cursorGroup.down;
|
|
1472
|
+
// const currentCursorGroup: CursorOccurrenceGroup =
|
|
1473
|
+
// this.data.cursorMovement[objectInformation.cursorIndex]
|
|
1474
|
+
// .occurrenceGroups[objectInformation.groupIndex];
|
|
1475
|
+
// // const cursorDistance: number = currentCursorGroup.down.position.getDistance(
|
|
1476
|
+
// // finalCursor.position
|
|
1477
|
+
// // );
|
|
1478
|
+
// const cursorDuration: number = Math.max(
|
|
1479
|
+
// 0,
|
|
1480
|
+
// currentCursorGroup.startTime - cursorGroup.endTime
|
|
1481
|
+
// );
|
|
1482
|
+
// // "Air velocity" is the cursor velocity from the moment the previous cursor release action to the next cursor press action.
|
|
1483
|
+
// // const airVelocity: number = cursorDistance / cursorDuration;
|
|
1484
|
+
// is2Handed =
|
|
1485
|
+
// // airVelocity / initialVelocity < 0.8 &&
|
|
1486
|
+
// cursorDuration / deltaTime > 0.2;
|
|
1487
|
+
// for (
|
|
1488
|
+
// let i = prevObjectInformation.occurrenceIndex + 1;
|
|
1489
|
+
// i < cursors.length && is2Handed;
|
|
1490
|
+
// ++i
|
|
1491
|
+
// ) {
|
|
1492
|
+
// const cursor: CursorOccurrence = cursors[i];
|
|
1493
|
+
// const prevCursor: CursorOccurrence = cursors[i - 1];
|
|
1494
|
+
// if (
|
|
1495
|
+
// cursor.position.equals(prevCursor.position) ||
|
|
1496
|
+
// cursor.time === prevCursor.time
|
|
1497
|
+
// ) {
|
|
1498
|
+
// continue;
|
|
1499
|
+
// }
|
|
1500
|
+
// if (cursor.id === MovementType.up) {
|
|
1501
|
+
// break;
|
|
1502
|
+
// }
|
|
1503
|
+
// // "Cursor velocity" is the velocity from the previous object's cursor release time to the current object's press time.
|
|
1504
|
+
// const cursorVelocity: number =
|
|
1505
|
+
// cursor.position.getDistance(prevCursor.position) /
|
|
1506
|
+
// (cursor.time - prevCursor.time);
|
|
1507
|
+
// is2Handed = cursorVelocity / initialVelocity < 0.8;
|
|
1508
|
+
// }
|
|
1509
|
+
// }
|
|
1510
|
+
if (!Number.isFinite(finalAngle)) {
|
|
1511
|
+
return new IndexedHitObject(diffObject, -1, -1, -1, null, false);
|
|
1512
|
+
}
|
|
1513
|
+
return new IndexedHitObject(diffObject, prevObjectInformation.cursorIndex, prevObjectInformation.groupIndex, prevObjectInformation.occurrenceIndex, finalAngle, is2Handed);
|
|
1514
|
+
}
|
|
1515
|
+
/**
|
|
1516
|
+
* Gets the position of the cursor that presses an object.
|
|
1517
|
+
*
|
|
1518
|
+
* @param objectIndex THe index of the object.
|
|
1519
|
+
* @returns The position of the cursor that presses the object.
|
|
1520
|
+
*/
|
|
1521
|
+
getCursorPositionForObjectStart(objectIndex) {
|
|
1522
|
+
const object = this.calculator.beatmap.hitObjects.objects[objectIndex];
|
|
1523
|
+
const data = this.data.hitObjectData[objectIndex];
|
|
1524
|
+
const objectPosition = object.getStackedPosition(osuBase.Modes.droid);
|
|
1525
|
+
if (object instanceof osuBase.Spinner) {
|
|
1526
|
+
return {
|
|
1527
|
+
position: objectPosition,
|
|
1528
|
+
cursorIndex: 0,
|
|
1529
|
+
groupIndex: Number.POSITIVE_INFINITY,
|
|
1530
|
+
occurrenceIndex: Number.POSITIVE_INFINITY,
|
|
1531
|
+
cursorTime: object.startTime,
|
|
1532
|
+
};
|
|
1533
|
+
}
|
|
1534
|
+
const radius = object.getRadius(osuBase.Modes.droid);
|
|
1535
|
+
let hitWindow = this.hitWindow50;
|
|
1536
|
+
const isPrecise = this.data.convertedMods.some((m) => m instanceof osuBase.ModPrecise);
|
|
1537
|
+
// For sliders, set the hit window to as lenient as possible.
|
|
1538
|
+
if (object instanceof osuBase.Circle) {
|
|
1539
|
+
switch (data.result) {
|
|
1540
|
+
case exports.HitResult.great:
|
|
1541
|
+
hitWindow = this.hitWindow.hitWindowFor300(isPrecise);
|
|
1542
|
+
break;
|
|
1543
|
+
case exports.HitResult.good:
|
|
1544
|
+
hitWindow = this.hitWindow.hitWindowFor100(isPrecise);
|
|
1545
|
+
break;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
// TODO: what to do for head sliderbreaks?
|
|
1549
|
+
let nearestPosition = new osuBase.Vector2(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
1550
|
+
let nearestCursorIndex = 0;
|
|
1551
|
+
let nearestGroupIndex = 0;
|
|
1552
|
+
let nearestCursorGroupIndex = 0;
|
|
1553
|
+
let nearestCursorTime = 0;
|
|
1554
|
+
const minimumActiveTime = object.startTime - hitWindow;
|
|
1555
|
+
const maximumActiveTime = object.startTime + hitWindow;
|
|
1556
|
+
for (let i = 0; i < this.data.cursorMovement.length; ++i) {
|
|
1557
|
+
if (nearestPosition.getDistance(objectPosition) <= radius) {
|
|
1558
|
+
break;
|
|
1559
|
+
}
|
|
1560
|
+
const cursorData = this.data.cursorMovement[i];
|
|
1561
|
+
for (let j = 0; j < cursorData.occurrenceGroups.length; ++j) {
|
|
1562
|
+
if (nearestPosition.getDistance(objectPosition) <= radius) {
|
|
1563
|
+
break;
|
|
1564
|
+
}
|
|
1565
|
+
const cursorGroup = cursorData.occurrenceGroups[j];
|
|
1566
|
+
if (cursorGroup.endTime < minimumActiveTime) {
|
|
1567
|
+
continue;
|
|
1568
|
+
}
|
|
1569
|
+
if (cursorGroup.startTime > maximumActiveTime) {
|
|
1570
|
+
break;
|
|
1571
|
+
}
|
|
1572
|
+
// Validate the down press first.
|
|
1573
|
+
const { down } = cursorGroup;
|
|
1574
|
+
if (down.position.getDistance(objectPosition) <= radius &&
|
|
1575
|
+
Math.abs(down.time - object.startTime) <= hitWindow) {
|
|
1576
|
+
if (objectIndex > 0) {
|
|
1577
|
+
const prevObject = this.calculator.beatmap.hitObjects.objects[objectIndex - 1];
|
|
1578
|
+
if (down.time > prevObject.endTime) {
|
|
1579
|
+
return {
|
|
1580
|
+
position: down.position,
|
|
1581
|
+
cursorIndex: i,
|
|
1582
|
+
groupIndex: j,
|
|
1583
|
+
occurrenceIndex: 0,
|
|
1584
|
+
cursorTime: down.time,
|
|
1585
|
+
};
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
else {
|
|
1589
|
+
return {
|
|
1590
|
+
position: down.position,
|
|
1591
|
+
cursorIndex: i,
|
|
1592
|
+
groupIndex: j,
|
|
1593
|
+
occurrenceIndex: 0,
|
|
1594
|
+
cursorTime: down.time,
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
const cursors = cursorGroup.allOccurrences;
|
|
1599
|
+
for (let k = 1; k < cursors.length; ++k) {
|
|
1600
|
+
const cursor = cursors[k];
|
|
1601
|
+
const prevCursor = cursors[k - 1];
|
|
1602
|
+
if (cursor.time < minimumActiveTime) {
|
|
1603
|
+
continue;
|
|
1604
|
+
}
|
|
1605
|
+
if (prevCursor.time > maximumActiveTime) {
|
|
1606
|
+
break;
|
|
1607
|
+
}
|
|
1608
|
+
let cursorPosition;
|
|
1609
|
+
if (cursor.id === exports.MovementType.up) {
|
|
1610
|
+
cursorPosition = prevCursor.position;
|
|
1611
|
+
const distance = cursorPosition.getDistance(objectPosition);
|
|
1612
|
+
if (distance <
|
|
1613
|
+
nearestPosition.getDistance(objectPosition)) {
|
|
1614
|
+
nearestPosition = cursorPosition;
|
|
1615
|
+
nearestCursorIndex = i;
|
|
1616
|
+
nearestGroupIndex = j;
|
|
1617
|
+
nearestCursorGroupIndex = k;
|
|
1618
|
+
nearestCursorTime = prevCursor.time;
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
else {
|
|
1622
|
+
// Check for cursor presses inbetween occurrences.
|
|
1623
|
+
for (let k = 0; k < this.data.cursorMovement.length; ++k) {
|
|
1624
|
+
// Skip the current cursor index.
|
|
1625
|
+
if (k === i) {
|
|
1626
|
+
continue;
|
|
1627
|
+
}
|
|
1628
|
+
const cursorGroup = this.data.cursorMovement[k].occurrenceGroups.find((v) => v.down.time >= prevCursor.time &&
|
|
1629
|
+
v.down.time <= cursor.time);
|
|
1630
|
+
if (!cursorGroup) {
|
|
1631
|
+
continue;
|
|
1632
|
+
}
|
|
1633
|
+
const t = (cursorGroup.down.time - prevCursor.time) /
|
|
1634
|
+
(cursor.time - prevCursor.time);
|
|
1635
|
+
cursorPosition = new osuBase.Vector2(osuBase.Interpolation.lerp(prevCursor.position.x, cursor.position.x, t), osuBase.Interpolation.lerp(prevCursor.position.y, cursor.position.y, t));
|
|
1636
|
+
const distance = cursorPosition.getDistance(objectPosition);
|
|
1637
|
+
if (distance <
|
|
1638
|
+
nearestPosition.getDistance(objectPosition)) {
|
|
1639
|
+
nearestPosition = cursorPosition;
|
|
1640
|
+
nearestCursorIndex = i;
|
|
1641
|
+
nearestGroupIndex = j;
|
|
1642
|
+
nearestCursorGroupIndex = k;
|
|
1643
|
+
nearestCursorTime = cursorGroup.down.time;
|
|
1644
|
+
}
|
|
1645
|
+
if (distance <= radius) {
|
|
1646
|
+
break;
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
if (nearestPosition.getDistance(objectPosition) <= radius) {
|
|
1651
|
+
break;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
if (nearestPosition.getDistance(objectPosition) ===
|
|
1657
|
+
Number.POSITIVE_INFINITY) {
|
|
1658
|
+
return {
|
|
1659
|
+
position: nearestPosition,
|
|
1660
|
+
cursorIndex: Number.POSITIVE_INFINITY,
|
|
1661
|
+
groupIndex: Number.POSITIVE_INFINITY,
|
|
1662
|
+
occurrenceIndex: Number.POSITIVE_INFINITY,
|
|
1663
|
+
cursorTime: object.startTime,
|
|
1664
|
+
};
|
|
1665
|
+
}
|
|
1666
|
+
return {
|
|
1667
|
+
position: nearestPosition,
|
|
1668
|
+
cursorIndex: nearestCursorIndex,
|
|
1669
|
+
groupIndex: nearestGroupIndex,
|
|
1670
|
+
occurrenceIndex: nearestCursorGroupIndex,
|
|
1671
|
+
cursorTime: nearestCursorTime,
|
|
1672
|
+
};
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* Gets the position of the cursor that at an object's end position.
|
|
1676
|
+
*
|
|
1677
|
+
* @param objectIndex THe index of the object.
|
|
1678
|
+
* @returns The position of the cursor at the object's end position.
|
|
1679
|
+
*/
|
|
1680
|
+
getCursorPositionForObjectEnd(objectIndex) {
|
|
1681
|
+
const object = this.calculator.beatmap.hitObjects.objects[objectIndex];
|
|
1682
|
+
if (!(object instanceof osuBase.Slider)) {
|
|
1683
|
+
return this.getCursorPositionForObjectStart(objectIndex);
|
|
1684
|
+
}
|
|
1685
|
+
const nextObject = this.calculator.beatmap.hitObjects.objects[objectIndex - 1];
|
|
1686
|
+
let objectEndPosition = object.getStackedEndPosition(osuBase.Modes.droid);
|
|
1687
|
+
if (object.lazyTravelDistance > 0 && nextObject) {
|
|
1688
|
+
const nextStartPosition = nextObject.getStackedPosition(osuBase.Modes.droid);
|
|
1689
|
+
const lazyEndMovement = nextStartPosition.subtract(object.lazyEndPosition);
|
|
1690
|
+
const actualEndMovement = nextStartPosition.subtract(objectEndPosition);
|
|
1691
|
+
if (lazyEndMovement.length < actualEndMovement.length) {
|
|
1692
|
+
objectEndPosition = object.lazyEndPosition;
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
else {
|
|
1696
|
+
objectEndPosition = object.getStackedPosition(osuBase.Modes.droid);
|
|
1697
|
+
}
|
|
1698
|
+
let nearestPosition = new osuBase.Vector2(Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY);
|
|
1699
|
+
let nearestCursorIndex = 0;
|
|
1700
|
+
let nearestGroupIndex = 0;
|
|
1701
|
+
let nearestCursorGroupIndex = 0;
|
|
1702
|
+
let nearestCursorTime = 0;
|
|
1703
|
+
for (let i = 0; i < this.data.cursorMovement.length; ++i) {
|
|
1704
|
+
const cursorData = this.data.cursorMovement[i];
|
|
1705
|
+
for (let j = 0; j < cursorData.occurrenceGroups.length; ++j) {
|
|
1706
|
+
const cursorGroup = cursorData.occurrenceGroups[j];
|
|
1707
|
+
if (cursorGroup.endTime < object.startTime) {
|
|
1708
|
+
continue;
|
|
1709
|
+
}
|
|
1710
|
+
if (cursorGroup.startTime > object.endTime) {
|
|
1711
|
+
break;
|
|
1712
|
+
}
|
|
1713
|
+
const cursors = cursorGroup.allOccurrences;
|
|
1714
|
+
for (let k = 0; k < cursors.length; ++k) {
|
|
1715
|
+
const cursor = cursors[k];
|
|
1716
|
+
let cursorPosition;
|
|
1717
|
+
switch (cursor.id) {
|
|
1718
|
+
case exports.MovementType.down:
|
|
1719
|
+
cursorPosition = cursor.position;
|
|
1720
|
+
break;
|
|
1721
|
+
case exports.MovementType.up: {
|
|
1722
|
+
const prevCursor = cursors[k - 1];
|
|
1723
|
+
cursorPosition = prevCursor.position;
|
|
1724
|
+
break;
|
|
1725
|
+
}
|
|
1726
|
+
case exports.MovementType.move: {
|
|
1727
|
+
const prevCursor = cursors[k - 1];
|
|
1728
|
+
const t = osuBase.MathUtils.clamp((object.endTime - prevCursor.time) /
|
|
1729
|
+
(cursor.time - prevCursor.time), 0, 1);
|
|
1730
|
+
cursorPosition = new osuBase.Vector2(osuBase.Interpolation.lerp(prevCursor.position.x, cursor.position.x, t), osuBase.Interpolation.lerp(prevCursor.position.y, cursor.position.y, t));
|
|
1731
|
+
break;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
if (cursorPosition.getDistance(objectEndPosition) <
|
|
1735
|
+
nearestPosition.getDistance(objectEndPosition)) {
|
|
1736
|
+
nearestPosition = cursorPosition;
|
|
1737
|
+
nearestCursorIndex = i;
|
|
1738
|
+
nearestGroupIndex = j;
|
|
1739
|
+
switch (cursor.id) {
|
|
1740
|
+
case exports.MovementType.down:
|
|
1741
|
+
nearestCursorGroupIndex = k;
|
|
1742
|
+
nearestCursorTime = cursor.time;
|
|
1743
|
+
break;
|
|
1744
|
+
case exports.MovementType.up:
|
|
1745
|
+
nearestCursorGroupIndex = k - 1;
|
|
1746
|
+
nearestCursorTime = cursors[k - 1].time;
|
|
1747
|
+
break;
|
|
1748
|
+
case exports.MovementType.move:
|
|
1749
|
+
nearestCursorGroupIndex = k;
|
|
1750
|
+
nearestCursorTime = object.endTime;
|
|
1751
|
+
break;
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
if (nearestPosition.getDistance(objectEndPosition) ===
|
|
1758
|
+
Number.POSITIVE_INFINITY) {
|
|
1759
|
+
return {
|
|
1760
|
+
position: nearestPosition,
|
|
1761
|
+
cursorIndex: Number.POSITIVE_INFINITY,
|
|
1762
|
+
groupIndex: Number.POSITIVE_INFINITY,
|
|
1763
|
+
occurrenceIndex: Number.POSITIVE_INFINITY,
|
|
1764
|
+
cursorTime: object.endTime,
|
|
1765
|
+
};
|
|
1766
|
+
}
|
|
1767
|
+
return {
|
|
1768
|
+
position: nearestPosition,
|
|
1769
|
+
cursorIndex: nearestCursorIndex,
|
|
1770
|
+
groupIndex: nearestGroupIndex,
|
|
1771
|
+
occurrenceIndex: nearestCursorGroupIndex,
|
|
1772
|
+
cursorTime: nearestCursorTime,
|
|
1773
|
+
};
|
|
1774
|
+
}
|
|
1775
|
+
/**
|
|
1776
|
+
* Checks whether a slider was cheesed.
|
|
1777
|
+
*
|
|
1778
|
+
* This is done by checking if a cursor follows a slider all the way to its end position.
|
|
1779
|
+
*
|
|
1780
|
+
* @param indexedHitObject The indexed slider.
|
|
1781
|
+
* @param hitData The hit data of the slider.
|
|
1782
|
+
* @returns Whether the slider was cheesed.
|
|
1783
|
+
*/
|
|
1784
|
+
checkSliderCheesing(indexedHitObject, hitData) {
|
|
1785
|
+
if (!(indexedHitObject.object.object instanceof osuBase.Slider) ||
|
|
1786
|
+
hitData.result === exports.HitResult.miss ||
|
|
1787
|
+
indexedHitObject.cursorIndex === -1) {
|
|
1788
|
+
return false;
|
|
1789
|
+
}
|
|
1790
|
+
return false;
|
|
1791
|
+
}
|
|
1660
1792
|
}
|
|
1661
1793
|
|
|
1662
|
-
/**
|
|
1663
|
-
*
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
/**
|
|
1671
|
-
* The
|
|
1672
|
-
*/
|
|
1673
|
-
|
|
1674
|
-
/**
|
|
1675
|
-
* The
|
|
1676
|
-
*/
|
|
1677
|
-
|
|
1678
|
-
/**
|
|
1679
|
-
* The
|
|
1680
|
-
*/
|
|
1681
|
-
|
|
1682
|
-
/**
|
|
1683
|
-
*
|
|
1684
|
-
*/
|
|
1685
|
-
|
|
1686
|
-
/**
|
|
1687
|
-
*
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
*
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
}
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
resultObject.
|
|
2018
|
-
resultObject.
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
break;
|
|
2042
|
-
case hit300Ratio > 0.
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
let
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
const
|
|
2089
|
-
const
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
1794
|
+
/**
|
|
1795
|
+
* Utility to check whether relevant sliders in a beatmap are cheesed.
|
|
1796
|
+
*/
|
|
1797
|
+
class SliderCheeseChecker {
|
|
1798
|
+
/**
|
|
1799
|
+
* The difficulty calculator that is being analyzed.
|
|
1800
|
+
*/
|
|
1801
|
+
calculator;
|
|
1802
|
+
/**
|
|
1803
|
+
* The data of the replay.
|
|
1804
|
+
*/
|
|
1805
|
+
data;
|
|
1806
|
+
/**
|
|
1807
|
+
* The osu!droid hitwindow of the analyzed beatmap.
|
|
1808
|
+
*/
|
|
1809
|
+
hitWindow;
|
|
1810
|
+
/**
|
|
1811
|
+
* The 50 osu!droid hit window of the analyzed beatmap.
|
|
1812
|
+
*/
|
|
1813
|
+
hitWindow50;
|
|
1814
|
+
/**
|
|
1815
|
+
* The indexes of objects that were cheesed.
|
|
1816
|
+
*/
|
|
1817
|
+
cheesedObjectIndexes = [];
|
|
1818
|
+
/**
|
|
1819
|
+
* @param calculator The difficulty calculator to analyze.
|
|
1820
|
+
* @param data The data of the replay.
|
|
1821
|
+
*/
|
|
1822
|
+
constructor(calculator, data) {
|
|
1823
|
+
this.calculator = calculator;
|
|
1824
|
+
this.data = data;
|
|
1825
|
+
const stats = new osuBase.MapStats({
|
|
1826
|
+
od: this.calculator.beatmap.difficulty.od,
|
|
1827
|
+
mods: this.calculator.mods.filter((m) => m.isApplicableToDroid() &&
|
|
1828
|
+
!osuBase.ModUtil.speedChangingMods.some((v) => v.acronym === m.acronym)),
|
|
1829
|
+
}).calculate();
|
|
1830
|
+
this.hitWindow = new osuBase.DroidHitWindow(stats.od);
|
|
1831
|
+
this.hitWindow50 = this.hitWindow.hitWindowFor50(calculator.mods.some((m) => m instanceof osuBase.ModPrecise));
|
|
1832
|
+
}
|
|
1833
|
+
/**
|
|
1834
|
+
* Checks if relevant sliders in the given beatmap was cheesed.
|
|
1835
|
+
*
|
|
1836
|
+
* Returns a number that can be passed to a `DroidPerformanceCalculator`
|
|
1837
|
+
* to alter the aim performance value.
|
|
1838
|
+
*/
|
|
1839
|
+
check() {
|
|
1840
|
+
if (this.calculator.attributes.sliderCount === 0) {
|
|
1841
|
+
return {
|
|
1842
|
+
aimPenalty: 1,
|
|
1843
|
+
flashlightPenalty: 1,
|
|
1844
|
+
visualPenalty: 1,
|
|
1845
|
+
};
|
|
1846
|
+
}
|
|
1847
|
+
this.checkSliderCheesing();
|
|
1848
|
+
return this.calculateSliderCheesePenalty();
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* Checks for sliders that were cheesed.
|
|
1852
|
+
*/
|
|
1853
|
+
checkSliderCheesing() {
|
|
1854
|
+
// Current loop indexes are stored for efficiency.
|
|
1855
|
+
const cursorLoopIndexes = osuBase.Utils.initializeArray(10, 0);
|
|
1856
|
+
const acceptableRadius = this.calculator.objects[0].object.getRadius(osuBase.Modes.droid) * 2;
|
|
1857
|
+
for (let i = 0; i < this.calculator.objects.length; ++i) {
|
|
1858
|
+
const diffObject = this.calculator.objects[i];
|
|
1859
|
+
const { object } = diffObject;
|
|
1860
|
+
if (diffObject.travelDistance === 0 ||
|
|
1861
|
+
!(object instanceof osuBase.Slider)) {
|
|
1862
|
+
continue;
|
|
1863
|
+
}
|
|
1864
|
+
const objectStartPosition = object.getStackedPosition(osuBase.Modes.droid);
|
|
1865
|
+
const objectData = this.data.hitObjectData[i];
|
|
1866
|
+
// If a slider break occurs, we disregard the check for that slider.
|
|
1867
|
+
if (objectData.accuracy === Math.floor(this.hitWindow50) + 13) {
|
|
1868
|
+
continue;
|
|
1869
|
+
}
|
|
1870
|
+
let isCheesed = false;
|
|
1871
|
+
for (let j = 0; j < this.data.cursorMovement.length; ++j) {
|
|
1872
|
+
if (isCheesed) {
|
|
1873
|
+
break;
|
|
1874
|
+
}
|
|
1875
|
+
const cursorGroups = this.data.cursorMovement[j].occurrenceGroups;
|
|
1876
|
+
for (let k = cursorLoopIndexes[j]; k < cursorGroups.length; k = ++cursorLoopIndexes[j]) {
|
|
1877
|
+
const group = cursorGroups[k];
|
|
1878
|
+
if (group.startTime < object.startTime - this.hitWindow50) {
|
|
1879
|
+
continue;
|
|
1880
|
+
}
|
|
1881
|
+
if (group.startTime > object.startTime + this.hitWindow50) {
|
|
1882
|
+
break;
|
|
1883
|
+
}
|
|
1884
|
+
if (group.down.position.getDistance(objectStartPosition) >
|
|
1885
|
+
acceptableRadius) {
|
|
1886
|
+
continue;
|
|
1887
|
+
}
|
|
1888
|
+
// Track cursor movement to see if it lands on every tick.
|
|
1889
|
+
let occurrenceLoopIndex = 1;
|
|
1890
|
+
let isSliderFulfilled = true;
|
|
1891
|
+
const { allOccurrences } = group;
|
|
1892
|
+
for (let l = 1; l < object.nestedHitObjects.length; ++l) {
|
|
1893
|
+
if (!isSliderFulfilled) {
|
|
1894
|
+
break;
|
|
1895
|
+
}
|
|
1896
|
+
const tickWasHit = objectData.tickset[l - 1];
|
|
1897
|
+
if (!tickWasHit) {
|
|
1898
|
+
continue;
|
|
1899
|
+
}
|
|
1900
|
+
const nestedObject = object.nestedHitObjects[l];
|
|
1901
|
+
const nestedPosition = nestedObject.getStackedPosition(osuBase.Modes.droid);
|
|
1902
|
+
while (occurrenceLoopIndex < allOccurrences.length &&
|
|
1903
|
+
allOccurrences[occurrenceLoopIndex].time <
|
|
1904
|
+
nestedObject.startTime) {
|
|
1905
|
+
++occurrenceLoopIndex;
|
|
1906
|
+
}
|
|
1907
|
+
if (occurrenceLoopIndex === allOccurrences.length) {
|
|
1908
|
+
continue;
|
|
1909
|
+
}
|
|
1910
|
+
const occurrence = allOccurrences[occurrenceLoopIndex];
|
|
1911
|
+
const prevOccurrence = allOccurrences[occurrenceLoopIndex - 1];
|
|
1912
|
+
switch (occurrence.id) {
|
|
1913
|
+
case exports.MovementType.move: {
|
|
1914
|
+
// Interpolate cursor position during nested object time.
|
|
1915
|
+
const t = (nestedObject.startTime -
|
|
1916
|
+
prevOccurrence.time) /
|
|
1917
|
+
(occurrence.time - prevOccurrence.time);
|
|
1918
|
+
const cursorPosition = new osuBase.Vector2(osuBase.Interpolation.lerp(prevOccurrence.position.x, occurrence.position.x, t), osuBase.Interpolation.lerp(prevOccurrence.position.y, occurrence.position.y, t));
|
|
1919
|
+
const distance = cursorPosition.getDistance(nestedPosition);
|
|
1920
|
+
if (distance > acceptableRadius) {
|
|
1921
|
+
isSliderFulfilled = false;
|
|
1922
|
+
}
|
|
1923
|
+
break;
|
|
1924
|
+
}
|
|
1925
|
+
case exports.MovementType.up:
|
|
1926
|
+
if (prevOccurrence.position.getDistance(nestedPosition) > acceptableRadius) {
|
|
1927
|
+
isSliderFulfilled = false;
|
|
1928
|
+
break;
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
if (!isSliderFulfilled) {
|
|
1933
|
+
isCheesed = true;
|
|
1934
|
+
break;
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
}
|
|
1938
|
+
if (isCheesed) {
|
|
1939
|
+
this.cheesedObjectIndexes.push(i);
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
}
|
|
1943
|
+
/**
|
|
1944
|
+
* Calculates the slider cheese penalty.
|
|
1945
|
+
*/
|
|
1946
|
+
calculateSliderCheesePenalty() {
|
|
1947
|
+
let calculator;
|
|
1948
|
+
if (this.calculator instanceof osuDifficultyCalculator.DroidDifficultyCalculator) {
|
|
1949
|
+
calculator = new osuDifficultyCalculator.DroidDifficultyCalculator(this.calculator.beatmap);
|
|
1950
|
+
}
|
|
1951
|
+
else {
|
|
1952
|
+
calculator = new osuRebalanceDifficultyCalculator.DroidDifficultyCalculator(this.calculator.beatmap);
|
|
1953
|
+
}
|
|
1954
|
+
Object.assign(calculator.attributes, this.calculator.attributes);
|
|
1955
|
+
calculator.stats = this.calculator.stats;
|
|
1956
|
+
calculator.generateDifficultyHitObjects();
|
|
1957
|
+
for (const index of this.cheesedObjectIndexes) {
|
|
1958
|
+
calculator.objects[index].travelDistance = 0;
|
|
1959
|
+
}
|
|
1960
|
+
calculator.calculateAll();
|
|
1961
|
+
return {
|
|
1962
|
+
aimPenalty: this.calculator.aim / calculator.aim,
|
|
1963
|
+
flashlightPenalty: this.calculator.flashlight / calculator.flashlight,
|
|
1964
|
+
visualPenalty: this.calculator.visual / calculator.visual,
|
|
1965
|
+
};
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* A replay analyzer that analyzes a replay from osu!droid.
|
|
1971
|
+
*
|
|
1972
|
+
* Created by reverse engineering the replay parser from the game itself, which can be found {@link https://github.com/osudroid/osu-droid/blob/master/src/ru/nsu/ccfit/zuev/osu/scoring/Replay.java here}.
|
|
1973
|
+
*
|
|
1974
|
+
* Once analyzed, the result can be accessed via the `data` property.
|
|
1975
|
+
*/
|
|
1976
|
+
class ReplayAnalyzer {
|
|
1977
|
+
/**
|
|
1978
|
+
* The score ID of the replay.
|
|
1979
|
+
*/
|
|
1980
|
+
scoreID;
|
|
1981
|
+
/**
|
|
1982
|
+
* The original odr file of the replay.
|
|
1983
|
+
*/
|
|
1984
|
+
originalODR = null;
|
|
1985
|
+
/**
|
|
1986
|
+
* The fixed odr file of the replay.
|
|
1987
|
+
*/
|
|
1988
|
+
fixedODR = null;
|
|
1989
|
+
/**
|
|
1990
|
+
* Whether or not the play is considered using >=3 finger abuse.
|
|
1991
|
+
*/
|
|
1992
|
+
is3Finger;
|
|
1993
|
+
/**
|
|
1994
|
+
* Whether or not the play is considered 2-handed.
|
|
1995
|
+
*/
|
|
1996
|
+
is2Hand;
|
|
1997
|
+
/**
|
|
1998
|
+
* The beatmap that is being analyzed. `DroidDifficultyCalculator` or `RebalanceDroidDifficultyCalculator` is required for three finger or two hand analyzing.
|
|
1999
|
+
*/
|
|
2000
|
+
beatmap;
|
|
2001
|
+
/**
|
|
2002
|
+
* The results of the analyzer. `null` when initialized.
|
|
2003
|
+
*/
|
|
2004
|
+
data = null;
|
|
2005
|
+
/**
|
|
2006
|
+
* Penalty value used to penalize dpp for 2-hand.
|
|
2007
|
+
*/
|
|
2008
|
+
aimPenalty = 1;
|
|
2009
|
+
/**
|
|
2010
|
+
* Penalty value used to penalize dpp for 3 finger abuse.
|
|
2011
|
+
*/
|
|
2012
|
+
tapPenalty = 1;
|
|
2013
|
+
/**
|
|
2014
|
+
* Penalty values used to penalize dpp for slider cheesing.
|
|
2015
|
+
*/
|
|
2016
|
+
sliderCheesePenalty = {
|
|
2017
|
+
aimPenalty: 1,
|
|
2018
|
+
flashlightPenalty: 1,
|
|
2019
|
+
visualPenalty: 1,
|
|
2020
|
+
};
|
|
2021
|
+
/**
|
|
2022
|
+
* Whether this replay has been checked against 3 finger usage.
|
|
2023
|
+
*/
|
|
2024
|
+
hasBeenCheckedFor3Finger = false;
|
|
2025
|
+
/**
|
|
2026
|
+
* Whether this replay has been checked against 2 hand usage.
|
|
2027
|
+
*/
|
|
2028
|
+
hasBeenCheckedFor2Hand = false;
|
|
2029
|
+
/**
|
|
2030
|
+
* Whether this repla has been checked against slider cheesing.
|
|
2031
|
+
*/
|
|
2032
|
+
hasBeenCheckedForSliderCheesing = false;
|
|
2033
|
+
/**
|
|
2034
|
+
* The amount of two-handed objects.
|
|
2035
|
+
*/
|
|
2036
|
+
twoHandedNoteCount = 0;
|
|
2037
|
+
// Sizes of primitive data types in Java (in bytes)
|
|
2038
|
+
BYTE_LENGTH = 1;
|
|
2039
|
+
SHORT_LENGTH = 2;
|
|
2040
|
+
INT_LENGTH = 4;
|
|
2041
|
+
FLOAT_LENGTH = 4;
|
|
2042
|
+
LONG_LENGTH = 8;
|
|
2043
|
+
constructor(values) {
|
|
2044
|
+
this.scoreID = values.scoreID;
|
|
2045
|
+
this.beatmap = values.map;
|
|
2046
|
+
}
|
|
2047
|
+
/**
|
|
2048
|
+
* Analyzes a replay.
|
|
2049
|
+
*/
|
|
2050
|
+
async analyze() {
|
|
2051
|
+
if (!this.originalODR && !this.fixedODR) {
|
|
2052
|
+
this.originalODR = await this.downloadReplay();
|
|
2053
|
+
}
|
|
2054
|
+
if (!this.originalODR) {
|
|
2055
|
+
return this;
|
|
2056
|
+
}
|
|
2057
|
+
if (!this.fixedODR) {
|
|
2058
|
+
this.fixedODR = await this.decompress().catch(() => null);
|
|
2059
|
+
}
|
|
2060
|
+
if (!this.fixedODR) {
|
|
2061
|
+
return this;
|
|
2062
|
+
}
|
|
2063
|
+
this.parseReplay();
|
|
2064
|
+
return this;
|
|
2065
|
+
}
|
|
2066
|
+
/**
|
|
2067
|
+
* Downloads the given score ID's replay.
|
|
2068
|
+
*/
|
|
2069
|
+
async downloadReplay() {
|
|
2070
|
+
const apiRequestBuilder = new osuBase.DroidAPIRequestBuilder()
|
|
2071
|
+
.setRequireAPIkey(false)
|
|
2072
|
+
.setEndpoint("upload")
|
|
2073
|
+
.addParameter("", `${this.scoreID}.odr`);
|
|
2074
|
+
const result = await apiRequestBuilder.sendRequest();
|
|
2075
|
+
if (result.statusCode !== 200) {
|
|
2076
|
+
return null;
|
|
2077
|
+
}
|
|
2078
|
+
return result.data;
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* Decompresses a replay.
|
|
2082
|
+
*
|
|
2083
|
+
* The decompressed replay is in a form of Java object. This will be converted to a buffer and deserialized to read data from the replay.
|
|
2084
|
+
*/
|
|
2085
|
+
decompress() {
|
|
2086
|
+
return new Promise((resolve, reject) => {
|
|
2087
|
+
const stream$1 = new stream.Readable();
|
|
2088
|
+
stream$1.push(this.originalODR);
|
|
2089
|
+
stream$1.push(null);
|
|
2090
|
+
stream$1
|
|
2091
|
+
.pipe(unzipper.Parse())
|
|
2092
|
+
.on("entry", async (entry) => {
|
|
2093
|
+
const fileName = entry.path;
|
|
2094
|
+
if (fileName === "data") {
|
|
2095
|
+
return resolve(await entry.buffer());
|
|
2096
|
+
}
|
|
2097
|
+
else {
|
|
2098
|
+
entry.autodrain();
|
|
2099
|
+
}
|
|
2100
|
+
})
|
|
2101
|
+
.on("error", (e) => {
|
|
2102
|
+
setTimeout(() => reject(e), 2000);
|
|
2103
|
+
});
|
|
2104
|
+
});
|
|
2105
|
+
}
|
|
2106
|
+
/**
|
|
2107
|
+
* Parses a replay after being downloaded and converted to a buffer.
|
|
2108
|
+
*/
|
|
2109
|
+
parseReplay() {
|
|
2110
|
+
// javaDeserialization can only somewhat parse some string field
|
|
2111
|
+
// the rest will be a buffer that we need to manually parse
|
|
2112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
2113
|
+
let rawObject;
|
|
2114
|
+
try {
|
|
2115
|
+
rawObject = javaDeserialization__namespace.parse(this.fixedODR);
|
|
2116
|
+
}
|
|
2117
|
+
catch {
|
|
2118
|
+
return;
|
|
2119
|
+
}
|
|
2120
|
+
const resultObject = {
|
|
2121
|
+
replayVersion: rawObject[0].version,
|
|
2122
|
+
folderName: rawObject[1],
|
|
2123
|
+
fileName: rawObject[2],
|
|
2124
|
+
hash: rawObject[3],
|
|
2125
|
+
cursorMovement: [],
|
|
2126
|
+
hitObjectData: [],
|
|
2127
|
+
};
|
|
2128
|
+
if (resultObject.replayVersion >= 3) {
|
|
2129
|
+
resultObject.time = new Date(Number(rawObject[4].readBigUInt64BE(0)));
|
|
2130
|
+
resultObject.hit300k = rawObject[4].readInt32BE(8);
|
|
2131
|
+
resultObject.hit100k = rawObject[4].readInt32BE(16);
|
|
2132
|
+
resultObject.score = rawObject[4].readInt32BE(32);
|
|
2133
|
+
resultObject.maxCombo = rawObject[4].readInt32BE(36);
|
|
2134
|
+
resultObject.accuracy = new osuBase.Accuracy({
|
|
2135
|
+
n300: rawObject[4].readInt32BE(12),
|
|
2136
|
+
n100: rawObject[4].readInt32BE(20),
|
|
2137
|
+
n50: rawObject[4].readInt32BE(24),
|
|
2138
|
+
nmiss: rawObject[4].readInt32BE(28),
|
|
2139
|
+
});
|
|
2140
|
+
resultObject.isFullCombo = !!rawObject[4][44];
|
|
2141
|
+
resultObject.playerName = rawObject[5];
|
|
2142
|
+
resultObject.rawMods = rawObject[6].elements;
|
|
2143
|
+
resultObject.convertedMods = osuBase.ModUtil.droidStringToMods(this.convertDroidMods(rawObject[6].elements));
|
|
2144
|
+
// Determine rank
|
|
2145
|
+
const totalHits = resultObject.accuracy.n300 +
|
|
2146
|
+
resultObject.accuracy.n100 +
|
|
2147
|
+
resultObject.accuracy.n50 +
|
|
2148
|
+
resultObject.accuracy.nmiss;
|
|
2149
|
+
const isHidden = resultObject.convertedMods.some((m) => m instanceof osuBase.ModHidden || m instanceof osuBase.ModFlashlight);
|
|
2150
|
+
const hit300Ratio = resultObject.accuracy.n300 / totalHits;
|
|
2151
|
+
switch (true) {
|
|
2152
|
+
case resultObject.accuracy.value() === 1:
|
|
2153
|
+
if (isHidden) {
|
|
2154
|
+
resultObject.rank = "XH";
|
|
2155
|
+
}
|
|
2156
|
+
else {
|
|
2157
|
+
resultObject.rank = "X";
|
|
2158
|
+
}
|
|
2159
|
+
break;
|
|
2160
|
+
case hit300Ratio > 0.9 &&
|
|
2161
|
+
resultObject.accuracy.n50 / totalHits < 0.01 &&
|
|
2162
|
+
!resultObject.accuracy.nmiss:
|
|
2163
|
+
if (isHidden) {
|
|
2164
|
+
resultObject.rank = "SH";
|
|
2165
|
+
}
|
|
2166
|
+
else {
|
|
2167
|
+
resultObject.rank = "S";
|
|
2168
|
+
}
|
|
2169
|
+
break;
|
|
2170
|
+
case (hit300Ratio > 0.8 && !resultObject.accuracy.nmiss) ||
|
|
2171
|
+
hit300Ratio > 0.9:
|
|
2172
|
+
resultObject.rank = "A";
|
|
2173
|
+
break;
|
|
2174
|
+
case (hit300Ratio > 0.7 && !resultObject.accuracy.nmiss) ||
|
|
2175
|
+
hit300Ratio > 0.8:
|
|
2176
|
+
resultObject.rank = "B";
|
|
2177
|
+
break;
|
|
2178
|
+
case hit300Ratio > 0.6:
|
|
2179
|
+
resultObject.rank = "C";
|
|
2180
|
+
break;
|
|
2181
|
+
default:
|
|
2182
|
+
resultObject.rank = "D";
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
if (resultObject.replayVersion >= 4) {
|
|
2186
|
+
const s = rawObject[7].split("|");
|
|
2187
|
+
resultObject.speedModification =
|
|
2188
|
+
parseFloat(s[0].replace("x", "")) || 1;
|
|
2189
|
+
if (s.length > 1) {
|
|
2190
|
+
resultObject.forcedAR = parseFloat(s[1].replace("AR", ""));
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
let bufferIndex;
|
|
2194
|
+
switch (true) {
|
|
2195
|
+
// replay v4 and above
|
|
2196
|
+
case resultObject.replayVersion >= 4:
|
|
2197
|
+
bufferIndex = 8;
|
|
2198
|
+
break;
|
|
2199
|
+
// replay v3
|
|
2200
|
+
case resultObject.replayVersion === 3:
|
|
2201
|
+
bufferIndex = 7;
|
|
2202
|
+
break;
|
|
2203
|
+
// replay v1 and v2
|
|
2204
|
+
default:
|
|
2205
|
+
bufferIndex = 4;
|
|
2206
|
+
}
|
|
2207
|
+
const replayDataBufferArray = [];
|
|
2208
|
+
while (bufferIndex < rawObject.length) {
|
|
2209
|
+
replayDataBufferArray.push(rawObject[bufferIndex++]);
|
|
2210
|
+
}
|
|
2211
|
+
// Merge all cursor movement and hit object data section into one for better control when parsing
|
|
2212
|
+
const replayDataBuffer = Buffer.concat(replayDataBufferArray);
|
|
2213
|
+
let bufferCounter = 0;
|
|
2214
|
+
const size = replayDataBuffer.readInt32BE(bufferCounter);
|
|
2215
|
+
bufferCounter += this.INT_LENGTH;
|
|
2216
|
+
// Parse movement data
|
|
2217
|
+
for (let x = 0; x < size; x++) {
|
|
2218
|
+
const moveSize = replayDataBuffer.readInt32BE(bufferCounter);
|
|
2219
|
+
bufferCounter += this.INT_LENGTH;
|
|
2220
|
+
const time = [];
|
|
2221
|
+
const x = [];
|
|
2222
|
+
const y = [];
|
|
2223
|
+
const id = [];
|
|
2224
|
+
for (let i = 0; i < moveSize; i++) {
|
|
2225
|
+
time[i] = replayDataBuffer.readInt32BE(bufferCounter);
|
|
2226
|
+
bufferCounter += this.INT_LENGTH;
|
|
2227
|
+
id[i] = time[i] & 3;
|
|
2228
|
+
time[i] >>= 2;
|
|
2229
|
+
if (id[i] !== exports.MovementType.up) {
|
|
2230
|
+
if (resultObject.replayVersion >= 5) {
|
|
2231
|
+
x[i] = replayDataBuffer.readFloatBE(bufferCounter);
|
|
2232
|
+
bufferCounter += this.FLOAT_LENGTH;
|
|
2233
|
+
y[i] = replayDataBuffer.readFloatBE(bufferCounter);
|
|
2234
|
+
bufferCounter += this.FLOAT_LENGTH;
|
|
2235
|
+
}
|
|
2236
|
+
else {
|
|
2237
|
+
x[i] = replayDataBuffer.readInt16BE(bufferCounter);
|
|
2238
|
+
bufferCounter += this.SHORT_LENGTH;
|
|
2239
|
+
y[i] = replayDataBuffer.readInt16BE(bufferCounter);
|
|
2240
|
+
bufferCounter += this.SHORT_LENGTH;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
else {
|
|
2244
|
+
x[i] = -1;
|
|
2245
|
+
y[i] = -1;
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
resultObject.cursorMovement.push(new CursorData({
|
|
2249
|
+
size: moveSize,
|
|
2250
|
+
time: time,
|
|
2251
|
+
x: x,
|
|
2252
|
+
y: y,
|
|
2253
|
+
id: id,
|
|
2254
|
+
}));
|
|
2255
|
+
}
|
|
2256
|
+
const replayObjectLength = replayDataBuffer.readInt32BE(bufferCounter);
|
|
2257
|
+
bufferCounter += this.INT_LENGTH;
|
|
2258
|
+
// Parse result data
|
|
2259
|
+
for (let i = 0; i < replayObjectLength; i++) {
|
|
2260
|
+
const replayObjectData = {
|
|
2261
|
+
accuracy: 0,
|
|
2262
|
+
tickset: [],
|
|
2263
|
+
result: 0,
|
|
2264
|
+
};
|
|
2265
|
+
replayObjectData.accuracy =
|
|
2266
|
+
replayDataBuffer.readInt16BE(bufferCounter);
|
|
2267
|
+
bufferCounter += this.SHORT_LENGTH;
|
|
2268
|
+
const len = replayDataBuffer.readInt8(bufferCounter);
|
|
2269
|
+
bufferCounter += this.BYTE_LENGTH;
|
|
2270
|
+
if (len > 0) {
|
|
2271
|
+
const bytes = [];
|
|
2272
|
+
for (let j = 0; j < len; j++) {
|
|
2273
|
+
bytes.push(replayDataBuffer.readInt8(bufferCounter));
|
|
2274
|
+
bufferCounter += this.BYTE_LENGTH;
|
|
2275
|
+
}
|
|
2276
|
+
// Int/int division in Java; numbers must be truncated to get actual number
|
|
2277
|
+
for (let j = 0; j < len * 8; j++) {
|
|
2278
|
+
replayObjectData.tickset.push((bytes[len - Math.trunc(j / 8) - 1] &
|
|
2279
|
+
(1 << Math.trunc(j % 8))) !==
|
|
2280
|
+
0);
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
if (resultObject.replayVersion >= 1) {
|
|
2284
|
+
replayObjectData.result =
|
|
2285
|
+
replayDataBuffer.readInt8(bufferCounter);
|
|
2286
|
+
bufferCounter += this.BYTE_LENGTH;
|
|
2287
|
+
}
|
|
2288
|
+
resultObject.hitObjectData.push(replayObjectData);
|
|
2289
|
+
}
|
|
2290
|
+
// Parse max combo, hit results, and accuracy in old replay version
|
|
2291
|
+
if (resultObject.replayVersion < 3 && this.beatmap) {
|
|
2292
|
+
let hit300 = 0;
|
|
2293
|
+
let hit300k = 0;
|
|
2294
|
+
let hit100 = 0;
|
|
2295
|
+
let hit100k = 0;
|
|
2296
|
+
let hit50 = 0;
|
|
2297
|
+
let hit0 = 0;
|
|
2298
|
+
let grantsGekiOrKatu = true;
|
|
2299
|
+
const objects = (this.beatmap instanceof osuDifficultyCalculator.DroidDifficultyCalculator ||
|
|
2300
|
+
this.beatmap instanceof osuRebalanceDifficultyCalculator.DroidDifficultyCalculator
|
|
2301
|
+
? this.beatmap.beatmap
|
|
2302
|
+
: this.beatmap).hitObjects.objects;
|
|
2303
|
+
for (let i = 0; i < resultObject.hitObjectData.length; ++i) {
|
|
2304
|
+
// Hit result
|
|
2305
|
+
const hitObjectData = resultObject.hitObjectData[i];
|
|
2306
|
+
const isNextNewCombo = i + 1 !== objects.length ? objects[i + 1].isNewCombo : true;
|
|
2307
|
+
switch (hitObjectData.result) {
|
|
2308
|
+
case exports.HitResult.miss:
|
|
2309
|
+
++hit0;
|
|
2310
|
+
grantsGekiOrKatu = false;
|
|
2311
|
+
break;
|
|
2312
|
+
case exports.HitResult.meh:
|
|
2313
|
+
++hit50;
|
|
2314
|
+
grantsGekiOrKatu = false;
|
|
2315
|
+
break;
|
|
2316
|
+
case exports.HitResult.good:
|
|
2317
|
+
++hit100;
|
|
2318
|
+
if (grantsGekiOrKatu && isNextNewCombo) {
|
|
2319
|
+
++hit100k;
|
|
2320
|
+
}
|
|
2321
|
+
break;
|
|
2322
|
+
case exports.HitResult.great:
|
|
2323
|
+
++hit300;
|
|
2324
|
+
if (grantsGekiOrKatu && isNextNewCombo) {
|
|
2325
|
+
++hit300k;
|
|
2326
|
+
}
|
|
2327
|
+
break;
|
|
2328
|
+
}
|
|
2329
|
+
if (isNextNewCombo) {
|
|
2330
|
+
grantsGekiOrKatu = true;
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
resultObject.hit300k = hit300k;
|
|
2334
|
+
resultObject.hit100k = hit100k;
|
|
2335
|
+
resultObject.accuracy = new osuBase.Accuracy({
|
|
2336
|
+
n300: hit300,
|
|
2337
|
+
n100: hit100,
|
|
2338
|
+
n50: hit50,
|
|
2339
|
+
nmiss: hit0,
|
|
2340
|
+
nobjects: hit300 + hit100 + hit50 + hit0,
|
|
2341
|
+
});
|
|
2342
|
+
// Determine rank
|
|
2343
|
+
const totalHits = resultObject.accuracy.n300 +
|
|
2344
|
+
resultObject.accuracy.n100 +
|
|
2345
|
+
resultObject.accuracy.n50 +
|
|
2346
|
+
resultObject.accuracy.nmiss;
|
|
2347
|
+
const isHidden = resultObject.convertedMods?.some((m) => m instanceof osuBase.ModHidden || m instanceof osuBase.ModFlashlight) ?? false;
|
|
2348
|
+
const hit300Ratio = resultObject.accuracy.n300 / totalHits;
|
|
2349
|
+
switch (true) {
|
|
2350
|
+
case resultObject.accuracy.value() === 1:
|
|
2351
|
+
if (isHidden) {
|
|
2352
|
+
resultObject.rank = "XH";
|
|
2353
|
+
}
|
|
2354
|
+
else {
|
|
2355
|
+
resultObject.rank = "X";
|
|
2356
|
+
}
|
|
2357
|
+
break;
|
|
2358
|
+
case hit300Ratio > 0.9 &&
|
|
2359
|
+
resultObject.accuracy.n50 / totalHits < 0.01 &&
|
|
2360
|
+
!resultObject.accuracy.nmiss:
|
|
2361
|
+
if (isHidden) {
|
|
2362
|
+
resultObject.rank = "SH";
|
|
2363
|
+
}
|
|
2364
|
+
else {
|
|
2365
|
+
resultObject.rank = "S";
|
|
2366
|
+
}
|
|
2367
|
+
break;
|
|
2368
|
+
case (hit300Ratio > 0.8 && !resultObject.accuracy.nmiss) ||
|
|
2369
|
+
hit300Ratio > 0.9:
|
|
2370
|
+
resultObject.rank = "A";
|
|
2371
|
+
break;
|
|
2372
|
+
case (hit300Ratio > 0.7 && !resultObject.accuracy.nmiss) ||
|
|
2373
|
+
hit300Ratio > 0.8:
|
|
2374
|
+
resultObject.rank = "B";
|
|
2375
|
+
break;
|
|
2376
|
+
case hit300Ratio > 0.6:
|
|
2377
|
+
resultObject.rank = "C";
|
|
2378
|
+
break;
|
|
2379
|
+
default:
|
|
2380
|
+
resultObject.rank = "D";
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
this.data = new ReplayData(resultObject);
|
|
2384
|
+
}
|
|
2385
|
+
/**
|
|
2386
|
+
* Gets hit error information of the replay.
|
|
2387
|
+
*
|
|
2388
|
+
* `analyze()` must be called before calling this.
|
|
2389
|
+
*/
|
|
2390
|
+
calculateHitError() {
|
|
2391
|
+
if (!this.data || !this.beatmap) {
|
|
2392
|
+
return null;
|
|
2393
|
+
}
|
|
2394
|
+
const hitObjectData = this.data.hitObjectData;
|
|
2395
|
+
let positiveCount = 0;
|
|
2396
|
+
let negativeCount = 0;
|
|
2397
|
+
let positiveTotal = 0;
|
|
2398
|
+
let negativeTotal = 0;
|
|
2399
|
+
const beatmap = this.beatmap instanceof osuDifficultyCalculator.DroidDifficultyCalculator ||
|
|
2400
|
+
this.beatmap instanceof osuRebalanceDifficultyCalculator.DroidDifficultyCalculator
|
|
2401
|
+
? this.beatmap.beatmap
|
|
2402
|
+
: this.beatmap;
|
|
2403
|
+
const objects = beatmap.hitObjects.objects;
|
|
2404
|
+
const stats = new osuBase.MapStats({
|
|
2405
|
+
od: beatmap.difficulty.od,
|
|
2406
|
+
mods: this.data.convertedMods.filter((m) => !osuBase.ModUtil.speedChangingMods.some((v) => v.acronym === m.acronym)),
|
|
2407
|
+
}).calculate();
|
|
2408
|
+
const hitWindow50 = new osuBase.DroidHitWindow(stats.od).hitWindowFor50(this.data.convertedMods.some((m) => m instanceof osuBase.ModPrecise));
|
|
2409
|
+
// The accuracy of sliders is set to (50 hit window)ms + 13ms if their head was not hit:
|
|
2410
|
+
// https://github.com/osudroid/osu-droid/blob/6306c68e3ffaf671eac794bf45cc95c0f3313a82/src/ru/nsu/ccfit/zuev/osu/game/Slider.java#L821
|
|
2411
|
+
//
|
|
2412
|
+
// In such cases, the slider is skipped.
|
|
2413
|
+
const sliderbreakHitOffset = Math.floor(hitWindow50) + 13;
|
|
2414
|
+
const accuracies = [];
|
|
2415
|
+
for (let i = 0; i < hitObjectData.length; ++i) {
|
|
2416
|
+
const v = hitObjectData[i];
|
|
2417
|
+
const o = objects[i];
|
|
2418
|
+
if (o instanceof osuBase.Spinner || v.result === exports.HitResult.miss) {
|
|
2419
|
+
accuracies.push(0);
|
|
2420
|
+
continue;
|
|
2421
|
+
}
|
|
2422
|
+
const accuracy = v.accuracy;
|
|
2423
|
+
if (o instanceof osuBase.Slider && v.accuracy === sliderbreakHitOffset) {
|
|
2424
|
+
accuracies.push(0);
|
|
2425
|
+
continue;
|
|
2426
|
+
}
|
|
2427
|
+
accuracies.push(accuracy);
|
|
2428
|
+
if (accuracy >= 0) {
|
|
2429
|
+
positiveTotal += accuracy;
|
|
2430
|
+
++positiveCount;
|
|
2431
|
+
}
|
|
2432
|
+
else {
|
|
2433
|
+
negativeTotal += accuracy;
|
|
2434
|
+
++negativeCount;
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
return {
|
|
2438
|
+
positiveAvg: positiveTotal / positiveCount || 0,
|
|
2439
|
+
negativeAvg: negativeTotal / negativeCount || 0,
|
|
2440
|
+
unstableRate: osuBase.MathUtils.calculateStandardDeviation(accuracies) * 10,
|
|
2441
|
+
};
|
|
2442
|
+
}
|
|
2443
|
+
/**
|
|
2444
|
+
* Converts replay mods to droid mod string.
|
|
2445
|
+
*/
|
|
2446
|
+
convertDroidMods(replayMods) {
|
|
2447
|
+
const replayModsConstants = {
|
|
2448
|
+
MOD_NOFAIL: "n",
|
|
2449
|
+
MOD_EASY: "e",
|
|
2450
|
+
MOD_HIDDEN: "h",
|
|
2451
|
+
MOD_HARDROCK: "r",
|
|
2452
|
+
MOD_DOUBLETIME: "d",
|
|
2453
|
+
MOD_HALFTIME: "t",
|
|
2454
|
+
MOD_NIGHTCORE: "c",
|
|
2455
|
+
MOD_PRECISE: "s",
|
|
2456
|
+
MOD_SMALLCIRCLE: "m",
|
|
2457
|
+
MOD_SPEEDUP: "b",
|
|
2458
|
+
MOD_REALLYEASY: "l",
|
|
2459
|
+
MOD_PERFECT: "f",
|
|
2460
|
+
MOD_SUDDENDEATH: "u",
|
|
2461
|
+
MOD_SCOREV2: "v",
|
|
2462
|
+
};
|
|
2463
|
+
let modString = "";
|
|
2464
|
+
for (const mod of replayMods) {
|
|
2465
|
+
for (const property in replayModsConstants) {
|
|
2466
|
+
if (!(property in replayModsConstants)) {
|
|
2467
|
+
continue;
|
|
2468
|
+
}
|
|
2469
|
+
if (!mod.includes(property)) {
|
|
2470
|
+
continue;
|
|
2471
|
+
}
|
|
2472
|
+
modString +=
|
|
2473
|
+
replayModsConstants[property];
|
|
2474
|
+
break;
|
|
2475
|
+
}
|
|
2476
|
+
}
|
|
2477
|
+
return modString;
|
|
2478
|
+
}
|
|
2479
|
+
/**
|
|
2480
|
+
* Checks if a play is using 3 fingers.
|
|
2481
|
+
*
|
|
2482
|
+
* Requires `analyze()` to be called first and `map` to be defined as `DroidDifficultyCalculator`.
|
|
2483
|
+
*/
|
|
2484
|
+
checkFor3Finger() {
|
|
2485
|
+
if (!(this.beatmap instanceof osuDifficultyCalculator.DroidDifficultyCalculator ||
|
|
2486
|
+
this.beatmap instanceof osuRebalanceDifficultyCalculator.DroidDifficultyCalculator) ||
|
|
2487
|
+
!this.data) {
|
|
2488
|
+
return;
|
|
2489
|
+
}
|
|
2490
|
+
const threeFingerChecker = new ThreeFingerChecker(this.beatmap, this.data);
|
|
2491
|
+
const result = threeFingerChecker.check();
|
|
2492
|
+
this.is3Finger = result.is3Finger;
|
|
2493
|
+
this.tapPenalty = result.penalty;
|
|
2494
|
+
this.hasBeenCheckedFor3Finger = true;
|
|
2495
|
+
}
|
|
2496
|
+
/**
|
|
2497
|
+
* Checks if a play is using 2 hands.
|
|
2498
|
+
*
|
|
2499
|
+
* Requires `analyze()` to be called first and `map` to be defined as `DroidDifficultyCalculator`.
|
|
2500
|
+
*/
|
|
2501
|
+
checkFor2Hand() {
|
|
2502
|
+
if (!(this.beatmap instanceof osuDifficultyCalculator.DroidDifficultyCalculator ||
|
|
2503
|
+
this.beatmap instanceof osuRebalanceDifficultyCalculator.DroidDifficultyCalculator) ||
|
|
2504
|
+
!this.data) {
|
|
2505
|
+
return;
|
|
2506
|
+
}
|
|
2507
|
+
const twoHandChecker = new TwoHandChecker(this.beatmap, this.data);
|
|
2508
|
+
const result = twoHandChecker.check();
|
|
2509
|
+
this.is2Hand = result.is2Hand;
|
|
2510
|
+
this.twoHandedNoteCount = result.twoHandedNoteCount;
|
|
2511
|
+
this.hasBeenCheckedFor2Hand = true;
|
|
2512
|
+
}
|
|
2513
|
+
/**
|
|
2514
|
+
* Checks if a play has cheesed sliders.
|
|
2515
|
+
*
|
|
2516
|
+
* Requires `analyze()` to be called first and `map` to be defined as `DroidDifficultyCalculator`.
|
|
2517
|
+
*/
|
|
2518
|
+
checkForSliderCheesing() {
|
|
2519
|
+
if (!(this.beatmap instanceof osuDifficultyCalculator.DroidDifficultyCalculator ||
|
|
2520
|
+
this.beatmap instanceof osuRebalanceDifficultyCalculator.DroidDifficultyCalculator) ||
|
|
2521
|
+
!this.data) {
|
|
2522
|
+
return;
|
|
2523
|
+
}
|
|
2524
|
+
const sliderCheeseChecker = new SliderCheeseChecker(this.beatmap, this.data);
|
|
2525
|
+
this.sliderCheesePenalty = sliderCheeseChecker.check();
|
|
2526
|
+
this.hasBeenCheckedForSliderCheesing = true;
|
|
2527
|
+
}
|
|
2182
2528
|
}
|
|
2183
2529
|
|
|
2184
|
-
/**
|
|
2185
|
-
* Represents a hitobject in an osu!droid replay.
|
|
2186
|
-
*
|
|
2187
|
-
* Stores information about hitobjects in an osu!droid replay such as hit offset, tickset, and hit result.
|
|
2188
|
-
*
|
|
2189
|
-
* This is used when analyzing replays using replay analyzer.
|
|
2190
|
-
*/
|
|
2191
|
-
class ReplayObjectData {
|
|
2192
|
-
/**
|
|
2193
|
-
*
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
*
|
|
2198
|
-
*
|
|
2199
|
-
*
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
*
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2530
|
+
/**
|
|
2531
|
+
* Represents a hitobject in an osu!droid replay.
|
|
2532
|
+
*
|
|
2533
|
+
* Stores information about hitobjects in an osu!droid replay such as hit offset, tickset, and hit result.
|
|
2534
|
+
*
|
|
2535
|
+
* This is used when analyzing replays using replay analyzer.
|
|
2536
|
+
*/
|
|
2537
|
+
class ReplayObjectData {
|
|
2538
|
+
/**
|
|
2539
|
+
* For circles, this is the offset at which the circle was hit. If the hit accuracy is 10000, it means the circle was tapped too late ([game source code](https://github.com/osudroid/osu-droid/blob/6306c68e3ffaf671eac794bf45cc95c0f3313a82/src/ru/nsu/ccfit/zuev/osu/game/HitCircle.java#L298-L306)).
|
|
2540
|
+
*
|
|
2541
|
+
* For sliders, this is the offset at which the slider head was hit. For
|
|
2542
|
+
* sliderbreaks, the accuracy would be `Math.floor(<hit window 50>ms) + 13ms` ([game source code](https://github.com/osudroid/osu-droid/blob/6306c68e3ffaf671eac794bf45cc95c0f3313a82/src/ru/nsu/ccfit/zuev/osu/game/Slider.java#L821)).
|
|
2543
|
+
*
|
|
2544
|
+
* For spinners, this is the total amount at which the spinner was spinned:
|
|
2545
|
+
* ```js
|
|
2546
|
+
* const rotations = Math.floor(data.accuracy / 4);
|
|
2547
|
+
* ```
|
|
2548
|
+
* The remainder of the division denotes the hit result of the spinner:
|
|
2549
|
+
* - `HitResult.great`: 3
|
|
2550
|
+
* - `HitResult.good`: 2
|
|
2551
|
+
* - `HitResult.meh`: 1
|
|
2552
|
+
* - `HitResult.miss`: 0
|
|
2553
|
+
*/
|
|
2554
|
+
accuracy;
|
|
2555
|
+
/**
|
|
2556
|
+
* The tickset of the hitobject.
|
|
2557
|
+
*
|
|
2558
|
+
* This is used to determine whether or not a slider event (tick, repeat, and end) is hit based on the order they appear.
|
|
2559
|
+
*/
|
|
2560
|
+
tickset;
|
|
2561
|
+
/**
|
|
2562
|
+
* The bitwise hit result of the hitobject.
|
|
2563
|
+
*/
|
|
2564
|
+
result;
|
|
2565
|
+
constructor(values) {
|
|
2566
|
+
this.accuracy = values.accuracy;
|
|
2567
|
+
this.tickset = values.tickset;
|
|
2568
|
+
this.result = values.result;
|
|
2569
|
+
}
|
|
2211
2570
|
}
|
|
2212
2571
|
|
|
2213
2572
|
exports.CursorData = CursorData;
|
|
@@ -2216,5 +2575,7 @@ exports.CursorOccurrenceGroup = CursorOccurrenceGroup;
|
|
|
2216
2575
|
exports.ReplayAnalyzer = ReplayAnalyzer;
|
|
2217
2576
|
exports.ReplayData = ReplayData;
|
|
2218
2577
|
exports.ReplayObjectData = ReplayObjectData;
|
|
2578
|
+
exports.SliderCheeseChecker = SliderCheeseChecker;
|
|
2219
2579
|
exports.ThreeFingerChecker = ThreeFingerChecker;
|
|
2580
|
+
exports.TwoHandChecker = TwoHandChecker;
|
|
2220
2581
|
//# sourceMappingURL=index.js.map
|