@rian8337/osu-droid-replay-analyzer 2.0.0-alpha.0 → 2.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +337 -195
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/typings/index.d.ts +108 -11
- package/dist/ReplayAnalyzer.js +0 -541
- package/dist/ReplayAnalyzer.js.map +0 -1
- package/dist/analysis/BeatmapSectionGenerator.js +0 -48
- package/dist/analysis/BeatmapSectionGenerator.js.map +0 -1
- package/dist/analysis/ThreeFingerChecker.js +0 -676
- package/dist/analysis/ThreeFingerChecker.js.map +0 -1
- package/dist/analysis/TwoHandChecker.js +0 -238
- package/dist/analysis/TwoHandChecker.js.map +0 -1
- package/dist/analysis/data/BeatmapSection.js +0 -18
- package/dist/analysis/data/BeatmapSection.js.map +0 -1
- package/dist/analysis/data/ThreeFingerBeatmapSection.js +0 -16
- package/dist/analysis/data/ThreeFingerBeatmapSection.js.map +0 -1
- package/dist/analysis/objects/IndexedHitObject.js +0 -18
- package/dist/analysis/objects/IndexedHitObject.js.map +0 -1
- package/dist/constants/hitResult.js +0 -26
- package/dist/constants/hitResult.js.map +0 -1
- package/dist/constants/movementType.js +0 -13
- package/dist/constants/movementType.js.map +0 -1
- package/dist/data/CursorData.js +0 -21
- package/dist/data/CursorData.js.map +0 -1
- package/dist/data/ReplayData.js +0 -36
- package/dist/data/ReplayData.js.map +0 -1
- package/dist/data/ReplayObjectData.js +0 -19
- package/dist/data/ReplayObjectData.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -29,25 +29,45 @@ function _interopNamespace(e) {
|
|
|
29
29
|
|
|
30
30
|
var javaDeserialization__namespace = /*#__PURE__*/_interopNamespace(javaDeserialization);
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Represents a cursor's occurrence.
|
|
34
|
+
*/
|
|
35
|
+
class CursorOccurrence {
|
|
36
|
+
/**
|
|
37
|
+
* The time of this occurrence.
|
|
38
|
+
*/
|
|
39
|
+
time;
|
|
40
|
+
/**
|
|
41
|
+
* The position of the occurrence.
|
|
42
|
+
*/
|
|
43
|
+
position;
|
|
44
|
+
/**
|
|
45
|
+
* The movement ID of the occurrence.
|
|
46
|
+
*/
|
|
47
|
+
id;
|
|
48
|
+
constructor(time, x, y, id) {
|
|
49
|
+
this.time = time;
|
|
50
|
+
this.position = new osuBase.Vector2(x, y);
|
|
51
|
+
this.id = id;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
32
55
|
/**
|
|
33
56
|
* Represents a cursor instance in an osu!droid replay.
|
|
34
57
|
*
|
|
35
|
-
* Stores cursor movement data
|
|
58
|
+
* Stores cursor movement data in the form of `CursorOccurrence`s.
|
|
36
59
|
*
|
|
37
60
|
* This is used when analyzing replays using replay analyzer.
|
|
38
61
|
*/
|
|
39
62
|
class CursorData {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
id;
|
|
63
|
+
/**
|
|
64
|
+
* The occurrences of this cursor instance.
|
|
65
|
+
*/
|
|
66
|
+
occurrences = [];
|
|
45
67
|
constructor(values) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.y = values.y;
|
|
50
|
-
this.id = values.id;
|
|
68
|
+
for (let i = 0; i < values.size; ++i) {
|
|
69
|
+
this.occurrences.push(new CursorOccurrence(values.time[i], values.x[i], values.y[i], values.id[i]));
|
|
70
|
+
}
|
|
51
71
|
}
|
|
52
72
|
}
|
|
53
73
|
|
|
@@ -352,14 +372,16 @@ class ThreeFingerChecker {
|
|
|
352
372
|
}
|
|
353
373
|
this.getAccurateBreakPoints();
|
|
354
374
|
this.filterCursorInstances();
|
|
355
|
-
if (this.downCursorInstances.filter((v) => v.
|
|
375
|
+
if (this.downCursorInstances.filter((v) => v.occurrences.length > 0)
|
|
376
|
+
.length <= 3) {
|
|
356
377
|
return { is3Finger: false, penalty: 1 };
|
|
357
378
|
}
|
|
358
379
|
this.getBeatmapSections();
|
|
359
380
|
this.detectDragPlay();
|
|
360
381
|
this.getDetailedBeatmapSections();
|
|
361
382
|
this.preventAccidentalTaps();
|
|
362
|
-
if (this.downCursorInstances.filter((v) => v.
|
|
383
|
+
if (this.downCursorInstances.filter((v) => v.occurrences.length > 0)
|
|
384
|
+
.length <= 3) {
|
|
363
385
|
return { is3Finger: false, penalty: 1 };
|
|
364
386
|
}
|
|
365
387
|
this.calculateNerfFactors();
|
|
@@ -478,22 +500,18 @@ class ThreeFingerChecker {
|
|
|
478
500
|
y: [],
|
|
479
501
|
id: [],
|
|
480
502
|
});
|
|
481
|
-
for (let j = 0; j < cursorInstance.
|
|
482
|
-
if (cursorInstance.
|
|
503
|
+
for (let j = 0; j < cursorInstance.occurrences.length; ++j) {
|
|
504
|
+
if (cursorInstance.occurrences[j].id !== exports.movementType.DOWN) {
|
|
483
505
|
continue;
|
|
484
506
|
}
|
|
485
|
-
const time = cursorInstance.
|
|
507
|
+
const time = cursorInstance.occurrences[j].time;
|
|
486
508
|
if (time < firstObjectHitTime || time > lastObjectHitTime) {
|
|
487
509
|
continue;
|
|
488
510
|
}
|
|
489
511
|
if (this.breakPointAccurateTimes.some((v) => time >= v.startTime && time <= v.endTime)) {
|
|
490
512
|
continue;
|
|
491
513
|
}
|
|
492
|
-
|
|
493
|
-
newCursorData.time.push(time);
|
|
494
|
-
newCursorData.x.push(cursorInstance.x[j]);
|
|
495
|
-
newCursorData.y.push(cursorInstance.y[j]);
|
|
496
|
-
newCursorData.id.push(cursorInstance.id[j]);
|
|
514
|
+
newCursorData.occurrences.push(new CursorOccurrence(time, cursorInstance.occurrences[j].position.x, cursorInstance.occurrences[j].position.y, cursorInstance.occurrences[j].id));
|
|
497
515
|
}
|
|
498
516
|
this.downCursorInstances.push(newCursorData);
|
|
499
517
|
}
|
|
@@ -579,16 +597,18 @@ class ThreeFingerChecker {
|
|
|
579
597
|
const cursorIndexes = [];
|
|
580
598
|
for (let i = 0; i < this.data.cursorMovement.length; ++i) {
|
|
581
599
|
const c = this.data.cursorMovement[i];
|
|
582
|
-
if (c.
|
|
600
|
+
if (c.occurrences.length === 0) {
|
|
583
601
|
continue;
|
|
584
602
|
}
|
|
585
603
|
// Do not include cursors that don't have an occurence in this section
|
|
586
604
|
// this speeds up checking process.
|
|
587
|
-
if (c.
|
|
605
|
+
if (c.occurrences.filter((v) => v.time >= firstObjectMinHitTime &&
|
|
606
|
+
v.time <= lastObjectMaxHitTime).length === 0) {
|
|
588
607
|
continue;
|
|
589
608
|
}
|
|
590
609
|
// If this cursor instance doesn't move, it's not the cursor instance we want.
|
|
591
|
-
if (c.
|
|
610
|
+
if (c.occurrences.filter((v) => v.id === exports.movementType.MOVE)
|
|
611
|
+
.length === 0) {
|
|
592
612
|
continue;
|
|
593
613
|
}
|
|
594
614
|
cursorIndexes.push(i);
|
|
@@ -625,27 +645,28 @@ class ThreeFingerChecker {
|
|
|
625
645
|
// therefore the game emulates the movement between
|
|
626
646
|
// movementType.MOVE cursors.
|
|
627
647
|
const hitTime = o.object.startTime + s.accuracy;
|
|
628
|
-
const nextHitIndex = c.
|
|
648
|
+
const nextHitIndex = c.occurrences.findIndex((v) => v.time >= hitTime);
|
|
629
649
|
const hitIndex = nextHitIndex - 1;
|
|
630
650
|
if (hitIndex <= -1) {
|
|
631
651
|
cursorIndexes[j] = -1;
|
|
632
652
|
continue;
|
|
633
653
|
}
|
|
634
|
-
if (c.
|
|
654
|
+
if (c.occurrences[hitIndex].id === exports.movementType.UP) {
|
|
635
655
|
cursorIndexes[j] = -1;
|
|
636
656
|
continue;
|
|
637
657
|
}
|
|
638
|
-
const cursorPosition = new osuBase.Vector2(c.
|
|
658
|
+
const cursorPosition = new osuBase.Vector2(c.occurrences[hitIndex].position.x, c.occurrences[hitIndex].position.y);
|
|
639
659
|
let isInObject = false;
|
|
640
|
-
if (c.
|
|
641
|
-
c.
|
|
660
|
+
if (c.occurrences[nextHitIndex].id === exports.movementType.MOVE ||
|
|
661
|
+
c.occurrences[hitIndex].id === exports.movementType.MOVE) {
|
|
642
662
|
// Try to interpolate movement between two movementType.MOVE cursor every 1ms.
|
|
643
663
|
// This minimizes rounding error.
|
|
644
|
-
for (let mSecPassed = c.
|
|
645
|
-
const t = (mSecPassed - c.
|
|
646
|
-
(c.
|
|
647
|
-
|
|
648
|
-
cursorPosition.
|
|
664
|
+
for (let mSecPassed = c.occurrences[hitIndex].time; mSecPassed <= c.occurrences[nextHitIndex].time; ++mSecPassed) {
|
|
665
|
+
const t = (mSecPassed - c.occurrences[nextHitIndex].time) /
|
|
666
|
+
(c.occurrences[hitIndex].time -
|
|
667
|
+
c.occurrences[nextHitIndex].time);
|
|
668
|
+
cursorPosition.x = osuBase.Interpolation.lerp(c.occurrences[hitIndex].position.x, c.occurrences[nextHitIndex].position.x, t);
|
|
669
|
+
cursorPosition.y = osuBase.Interpolation.lerp(c.occurrences[hitIndex].position.y, c.occurrences[nextHitIndex].position.y, t);
|
|
649
670
|
if (o.object.stackedPosition.getDistance(cursorPosition) <= o.object.radius) {
|
|
650
671
|
isInObject = true;
|
|
651
672
|
break;
|
|
@@ -718,32 +739,24 @@ class ThreeFingerChecker {
|
|
|
718
739
|
* unnecessary taps.
|
|
719
740
|
*/
|
|
720
741
|
preventAccidentalTaps() {
|
|
721
|
-
let filledCursorAmount = this.downCursorInstances.filter((v) => v.
|
|
742
|
+
let filledCursorAmount = this.downCursorInstances.filter((v) => v.occurrences.length > 0).length;
|
|
722
743
|
if (filledCursorAmount <= 3) {
|
|
723
744
|
return;
|
|
724
745
|
}
|
|
725
746
|
const objects = this.map.objects;
|
|
726
|
-
const totalCursorAmount = this.downCursorInstances.reduce((acc, value) => acc + value.
|
|
747
|
+
const totalCursorAmount = this.downCursorInstances.reduce((acc, value) => acc + value.occurrences.length, 0);
|
|
727
748
|
for (let i = 0; i < this.downCursorInstances.length; ++i) {
|
|
728
749
|
if (filledCursorAmount <= 3) {
|
|
729
750
|
break;
|
|
730
751
|
}
|
|
731
752
|
const cursorInstance = this.downCursorInstances[i];
|
|
732
753
|
// Use an estimation for accidental tap threshold.
|
|
733
|
-
if (cursorInstance.
|
|
754
|
+
if (cursorInstance.occurrences.length <=
|
|
734
755
|
Math.ceil(objects.length / this.accidentalTapThreshold) &&
|
|
735
|
-
cursorInstance.
|
|
756
|
+
cursorInstance.occurrences.length / totalCursorAmount <
|
|
736
757
|
this.threeFingerRatioThreshold * 2) {
|
|
737
758
|
--filledCursorAmount;
|
|
738
|
-
|
|
739
|
-
const prop = property;
|
|
740
|
-
if (Array.isArray(cursorInstance[prop])) {
|
|
741
|
-
cursorInstance[prop].length = 0;
|
|
742
|
-
}
|
|
743
|
-
else {
|
|
744
|
-
cursorInstance[prop] = 0;
|
|
745
|
-
}
|
|
746
|
-
}
|
|
759
|
+
cursorInstance.occurrences.length = 0;
|
|
747
760
|
}
|
|
748
761
|
this.downCursorInstances[i] = cursorInstance;
|
|
749
762
|
}
|
|
@@ -773,13 +786,9 @@ class ThreeFingerChecker {
|
|
|
773
786
|
: this.hitWindow.hitWindowFor50(isPrecise));
|
|
774
787
|
// Filter cursor instances during section.
|
|
775
788
|
this.downCursorInstances.forEach((c) => {
|
|
776
|
-
const i = c.
|
|
789
|
+
const i = c.occurrences.findIndex((t) => t.time >= startTime);
|
|
777
790
|
if (i !== -1) {
|
|
778
|
-
c.
|
|
779
|
-
c.time.splice(0, i);
|
|
780
|
-
c.x.splice(0, i);
|
|
781
|
-
c.y.splice(0, i);
|
|
782
|
-
c.id.splice(0, i);
|
|
791
|
+
c.occurrences = c.occurrences.slice(0, i);
|
|
783
792
|
}
|
|
784
793
|
});
|
|
785
794
|
const cursorAmounts = [];
|
|
@@ -791,13 +800,13 @@ class ThreeFingerChecker {
|
|
|
791
800
|
}
|
|
792
801
|
const cursorData = this.downCursorInstances[i];
|
|
793
802
|
let amount = 0;
|
|
794
|
-
for (let j = 0; j < cursorData.
|
|
795
|
-
if (cursorData.
|
|
796
|
-
cursorData.
|
|
803
|
+
for (let j = 0; j < cursorData.occurrences.length; ++j) {
|
|
804
|
+
if (cursorData.occurrences[j].time >= startTime &&
|
|
805
|
+
cursorData.occurrences[j].time <= endTime) {
|
|
797
806
|
++amount;
|
|
798
807
|
cursorVectorTimes.push({
|
|
799
|
-
vector: new osuBase.Vector2(cursorData.
|
|
800
|
-
time: cursorData.
|
|
808
|
+
vector: new osuBase.Vector2(cursorData.occurrences[j].position.x, cursorData.occurrences[j].position.y),
|
|
809
|
+
time: cursorData.occurrences[j].time,
|
|
801
810
|
});
|
|
802
811
|
}
|
|
803
812
|
}
|
|
@@ -936,10 +945,6 @@ class TwoHandChecker {
|
|
|
936
945
|
* The data of the replay.
|
|
937
946
|
*/
|
|
938
947
|
data;
|
|
939
|
-
/**
|
|
940
|
-
* A cursor data array that only contains `movementType.DOWN` and `movementType.MOVE` movement ID occurrences.
|
|
941
|
-
*/
|
|
942
|
-
downMoveCursorInstances = [];
|
|
943
948
|
/**
|
|
944
949
|
* The hitobjects of the beatmap that have been assigned with their respective cursor index.
|
|
945
950
|
*/
|
|
@@ -955,6 +960,17 @@ class TwoHandChecker {
|
|
|
955
960
|
* those that do not worth any strain.
|
|
956
961
|
*/
|
|
957
962
|
minCursorIndexCount = 5;
|
|
963
|
+
/**
|
|
964
|
+
* The approximated difficulty of the current object such that the object is likely to be 2-handed by a player.
|
|
965
|
+
*
|
|
966
|
+
* This scales with an object's angle and speed relative to the previous object.
|
|
967
|
+
* Acute angles or fast speed will accumulate this number. Conversely, wide angles or slow speed will decay this number.
|
|
968
|
+
*/
|
|
969
|
+
currentAngleDiffApproxDefault = 10;
|
|
970
|
+
/**
|
|
971
|
+
* The threshold at which objects will be started getting considered to be 2-handable.
|
|
972
|
+
*/
|
|
973
|
+
currentAngleDiffApproxThreshold = 200;
|
|
958
974
|
/**
|
|
959
975
|
* @param map The beatmap to analyze.
|
|
960
976
|
* @param data The data of the replay.
|
|
@@ -974,56 +990,31 @@ class TwoHandChecker {
|
|
|
974
990
|
* Checks if a beatmap is two-handed.
|
|
975
991
|
*/
|
|
976
992
|
check() {
|
|
977
|
-
this.
|
|
978
|
-
|
|
993
|
+
if (this.data.cursorMovement.filter((v) => v.occurrences.length > 0)
|
|
994
|
+
.length <= 1) {
|
|
979
995
|
return false;
|
|
980
996
|
}
|
|
981
997
|
this.indexHitObjects();
|
|
982
998
|
this.applyPenalty();
|
|
983
999
|
return true;
|
|
984
1000
|
}
|
|
985
|
-
/**
|
|
986
|
-
* Filters the original cursor instances, returning only those with `movementType.DOWN` and `movementType.MOVE` movement ID.
|
|
987
|
-
*/
|
|
988
|
-
filterCursorInstances() {
|
|
989
|
-
for (let i = 0; i < this.data.cursorMovement.length; ++i) {
|
|
990
|
-
const cursorInstance = this.data.cursorMovement[i];
|
|
991
|
-
const newCursorData = {
|
|
992
|
-
size: 0,
|
|
993
|
-
time: [],
|
|
994
|
-
x: [],
|
|
995
|
-
y: [],
|
|
996
|
-
id: [],
|
|
997
|
-
};
|
|
998
|
-
for (let j = 0; j < cursorInstance.size; ++j) {
|
|
999
|
-
if (cursorInstance.id[j] === exports.movementType.UP) {
|
|
1000
|
-
continue;
|
|
1001
|
-
}
|
|
1002
|
-
++newCursorData.size;
|
|
1003
|
-
newCursorData.time.push(cursorInstance.time[j]);
|
|
1004
|
-
newCursorData.x.push(cursorInstance.x[j]);
|
|
1005
|
-
newCursorData.y.push(cursorInstance.y[j]);
|
|
1006
|
-
newCursorData.id.push(cursorInstance.id[j]);
|
|
1007
|
-
}
|
|
1008
|
-
this.downMoveCursorInstances.push(newCursorData);
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
1001
|
/**
|
|
1012
1002
|
* Converts hitobjects into indexed hit objects.
|
|
1013
1003
|
*/
|
|
1014
1004
|
indexHitObjects() {
|
|
1015
|
-
const
|
|
1016
|
-
const objectData = this.data.hitObjectData;
|
|
1005
|
+
const hitWindowOffset = this.getHitWindowOffset();
|
|
1017
1006
|
const indexes = [];
|
|
1007
|
+
let overallDiffApprox = this.currentAngleDiffApproxDefault;
|
|
1018
1008
|
for (let i = 0; i < this.map.objects.length; ++i) {
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1021
|
-
const index = this.
|
|
1009
|
+
const diff = i > 0 ? this.getSpacingAngleDiffApprox(i) : 1;
|
|
1010
|
+
overallDiffApprox = osuBase.MathUtils.clamp(overallDiffApprox * diff, this.currentAngleDiffApproxDefault, this.currentAngleDiffApproxThreshold + 100);
|
|
1011
|
+
const index = overallDiffApprox >= this.currentAngleDiffApproxThreshold
|
|
1012
|
+
? this.getCursorIndex(i, hitWindowOffset)
|
|
1013
|
+
: -1;
|
|
1022
1014
|
indexes.push(index);
|
|
1023
|
-
this.indexedHitObjects.push(new IndexedHitObject(
|
|
1015
|
+
this.indexedHitObjects.push(new IndexedHitObject(this.map.objects[i], index));
|
|
1024
1016
|
}
|
|
1025
|
-
|
|
1026
|
-
const indexCounts = osuBase.Utils.initializeArray(this.downMoveCursorInstances.length, 0);
|
|
1017
|
+
const indexCounts = osuBase.Utils.initializeArray(this.data.cursorMovement.length, 0);
|
|
1027
1018
|
for (const index of indexes) {
|
|
1028
1019
|
if (index === -1) {
|
|
1029
1020
|
continue;
|
|
@@ -1033,7 +1024,8 @@ class TwoHandChecker {
|
|
|
1033
1024
|
const mainCursorIndex = indexCounts.indexOf(Math.max(...indexCounts));
|
|
1034
1025
|
const ignoredCursorIndexes = [];
|
|
1035
1026
|
for (let i = 0; i < indexCounts.length; ++i) {
|
|
1036
|
-
if (indexCounts[i] < this.minCursorIndexCount
|
|
1027
|
+
if (indexCounts[i] < this.minCursorIndexCount &&
|
|
1028
|
+
i !== mainCursorIndex) {
|
|
1037
1029
|
ignoredCursorIndexes.push(i);
|
|
1038
1030
|
}
|
|
1039
1031
|
}
|
|
@@ -1043,109 +1035,249 @@ class TwoHandChecker {
|
|
|
1043
1035
|
indexedHitObject.cursorIndex = mainCursorIndex;
|
|
1044
1036
|
}
|
|
1045
1037
|
});
|
|
1046
|
-
for (let i = 0; i < this.
|
|
1047
|
-
console.log("Index", i, "count:",
|
|
1038
|
+
for (let i = 0; i < this.data.cursorMovement.length; ++i) {
|
|
1039
|
+
console.log("Index", i, "count:", this.indexedHitObjects.filter((v) => v.cursorIndex === i).length);
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Gets the approximation of an object's difficulty such that the object is likely to be 2-handed.
|
|
1044
|
+
*
|
|
1045
|
+
* @param index The index of the object.
|
|
1046
|
+
*/
|
|
1047
|
+
getSpacingAngleDiffApprox(index) {
|
|
1048
|
+
const object = this.map.objects[index];
|
|
1049
|
+
if (object.object instanceof osuBase.Spinner) {
|
|
1050
|
+
return 0.1;
|
|
1051
|
+
}
|
|
1052
|
+
const angleDiff = object.angle !== null
|
|
1053
|
+
? 0.5 + Math.pow(Math.cos(object.angle / 2), 2)
|
|
1054
|
+
: 1;
|
|
1055
|
+
const speedDiff = object.lazyJumpDistance / Math.max(1, object.deltaTime);
|
|
1056
|
+
// Make decay slower.
|
|
1057
|
+
return Math.max(0.8, angleDiff * speedDiff);
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Gets the hit window offset to be applied to `getCursorIndex`.
|
|
1061
|
+
*/
|
|
1062
|
+
getHitWindowOffset() {
|
|
1063
|
+
const deltaTimes = [];
|
|
1064
|
+
for (let i = 0; i < this.data.cursorMovement.length; ++i) {
|
|
1065
|
+
const c = this.data.cursorMovement[i];
|
|
1066
|
+
for (let j = 0; j < c.occurrences.length; ++j) {
|
|
1067
|
+
if (c.occurrences[j].time <
|
|
1068
|
+
this.map.map.hitObjects.objects[0].startTime -
|
|
1069
|
+
this.hitWindow.hitWindowFor50()) {
|
|
1070
|
+
continue;
|
|
1071
|
+
}
|
|
1072
|
+
if (c.occurrences[j].id !== exports.movementType.MOVE) {
|
|
1073
|
+
continue;
|
|
1074
|
+
}
|
|
1075
|
+
const deltaTime = c.occurrences[j]?.time - c.occurrences[j - 1]?.time || 0;
|
|
1076
|
+
if (deltaTime > 0) {
|
|
1077
|
+
deltaTimes.push(deltaTime);
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1048
1080
|
}
|
|
1081
|
+
return Math.min(...deltaTimes);
|
|
1049
1082
|
}
|
|
1050
1083
|
/**
|
|
1051
1084
|
* Gets the cursor index that hits the given object.
|
|
1052
1085
|
*
|
|
1053
|
-
* @param
|
|
1054
|
-
* @param
|
|
1086
|
+
* @param index The index of the object to check.
|
|
1087
|
+
* @param hitWindowOffset The offset for hit window to compensate for replay hit inaccuracies.
|
|
1055
1088
|
* @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.
|
|
1056
1089
|
*/
|
|
1057
|
-
getCursorIndex(
|
|
1090
|
+
getCursorIndex(index, hitWindowOffset) {
|
|
1091
|
+
const object = this.map.objects[index];
|
|
1092
|
+
const data = this.data.hitObjectData[index];
|
|
1058
1093
|
if (object.object instanceof osuBase.Spinner ||
|
|
1059
1094
|
data.result === exports.hitResult.RESULT_0) {
|
|
1060
1095
|
return -1;
|
|
1061
1096
|
}
|
|
1062
1097
|
const isPrecise = this.data.convertedMods.some((m) => m instanceof osuBase.ModPrecise);
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1098
|
+
// For sliders, automatically set hit window to be as lenient as possible.
|
|
1099
|
+
let hitWindowLength = this.hitWindow.hitWindowFor50(isPrecise);
|
|
1100
|
+
if (!(object.object instanceof osuBase.Slider)) {
|
|
1101
|
+
switch (data.result) {
|
|
1102
|
+
case exports.hitResult.RESULT_300:
|
|
1103
|
+
hitWindowLength = this.hitWindow.hitWindowFor300(isPrecise);
|
|
1104
|
+
break;
|
|
1105
|
+
case exports.hitResult.RESULT_100:
|
|
1106
|
+
hitWindowLength = this.hitWindow.hitWindowFor100(isPrecise);
|
|
1107
|
+
break;
|
|
1108
|
+
}
|
|
1073
1109
|
}
|
|
1074
|
-
const
|
|
1075
|
-
const
|
|
1076
|
-
const minimumHitTime =
|
|
1110
|
+
const startTime = object.object.startTime;
|
|
1111
|
+
const hitTime = startTime + data.accuracy;
|
|
1112
|
+
const minimumHitTime = startTime - hitWindowLength - hitWindowOffset;
|
|
1113
|
+
const maximumHitTime = startTime + hitWindowLength + hitWindowOffset;
|
|
1077
1114
|
const cursorInformations = [];
|
|
1078
|
-
for (let i = 0; i < this.
|
|
1079
|
-
const c = this.
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1115
|
+
for (let i = 0; i < this.data.cursorMovement.length; ++i) {
|
|
1116
|
+
const c = this.data.cursorMovement[i];
|
|
1117
|
+
if (c.occurrences.length === 0) {
|
|
1118
|
+
continue;
|
|
1119
|
+
}
|
|
1120
|
+
let hitTimeBeforeIndex = osuBase.MathUtils.clamp(c.occurrences.findIndex((v) => v.time >= minimumHitTime), 0, c.occurrences.length - 2);
|
|
1121
|
+
let hitTimeAfterIndex = c.occurrences.findIndex(
|
|
1122
|
+
// There is a special case for sliders where the time leniency in droid is a lot bigger compared to PC.
|
|
1123
|
+
// To prevent slider end time from ending earlier than hit window leniency, we use the maximum value between both.
|
|
1124
|
+
(v) => v.time >= Math.max(object.object.endTime, maximumHitTime));
|
|
1125
|
+
if (hitTimeAfterIndex === -1) {
|
|
1126
|
+
// Maximum hit time or object end time may be out of bounds for every presses.
|
|
1127
|
+
// We set the index to the latest cursor occurrence if that happens.
|
|
1128
|
+
hitTimeAfterIndex = c.occurrences.length;
|
|
1129
|
+
}
|
|
1130
|
+
--hitTimeAfterIndex;
|
|
1131
|
+
// Sometimes a `movementType.UP` instance occurs at the same time as a `movementType.MOVE`
|
|
1132
|
+
// or a cursor is recorded twice in one time, therefore this check is required.
|
|
1133
|
+
while (c.occurrences[hitTimeBeforeIndex]?.time ===
|
|
1134
|
+
c.occurrences[hitTimeBeforeIndex - 1]?.time &&
|
|
1135
|
+
hitTimeBeforeIndex > 0) {
|
|
1136
|
+
--hitTimeBeforeIndex;
|
|
1137
|
+
}
|
|
1138
|
+
// We track the cursor movement along those indexes.
|
|
1139
|
+
// Current cursor position is in `hitTimeBeforeIndex`.
|
|
1140
|
+
let distance = Number.POSITIVE_INFINITY;
|
|
1141
|
+
let acceptableRadius = object.object.radius;
|
|
1142
|
+
// Sliders have a bigger radius tolerance due to slider ball.
|
|
1143
|
+
if (object.object instanceof osuBase.Slider) {
|
|
1144
|
+
acceptableRadius *= 2.4;
|
|
1145
|
+
}
|
|
1146
|
+
let j = hitTimeBeforeIndex;
|
|
1147
|
+
for (j; j <= hitTimeAfterIndex; ++j) {
|
|
1148
|
+
const occurrence = c.occurrences[j];
|
|
1149
|
+
const nextOccurrence = c.occurrences[j + 1];
|
|
1150
|
+
const cursorPosition = occurrence.position;
|
|
1151
|
+
if (occurrence.time > hitTime + hitWindowOffset) {
|
|
1152
|
+
// Set distance to minimum just for the last.
|
|
1153
|
+
if (occurrence.id !== exports.movementType.UP) {
|
|
1154
|
+
distance = Math.min(distance, object.object.stackedPosition.getDistance(cursorPosition));
|
|
1155
|
+
}
|
|
1156
|
+
break;
|
|
1085
1157
|
}
|
|
1086
|
-
|
|
1087
|
-
// so just skip it to save time.
|
|
1088
|
-
if (c.time[j + 1] === c.time[j]) {
|
|
1158
|
+
if (occurrence.id === exports.movementType.UP) {
|
|
1089
1159
|
continue;
|
|
1090
1160
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1161
|
+
distance =
|
|
1162
|
+
object.object.stackedPosition.getDistance(cursorPosition);
|
|
1163
|
+
if (nextOccurrence &&
|
|
1164
|
+
nextOccurrence.id === exports.movementType.MOVE &&
|
|
1165
|
+
occurrence.time !== nextOccurrence.time &&
|
|
1166
|
+
!occurrence.position.equals(nextOccurrence.position)) {
|
|
1167
|
+
// If next cursor is a `move` instance and it doesn't go out of time
|
|
1168
|
+
// range, we interpolate cursor position between two occurrences.
|
|
1169
|
+
const nextPosition = nextOccurrence.position;
|
|
1170
|
+
const displacement = nextPosition.subtract(cursorPosition);
|
|
1171
|
+
for (let mSecPassed = Math.max(minimumHitTime, occurrence.time); mSecPassed <=
|
|
1172
|
+
Math.min(hitTime + hitWindowOffset, nextOccurrence.time); ++mSecPassed) {
|
|
1173
|
+
const progress = (mSecPassed - occurrence.time) /
|
|
1174
|
+
(nextOccurrence.time - occurrence.time);
|
|
1175
|
+
distance = object.object.stackedPosition.getDistance(cursorPosition.add(displacement.scale(progress)));
|
|
1176
|
+
}
|
|
1093
1177
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1178
|
+
}
|
|
1179
|
+
if (distance > acceptableRadius) {
|
|
1180
|
+
continue;
|
|
1181
|
+
}
|
|
1182
|
+
// The case for a one-handed object is that there will be a slight movement in the cursor towards
|
|
1183
|
+
// the next object in fast patterns. We should not be worried about slow patterns as they will only
|
|
1184
|
+
// make a minimal difference and the difficulty approximation we did earlier should filter them out.
|
|
1185
|
+
// In order to verify if the player does that, we check if the movement towards the next
|
|
1186
|
+
// object is sufficient enough to be two-handed. This is done by checking if the movement
|
|
1187
|
+
// from the current object to the next object and the movement from the current object
|
|
1188
|
+
// to the significant move cursor occurrence produces an angle that is acute enough.
|
|
1189
|
+
let isAngleFulfilled = false;
|
|
1190
|
+
// For sliders, we need to consider two cases. The first case is when the player doesn't drag
|
|
1191
|
+
// the slider. The second case is when the player drags the slider.
|
|
1192
|
+
// TODO: check for cursor occurrences in nested objects
|
|
1193
|
+
// Get the latest down or movement cursor occurrence.
|
|
1194
|
+
while (c.occurrences[j]?.id === exports.movementType.UP &&
|
|
1195
|
+
j > hitTimeBeforeIndex) {
|
|
1196
|
+
--j;
|
|
1197
|
+
}
|
|
1198
|
+
if (object.object instanceof osuBase.Circle) {
|
|
1199
|
+
// For circles, we only need to consider the actual press on the circle.
|
|
1200
|
+
// Therefore, we need to get the latest down cursor occurrence instead.
|
|
1201
|
+
while (c.occurrences[j]?.id !== exports.movementType.DOWN &&
|
|
1202
|
+
j > hitTimeBeforeIndex) {
|
|
1203
|
+
--j;
|
|
1099
1204
|
}
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1205
|
+
}
|
|
1206
|
+
// Theoretically there can only be 1 up occurrence, but this is a
|
|
1207
|
+
// consideration if the user manually adds cursor occurrences.
|
|
1208
|
+
if (c.occurrences[j]?.id === exports.movementType.UP) {
|
|
1209
|
+
++j;
|
|
1210
|
+
}
|
|
1211
|
+
// Some move instances move in the exact same place. Not sure why, most likely
|
|
1212
|
+
// because the position is recorded as int in the game and the movement is too small to
|
|
1213
|
+
// convert into +1 or -1.
|
|
1214
|
+
let nextSignificantOccurrenceIndex = j + 1;
|
|
1215
|
+
while (c.occurrences[j] &&
|
|
1216
|
+
c.occurrences[nextSignificantOccurrenceIndex] &&
|
|
1217
|
+
c.occurrences[j].position.equals(c.occurrences[nextSignificantOccurrenceIndex].position)) {
|
|
1218
|
+
++nextSignificantOccurrenceIndex;
|
|
1219
|
+
}
|
|
1220
|
+
const nextSignificantOccurrence = c.occurrences[nextSignificantOccurrenceIndex];
|
|
1221
|
+
const next = this.map.objects[index + 1];
|
|
1222
|
+
if (nextSignificantOccurrence?.id === exports.movementType.MOVE && next) {
|
|
1223
|
+
// Get the object's actual end position.
|
|
1224
|
+
let actualEndPosition = object.object.stackedEndPosition;
|
|
1225
|
+
if (object.object instanceof osuBase.Slider &&
|
|
1226
|
+
object.object.lazyEndPosition) {
|
|
1227
|
+
// For sliders, we take the closest distance between the lazy end position
|
|
1228
|
+
// and stacked end position towards the next significant cursor occurrence.
|
|
1229
|
+
// This assumes that the player takes the simpler movement.
|
|
1230
|
+
const lazyEndDistance = object.object.lazyEndPosition.getDistance(nextSignificantOccurrence.position);
|
|
1231
|
+
const actualEndDistance = object.object.stackedEndPosition.getDistance(nextSignificantOccurrence.position);
|
|
1232
|
+
if (lazyEndDistance < actualEndDistance) {
|
|
1233
|
+
actualEndPosition = object.object.lazyEndPosition;
|
|
1117
1234
|
}
|
|
1118
1235
|
}
|
|
1236
|
+
// Get the movement vector towards the next cursor occurrence by subtracting
|
|
1237
|
+
// the next cursor occurrence with the object's position.
|
|
1238
|
+
const movementVec = nextSignificantOccurrence.position.subtract(actualEndPosition);
|
|
1239
|
+
const currentToNext = next.object.stackedPosition.subtract(actualEndPosition);
|
|
1240
|
+
const dot = currentToNext.dot(movementVec);
|
|
1241
|
+
const det = currentToNext.x * movementVec.y -
|
|
1242
|
+
currentToNext.y * movementVec.x;
|
|
1243
|
+
const movementToNextAngle = Math.abs(Math.atan2(det, dot));
|
|
1244
|
+
isAngleFulfilled = movementToNextAngle < Math.PI / 6;
|
|
1119
1245
|
}
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
if (cursorInformations.length === 0) {
|
|
1128
|
-
return -1;
|
|
1246
|
+
cursorInformations.push({
|
|
1247
|
+
// If the angle is fulfilled, we set the cursor index to the main cursor index.
|
|
1248
|
+
cursorIndex: isAngleFulfilled ? i : -1,
|
|
1249
|
+
distanceDiff: distance,
|
|
1250
|
+
});
|
|
1129
1251
|
}
|
|
1130
|
-
//
|
|
1131
|
-
|
|
1132
|
-
|
|
1252
|
+
// Cursors have been filtered to see which of them is inside the object.
|
|
1253
|
+
// Now we look at which cursor is closest to the center of the object.
|
|
1254
|
+
const minDistanceDiff = Math.min(...cursorInformations.map((v) => {
|
|
1255
|
+
return v.distanceDiff;
|
|
1133
1256
|
}));
|
|
1134
|
-
return (cursorInformations.find((c) => c.
|
|
1135
|
-
?.cursorIndex);
|
|
1257
|
+
return (cursorInformations.find((c) => c.distanceDiff === minDistanceDiff)
|
|
1258
|
+
?.cursorIndex ?? -1);
|
|
1136
1259
|
}
|
|
1137
1260
|
/**
|
|
1138
1261
|
* Applies penalty to the original star rating instance.
|
|
1139
1262
|
*/
|
|
1140
1263
|
applyPenalty() {
|
|
1141
|
-
const beatmaps = new Array(this.
|
|
1264
|
+
const beatmaps = new Array(this.data.cursorMovement.length);
|
|
1142
1265
|
this.indexedHitObjects.forEach((o) => {
|
|
1143
1266
|
if (!beatmaps[o.cursorIndex]) {
|
|
1144
1267
|
const map = osuBase.Utils.deepCopy(this.map.map);
|
|
1268
|
+
map.hitObjects.clear();
|
|
1145
1269
|
beatmaps[o.cursorIndex] = map;
|
|
1146
1270
|
}
|
|
1147
1271
|
beatmaps[o.cursorIndex].hitObjects.add(o.object.object);
|
|
1148
1272
|
});
|
|
1273
|
+
// Preserve some values that aren't reasonable for them to be changed.
|
|
1274
|
+
const preservedValues = this.map.objects.map((v) => {
|
|
1275
|
+
return {
|
|
1276
|
+
noteDensity: v.noteDensity,
|
|
1277
|
+
rhythmStrain: v.rhythmStrain,
|
|
1278
|
+
rhythmMultiplier: v.rhythmMultiplier,
|
|
1279
|
+
};
|
|
1280
|
+
});
|
|
1149
1281
|
this.map.objects.length = 0;
|
|
1150
1282
|
beatmaps.forEach((beatmap) => {
|
|
1151
1283
|
if (!beatmap) {
|
|
@@ -1155,15 +1287,25 @@ class TwoHandChecker {
|
|
|
1155
1287
|
starRating.map = beatmap;
|
|
1156
1288
|
starRating.generateDifficultyHitObjects();
|
|
1157
1289
|
starRating.objects[0].deltaTime =
|
|
1158
|
-
starRating.objects[0].
|
|
1159
|
-
this.indexedHitObjects[0].object.
|
|
1160
|
-
starRating.objects[0].strainTime = Math.max(
|
|
1290
|
+
starRating.objects[0].startTime -
|
|
1291
|
+
this.indexedHitObjects[0].object.startTime;
|
|
1292
|
+
starRating.objects[0].strainTime = Math.max(25, starRating.objects[0].deltaTime);
|
|
1161
1293
|
this.map.objects.push(...starRating.objects);
|
|
1162
1294
|
});
|
|
1163
|
-
this.map.objects.sort((a, b) =>
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1295
|
+
this.map.objects.sort((a, b) => a.startTime - b.startTime);
|
|
1296
|
+
// Reassign rhythm values before calculating.
|
|
1297
|
+
for (let i = 0; i < this.map.objects.length; ++i) {
|
|
1298
|
+
this.map.objects[i].noteDensity = preservedValues[i].noteDensity;
|
|
1299
|
+
this.map.objects[i].rhythmStrain = preservedValues[i].rhythmStrain;
|
|
1300
|
+
this.map.objects[i].rhythmMultiplier =
|
|
1301
|
+
preservedValues[i].rhythmMultiplier;
|
|
1302
|
+
}
|
|
1303
|
+
// Do not include rhythm skill.
|
|
1304
|
+
this.map.calculateAim();
|
|
1305
|
+
this.map.calculateTap();
|
|
1306
|
+
this.map.calculateFlashlight();
|
|
1307
|
+
this.map.calculateVisual();
|
|
1308
|
+
this.map.calculateTotal();
|
|
1167
1309
|
}
|
|
1168
1310
|
}
|
|
1169
1311
|
|
|
@@ -1404,42 +1546,41 @@ class ReplayAnalyzer {
|
|
|
1404
1546
|
for (let x = 0; x < size; x++) {
|
|
1405
1547
|
const moveSize = replayDataBuffer.readInt32BE(bufferCounter);
|
|
1406
1548
|
bufferCounter += this.INT_LENGTH;
|
|
1407
|
-
const
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
y: [],
|
|
1412
|
-
id: [],
|
|
1413
|
-
};
|
|
1549
|
+
const time = [];
|
|
1550
|
+
const x = [];
|
|
1551
|
+
const y = [];
|
|
1552
|
+
const id = [];
|
|
1414
1553
|
for (let i = 0; i < moveSize; i++) {
|
|
1415
|
-
|
|
1554
|
+
time[i] = replayDataBuffer.readInt32BE(bufferCounter);
|
|
1416
1555
|
bufferCounter += this.INT_LENGTH;
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
if (
|
|
1556
|
+
id[i] = time[i] & 3;
|
|
1557
|
+
time[i] >>= 2;
|
|
1558
|
+
if (id[i] !== exports.movementType.UP) {
|
|
1420
1559
|
if (resultObject.replayVersion >= 5) {
|
|
1421
|
-
|
|
1422
|
-
replayDataBuffer.readFloatBE(bufferCounter);
|
|
1560
|
+
x[i] = replayDataBuffer.readFloatBE(bufferCounter);
|
|
1423
1561
|
bufferCounter += this.FLOAT_LENGTH;
|
|
1424
|
-
|
|
1425
|
-
replayDataBuffer.readFloatBE(bufferCounter);
|
|
1562
|
+
y[i] = replayDataBuffer.readFloatBE(bufferCounter);
|
|
1426
1563
|
bufferCounter += this.FLOAT_LENGTH;
|
|
1427
1564
|
}
|
|
1428
1565
|
else {
|
|
1429
|
-
|
|
1430
|
-
replayDataBuffer.readInt16BE(bufferCounter);
|
|
1566
|
+
x[i] = replayDataBuffer.readInt16BE(bufferCounter);
|
|
1431
1567
|
bufferCounter += this.SHORT_LENGTH;
|
|
1432
|
-
|
|
1433
|
-
replayDataBuffer.readInt16BE(bufferCounter);
|
|
1568
|
+
y[i] = replayDataBuffer.readInt16BE(bufferCounter);
|
|
1434
1569
|
bufferCounter += this.SHORT_LENGTH;
|
|
1435
1570
|
}
|
|
1436
1571
|
}
|
|
1437
1572
|
else {
|
|
1438
|
-
|
|
1439
|
-
|
|
1573
|
+
x[i] = -1;
|
|
1574
|
+
y[i] = -1;
|
|
1440
1575
|
}
|
|
1441
1576
|
}
|
|
1442
|
-
resultObject.cursorMovement.push(
|
|
1577
|
+
resultObject.cursorMovement.push(new CursorData({
|
|
1578
|
+
size: moveSize,
|
|
1579
|
+
time: time,
|
|
1580
|
+
x: x,
|
|
1581
|
+
y: y,
|
|
1582
|
+
id: id,
|
|
1583
|
+
}));
|
|
1443
1584
|
}
|
|
1444
1585
|
const replayObjectLength = replayDataBuffer.readInt32BE(bufferCounter);
|
|
1445
1586
|
bufferCounter += this.INT_LENGTH;
|
|
@@ -1720,6 +1861,7 @@ class ReplayObjectData {
|
|
|
1720
1861
|
}
|
|
1721
1862
|
|
|
1722
1863
|
exports.CursorData = CursorData;
|
|
1864
|
+
exports.CursorOccurrence = CursorOccurrence;
|
|
1723
1865
|
exports.ReplayAnalyzer = ReplayAnalyzer;
|
|
1724
1866
|
exports.ReplayData = ReplayData;
|
|
1725
1867
|
exports.ReplayObjectData = ReplayObjectData;
|