Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add most common BPM and object counters #18

Merged
merged 3 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"koa-send": "^5.0.1",
"koa-static": "^5.0.0",
"koa-websocket": "^7.0.0",
"osu-catch-stable": "^3.2.2",
"osu-classes": "^2.1.3",
"osu-mania-stable": "^4.0.3",
"osu-parsers": "^4.0.0",
"osu-standard-stable": "^4.0.4",
"osu-taiko-stable": "^4.0.4",
"osu-catch-stable": "^4.0.0",
"osu-classes": "^3.0.0",
"osu-mania-stable": "^5.0.0",
"osu-parsers": "^4.1.0",
"osu-standard-stable": "^5.0.0",
"osu-taiko-stable": "^5.0.0",
"pkg": "^5.8.0",
"resedit": "^2.0.0",
"rosu-pp": "^0.9.4",
Expand Down
5 changes: 5 additions & 0 deletions src/Api/Utils/BuildResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,14 @@ export const buildResult = (
HP: beatmapPpData.calculatedMapAttributes.hp,
SR: beatmapPpData.currAttributes.stars,
BPM: {
common: beatmapPpData.commonBPM,
min: beatmapPpData.minBPM,
max: beatmapPpData.maxBPM
},
circles: beatmapPpData.calculatedMapAttributes.circles,
sliders: beatmapPpData.calculatedMapAttributes.sliders,
spinners: beatmapPpData.calculatedMapAttributes.spinners,
holds: beatmapPpData.calculatedMapAttributes.holds,
maxCombo: beatmapPpData.calculatedMapAttributes.maxCombo,
fullSR: beatmapPpData.calculatedMapAttributes.fullStars,
memoryAR: menuData.AR,
Expand Down
5 changes: 5 additions & 0 deletions src/Api/Utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ interface BeatmapStats {
HP: number;
SR: number;
BPM: {
common: number;
min: number;
max: number;
};
circles: number;
sliders: number;
spinners: number;
holds: number;
maxCombo: number;
fullSR: number;
memoryAR: number;
Expand Down
32 changes: 28 additions & 4 deletions src/Services/Entities/BeatmapPpData/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Beatmap as ParsedBeatmap } from 'osu-classes';
import { BeatmapDecoder } from 'osu-parsers';
import path from 'path';
import { Beatmap, Calculator } from 'rosu-pp';
Expand All @@ -23,6 +24,10 @@ interface BeatmapPPAttributes {
cs: number;
hp: number;
od: number;
circles: number;
sliders: number;
spinners: number;
holds: number;
maxCombo: number;
fullStars: number;
stars: number;
Expand All @@ -43,6 +48,7 @@ interface BeatmapPPTimings {
export class BeatmapPPData extends AbstractEntity {
strains: number[];
strainsAll: BeatmapStrains;
commonBPM: number;
minBPM: number;
maxBPM: number;
ppAcc: BeatmapPPAcc;
Expand All @@ -62,6 +68,7 @@ export class BeatmapPPData extends AbstractEntity {
series: [],
xaxis: []
};
this.commonBPM = 0.0;
this.minBPM = 0.0;
this.maxBPM = 0.0;
this.ppAcc = {
Expand All @@ -77,6 +84,10 @@ export class BeatmapPPData extends AbstractEntity {
cs: 0.0,
hp: 0.0,
od: 0.0,
circles: 0,
sliders: 0,
spinners: 0,
holds: 0,
maxCombo: 0,
fullStars: 0.0,
stars: 0.0
Expand Down Expand Up @@ -128,7 +139,8 @@ export class BeatmapPPData extends AbstractEntity {
};
}

updateBPM(minBPM: number, maxBPM: number) {
updateBPM(commonBPM: number, minBPM: number, maxBPM: number) {
this.commonBPM = commonBPM;
this.minBPM = minBPM;
this.maxBPM = maxBPM;
}
Expand All @@ -154,7 +166,7 @@ export class BeatmapPPData extends AbstractEntity {
menuData.Folder,
menuData.Path
);
let beatmap;
let beatmap: Beatmap;
try {
beatmap = new Beatmap({
path: mapPath,
Expand Down Expand Up @@ -200,12 +212,17 @@ export class BeatmapPPData extends AbstractEntity {
series: [],
xaxis: []
};

let oldStrains: number[] = [];

const offset: number = strains.sectionLength;

let lazerBeatmap: ParsedBeatmap;

try {
const decoder = new BeatmapDecoder();
const lazerBeatmap = await decoder.decodeFromPath(mapPath, {

lazerBeatmap = await decoder.decodeFromPath(mapPath, {
parseColours: false,
parseDifficulty: false,
parseEditor: false,
Expand All @@ -214,7 +231,9 @@ export class BeatmapPPData extends AbstractEntity {
parseMetadata: false
});

this.updateBPM(lazerBeatmap.bpmMin, lazerBeatmap.bpmMax);
const { bpm, bpmMin, bpmMax } = lazerBeatmap;

this.updateBPM(bpm, bpmMin, bpmMax);

const firstObj = Math.round(
lazerBeatmap.hitObjects.at(0)?.startTime ?? 0
Expand All @@ -227,6 +246,7 @@ export class BeatmapPPData extends AbstractEntity {
wLogger.error(
"Something happend, when we're tried to parse beatmap"
);
return;
}

const beatmap_parse_time = performance.now();
Expand Down Expand Up @@ -330,6 +350,10 @@ export class BeatmapPPData extends AbstractEntity {
cs: mapAttributes.cs,
od: mapAttributes.od,
hp: mapAttributes.hp,
circles: lazerBeatmap.hittable,
sliders: lazerBeatmap.slidable,
spinners: lazerBeatmap.spinnable,
holds: lazerBeatmap.holdable,
maxCombo: fcPerformance.difficulty.maxCombo,
fullStars: fcPerformance.difficulty.stars,
stars: fcPerformance.difficulty.stars
Expand Down
48 changes: 24 additions & 24 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1963,37 +1963,37 @@ only@~0.0.2:
resolved "https://registry.yarnpkg.com/only/-/only-0.0.2.tgz#2afde84d03e50b9a8edc444e30610a70295edfb4"
integrity sha512-Fvw+Jemq5fjjyWz6CpKx6w9s7xxqo3+JCyM0WXWeCSOboZ8ABkyvP8ID4CZuChA/wxSx+XSJmdOm8rGVyJ1hdQ==

osu-catch-stable@^3.2.2:
version "3.2.3"
resolved "https://registry.yarnpkg.com/osu-catch-stable/-/osu-catch-stable-3.2.3.tgz#d11cd0a0632dccf90fc01e911d5f670080e50ae4"
integrity sha512-jpHWUWOV3q9HIpEGS9casjSTcy+Y1P/qrhqfku2bhfY5TdG1KcwVasHgL/sa+92cp52LqjM7DRhRMn7YVgZ1Ng==
osu-catch-stable@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/osu-catch-stable/-/osu-catch-stable-4.0.0.tgz#60a5b150840a9d4efe53b230a92945e43ac13908"
integrity sha512-qOayn6WifpZ7+mT4qj6gCgGmbOxx5/PVL/NIm6NsZ86O6O0qH+6R+ytSV2TtB4RXklBYKP/nK2dTdS9kSbXznQ==

osu-classes@^2.1.3:
version "2.2.1"
resolved "https://registry.yarnpkg.com/osu-classes/-/osu-classes-2.2.1.tgz#78d15ef10dd9b0d1b5620dffcbfafcdd43e4f5e0"
integrity sha512-mgzAQ1KXU5SKUrZZE221kZ2c/l8H89NxlufICV5AScSYH1OARlahbpMcxPja2rwsJGEH4NQbtd7LRO5W0rtGKQ==
osu-classes@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/osu-classes/-/osu-classes-3.0.0.tgz#3617e1d5fe4227f060a90ff9969ed5fc22a8d688"
integrity sha512-LVslpXRjzHqUN0IJOmTwMnoKUNSeCyr7dKhsbPR7jvtkJoYyZtMpr9AS/nVdJmL5MPKKoEa3unLfffdUSmonoA==

osu-mania-stable@^4.0.3:
version "4.0.4"
resolved "https://registry.yarnpkg.com/osu-mania-stable/-/osu-mania-stable-4.0.4.tgz#8af7dfda251fad5e90ae8766b5feaf73c8768af0"
integrity sha512-yCCKFc6+0AMpn9ENvIjUFC3gRa6B/OA3NEiO20RLGm0RNcetJLRSi16P/gBR8LLBNhmA+Vpx970cwWq9FS3VMA==
osu-mania-stable@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/osu-mania-stable/-/osu-mania-stable-5.0.0.tgz#ddc5103743e5082326e9bb6d97b2add553b98b90"
integrity sha512-9UYjgZ2YYBFgVxNDON1rSXQO7KQ5DMuJxRsavDRLKFsoE7foHHc4y1AUBgOH0u6vuGVDOleBXhvvGjwsHAibjw==

osu-parsers@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/osu-parsers/-/osu-parsers-4.0.0.tgz#a90b46be5f002fd630053723c553e8d752ca7933"
integrity sha512-z7R5kxCyWZsIY04UNMVNBFwUZ9mVSMMZuAzH/BgcOzx9aVU9Xb5yz0M5K2XYmXGtVgWMqCNh7NUfg7iDV5Bllg==
osu-parsers@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/osu-parsers/-/osu-parsers-4.1.0.tgz#165b901b0c8b08de1370468b2ad348c918e1a0e2"
integrity sha512-bPMlNkGx1TG0qIr/D3zPZ3CEOC3onwcSNYG1vAstAnltmIx1vlvOuZSVrl5fCjmZytc3sz+ZAEUW8vC7iQ0lnQ==
dependencies:
lzma-js-simple-v2 "^1.2.2"

osu-standard-stable@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/osu-standard-stable/-/osu-standard-stable-4.0.4.tgz#eaf30e4d3441d552549b88bf4742286c12cc923d"
integrity sha512-Rb1aJTViU+ZFMe197aKlYhjMThuQ/jPHF9+KybKvElLY10/+nDgbD+lyVw2fp/4G/IgI3ghxSuD4nakgrLLGaA==
osu-standard-stable@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/osu-standard-stable/-/osu-standard-stable-5.0.0.tgz#dc82e0d4224c13d05effaa64904f4d34d8b0e9c6"
integrity sha512-qCzS1DFStHjgeDZguLRY5k4OgJSNXHG+sUdi1jm2Xwgk23QsyexwRQyTs5phFMuAnQmxeyjzWELLHOo99A/gMA==

osu-taiko-stable@^4.0.4:
version "4.0.5"
resolved "https://registry.yarnpkg.com/osu-taiko-stable/-/osu-taiko-stable-4.0.5.tgz#d87d1fb3f25046427b398c00e4326b18acd9e58f"
integrity sha512-2MRYH7NjraRAcJLDOfPcjDosgMv0RYA1hcOpxtI+YLPNr7tIjaxLmksbzP4NLM//au7jDbF4QmBb14k8bPOq6Q==
osu-taiko-stable@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/osu-taiko-stable/-/osu-taiko-stable-5.0.0.tgz#f3db101721923b5601e82b2032f0e5a56659365b"
integrity sha512-zvkFfAysl2BOSTTRN7sNtA590I+1hRYhEnArvQrUOWU94UTeyCLgh2yvlYXqVXeIQlhVDcrSxT8JR9RnGk3voA==

p-is-promise@^3.0.0:
version "3.0.0"
Expand Down