Skip to content

Commit

Permalink
Merge pull request #202 from tosuapp/feat/pp_rework
Browse files Browse the repository at this point in the history
feat: pp rework
  • Loading branch information
KotRikD authored Oct 30, 2024
2 parents 0c5dea2 + b0e08ff commit 2d5ac58
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 51 deletions.
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dependencies": {
"@tosu/common": "workspace:*",
"@tosu/updater": "workspace:*",
"rosu-pp-js": "^1.0.2",
"@kotrikd/rosu-pp": "2.0.0-alpha.6",
"semver": "^7.5.4",
"ws": "^8.16.0"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/server/router/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import rosu from '@kotrikd/rosu-pp';
import {
downloadFile,
getCachePath,
Expand All @@ -12,7 +13,6 @@ import { autoUpdater } from '@tosu/updater';
import { exec } from 'child_process';
import fs from 'fs';
import path from 'path';
import rosu from 'rosu-pp-js';

import { Server, sendJson } from '../index';
import {
Expand Down Expand Up @@ -421,6 +421,7 @@ export default function buildBaseApi(server: Server) {
if (query.nKatu) params.nKatu = +query.nKatu;
if (query.mods) params.mods = +query.mods;
if (query.acc) params.accuracy = +query.acc;
if (query.lazer) params.lazer = query.lazer ?? true;

const calculate = new rosu.Performance(params).calculate(beatmap);
sendJson(res, calculate);
Expand Down
2 changes: 1 addition & 1 deletion packages/tosu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"osu-standard-stable": "^5.0.0",
"osu-taiko-stable": "^5.0.0",
"resedit": "^2.0.0",
"rosu-pp-js": "^1.0.2",
"@kotrikd/rosu-pp": "2.0.0-alpha.6",
"semver": "^7.5.4",
"tsprocess": "workspace:*"
},
Expand Down
14 changes: 8 additions & 6 deletions packages/tosu/src/entities/BeatmapPpData/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import rosu from '@kotrikd/rosu-pp';
import { config, wLogger } from '@tosu/common';
import fs from 'fs';
import { Beatmap as ParsedBeatmap } from 'osu-classes';
import { BeatmapDecoder } from 'osu-parsers';
import path from 'path';
import rosu from 'rosu-pp-js';

import { BeatmapStrains } from '@/api/types/v1';
import { AbstractEntity } from '@/entities/AbstractEntity';
Expand Down Expand Up @@ -319,14 +319,14 @@ export class BeatmapPPData extends AbstractEntity {
`BPPD(updateMapMetadata) [${totalTime}ms] Spend on opening beatmap`
);

const difficulty = new rosu.Difficulty({ mods: currentMods });
const attributes = new rosu.BeatmapAttributesBuilder({
map: this.beatmap,
mods: currentMods,
mode: currentMode
}).build();

const fcPerformance = new rosu.Performance({
lazer: false,
mods: currentMods
}).calculate(this.beatmap);

Expand All @@ -337,6 +337,7 @@ export class BeatmapPPData extends AbstractEntity {
const ppAcc = {};
for (const acc of [100, 99, 98, 97, 96, 95]) {
const calculate = new rosu.Performance({
lazer: false,
mods: currentMods,
accuracy: acc
}).calculate(fcPerformance);
Expand Down Expand Up @@ -443,7 +444,6 @@ export class BeatmapPPData extends AbstractEntity {
hitWindow: fcPerformance.difficulty.hitWindow
};

difficulty.free();
attributes.free();

this.resetReportCount('BPPD(updateMapMetadata)');
Expand All @@ -468,9 +468,10 @@ export class BeatmapPPData extends AbstractEntity {
xaxis: []
};

const difficulty = new rosu.Difficulty({ mods: currentMods });
const strains = difficulty.strains(this.beatmap);

const strains = new rosu.Difficulty({
mods: currentMods,
lazer: false
}).strains(this.beatmap);
let oldStrains: number[] = [];

let strainsAmount = 0;
Expand Down Expand Up @@ -638,6 +639,7 @@ export class BeatmapPPData extends AbstractEntity {
);

const curPerformance = new rosu.Performance({
lazer: false,
passedObjects: passedObjects.length
}).calculate(this.PerformanceAttributes);

Expand Down
9 changes: 7 additions & 2 deletions packages/tosu/src/entities/GamePlayData/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rosu from '@kotrikd/rosu-pp';
import { config, wLogger } from '@tosu/common';
import rosu from 'rosu-pp-js';
import { Process } from 'tsprocess/dist/process';

import { AbstractEntity } from '@/entities/AbstractEntity';
Expand Down Expand Up @@ -611,13 +611,17 @@ export class GamePlayData extends AbstractEntity {
if (this.PerformanceAttributes)
this.PerformanceAttributes.free();

const difficulty = new rosu.Difficulty({ mods: this.Mods });
const difficulty = new rosu.Difficulty({
mods: this.Mods,
lazer: false
});
this.GradualPerformance = new rosu.GradualPerformance(
difficulty,
currentBeatmap
);

this.PerformanceAttributes = new rosu.Performance({
lazer: false,
mods: this.Mods
}).calculate(currentBeatmap);

Expand Down Expand Up @@ -660,6 +664,7 @@ export class GamePlayData extends AbstractEntity {
)!;

const fcPerformance = new rosu.Performance({
lazer: false,
mods: this.Mods,
misses: 0,
accuracy: this.Accuracy
Expand Down
6 changes: 4 additions & 2 deletions packages/tosu/src/entities/ResultsScreenData/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import rosu from '@kotrikd/rosu-pp';
import { wLogger } from '@tosu/common';
import rosu from 'rosu-pp-js';

import { AbstractEntity } from '@/entities/AbstractEntity';
import { OsuInstance } from '@/objects/instanceManager/osuInstance';
Expand Down Expand Up @@ -184,13 +184,15 @@ export class ResultsScreenData extends AbstractEntity {
n100: this.Hit100,
n300: this.Hit300,
nKatu: this.HitKatu,
nGeki: this.HitGeki
nGeki: this.HitGeki,
lazer: false
};

const curPerformance = new rosu.Performance(scoreParams).calculate(
currentBeatmap
);
const fcPerformance = new rosu.Performance({
lazer: false,
mods: this.Mods,
misses: 0,
accuracy: this.Accuracy
Expand Down
Loading

0 comments on commit 2d5ac58

Please sign in to comment.