Skip to content

Commit

Permalink
fix: Fix result screen pp
Browse files Browse the repository at this point in the history
  • Loading branch information
cyperdark committed Jun 30, 2024
1 parent a39dbdb commit df7a0aa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
24 changes: 6 additions & 18 deletions packages/tosu/src/entities/ResultsScreenData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import rosu from 'rosu-pp-js';

import { AbstractEntity } from '@/entities/AbstractEntity';
import { OsuInstance } from '@/objects/instanceManager/osuInstance';
import {
calculateAccuracy,
calculateGrade,
calculatePassedObjects
} from '@/utils/calculators';
import { calculateAccuracy, calculateGrade } from '@/utils/calculators';
import { netDateBinaryToDate } from '@/utils/converters';
import { OsuMods } from '@/utils/osuMods.types';

Expand Down Expand Up @@ -159,29 +155,21 @@ export class ResultsScreenData extends AbstractEntity {
return;
}

const scoreParams = {
passedObjects: calculatePassedObjects(
this.Mode,
this.Hit300,
this.Hit100,
this.Hit50,
this.HitMiss,
this.HitKatu,
this.HitGeki
),
const scoreParams: rosu.PerformanceArgs = {
combo: this.MaxCombo,
mods: this.Mods,
nMisses: this.HitMiss,
misses: this.HitMiss,
n50: this.Hit50,
n100: this.Hit100,
n300: this.Hit300
n300: this.Hit300,
nKatu: this.HitKatu,
nGeki: this.HitGeki
};

const curPerformance = new rosu.Performance(scoreParams).calculate(
currentBeatmap
);
const fcPerformance = new rosu.Performance({
combo: curPerformance.difficulty.maxCombo,
mods: this.Mods,
misses: 0,
accuracy: this.Accuracy
Expand Down
18 changes: 14 additions & 4 deletions packages/tosu/src/objects/instanceManager/osuInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,8 @@ export class OsuInstance {
'menuData',
'allTimesData',
'gamePlayData',
'beatmapPpData'
'beatmapPpData',
'resultsScreenData'
]);

this.updateMapMetadata(entities);
Expand All @@ -411,12 +412,21 @@ export class OsuInstance {
allTimesData: AllTimesData;
gamePlayData: GamePlayData;
beatmapPpData: BeatmapPPData;
resultsScreenData: ResultsScreenData;
}) {
const { menuData, allTimesData, gamePlayData, beatmapPpData } = entries;
const {
menuData,
allTimesData,
gamePlayData,
beatmapPpData,
resultsScreenData
} = entries;
const currentMods =
allTimesData.Status === 2 || allTimesData.Status === 7
allTimesData.Status === 2
? gamePlayData.Mods
: allTimesData.MenuMods;
: allTimesData.Status === 7
? resultsScreenData.Mods
: allTimesData.MenuMods;

const currentState = `${menuData.MD5}:${menuData.MenuGameMode}:${currentMods}:${menuData.MP3Length}`;

Expand Down

0 comments on commit df7a0aa

Please sign in to comment.