From a6d74a618c9528e25edf5c278c1d67d77432257e Mon Sep 17 00:00:00 2001 From: ck <21735205+cyperdark@users.noreply.github.com> Date: Sat, 23 Nov 2024 00:38:46 +0300 Subject: [PATCH] fix: Remove RX and AP from pp and attributes calculation --- packages/tosu/src/states/beatmap.ts | 9 +++++---- packages/tosu/src/states/gameplay.ts | 8 ++++---- packages/tosu/src/states/resultScreen.ts | 6 +++--- packages/tosu/src/utils/osuMods.ts | 12 ++++++++++++ 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/packages/tosu/src/states/beatmap.ts b/packages/tosu/src/states/beatmap.ts index bc56d7aa..f540d01a 100644 --- a/packages/tosu/src/states/beatmap.ts +++ b/packages/tosu/src/states/beatmap.ts @@ -13,6 +13,7 @@ import { BeatmapStrains } from '@/api/types/v1'; import { AbstractInstance } from '@/instances'; import { AbstractState } from '@/states'; import { fixDecimals } from '@/utils/converters'; +import { removeDebuffMods } from '@/utils/osuMods'; import { CalculateMods, ModsLazer } from '@/utils/osuMods.types'; interface BeatmapPPAcc { @@ -363,12 +364,12 @@ export class BeatmapPP extends AbstractState { this.beatmap.mode === 0 && this.beatmap.mode !== currentMode, map: this.beatmap, - mods: currentMods.array, + mods: removeDebuffMods(currentMods.array), mode: currentMode }).build(); const fcPerformance = new rosu.Performance({ - mods: currentMods.array, + mods: removeDebuffMods(currentMods.array), lazer: this.game.client === ClientType.lazer }).calculate(this.beatmap); @@ -381,7 +382,7 @@ export class BeatmapPP extends AbstractState { 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90 ]) { const calculate = new rosu.Performance({ - mods: currentMods.array, + mods: removeDebuffMods(currentMods.array), accuracy: acc, lazer: this.game.client === ClientType.lazer }).calculate(fcPerformance); @@ -527,7 +528,7 @@ export class BeatmapPP extends AbstractState { }; const difficulty = new rosu.Difficulty({ - mods: currentMods, + mods: removeDebuffMods(currentMods), lazer: this.game.client === ClientType.lazer }); const strains = difficulty.strains(this.beatmap); diff --git a/packages/tosu/src/states/gameplay.ts b/packages/tosu/src/states/gameplay.ts index cc41bed3..d884c877 100644 --- a/packages/tosu/src/states/gameplay.ts +++ b/packages/tosu/src/states/gameplay.ts @@ -5,7 +5,7 @@ import { AbstractInstance } from '@/instances'; import { AbstractState } from '@/states/index'; import { KeyOverlay, LeaderboardPlayer } from '@/states/types'; import { calculateGrade, calculatePassedObjects } from '@/utils/calculators'; -import { defaultCalculatedMods } from '@/utils/osuMods'; +import { defaultCalculatedMods, removeDebuffMods } from '@/utils/osuMods'; import { CalculateMods, OsuMods } from '@/utils/osuMods.types'; const defaultLBPlayer = { @@ -442,7 +442,7 @@ export class Gameplay extends AbstractState { this.performanceAttributes.free(); const difficulty = new rosu.Difficulty({ - mods: this.mods.array, + mods: removeDebuffMods(this.mods.array), lazer: this.game.client === ClientType.lazer }); this.gradualPerformance = new rosu.GradualPerformance( @@ -451,7 +451,7 @@ export class Gameplay extends AbstractState { ); this.performanceAttributes = new rosu.Performance({ - mods: this.mods.array, + mods: removeDebuffMods(this.mods.array), lazer: this.game.client === ClientType.lazer }).calculate(currentBeatmap); @@ -496,7 +496,7 @@ export class Gameplay extends AbstractState { )!; const fcPerformance = new rosu.Performance({ - mods: this.mods.array, + mods: removeDebuffMods(this.mods.array), misses: 0, accuracy: this.accuracy, lazer: this.game.client === ClientType.lazer diff --git a/packages/tosu/src/states/resultScreen.ts b/packages/tosu/src/states/resultScreen.ts index 7cfe213d..d0d4d0a0 100644 --- a/packages/tosu/src/states/resultScreen.ts +++ b/packages/tosu/src/states/resultScreen.ts @@ -4,7 +4,7 @@ import { ClientType, wLogger } from '@tosu/common'; import { AbstractInstance } from '@/instances'; import { AbstractState } from '@/states'; import { calculateAccuracy, calculateGrade } from '@/utils/calculators'; -import { defaultCalculatedMods } from '@/utils/osuMods'; +import { defaultCalculatedMods, removeDebuffMods } from '@/utils/osuMods'; import { CalculateMods } from '@/utils/osuMods.types'; export class ResultScreen extends AbstractState { @@ -138,7 +138,7 @@ export class ResultScreen extends AbstractState { const scoreParams: rosu.PerformanceArgs = { combo: this.maxCombo, - mods: this.mods.array, + mods: removeDebuffMods(this.mods.array), misses: this.hitMiss, n50: this.hit50, n100: this.hit100, @@ -154,7 +154,7 @@ export class ResultScreen extends AbstractState { currentBeatmap ); const fcPerformance = new rosu.Performance({ - mods: this.mods.array, + mods: removeDebuffMods(this.mods.array), misses: 0, accuracy: this.accuracy }).calculate(curPerformance); diff --git a/packages/tosu/src/utils/osuMods.ts b/packages/tosu/src/utils/osuMods.ts index 807591ce..5a2234fa 100644 --- a/packages/tosu/src/utils/osuMods.ts +++ b/packages/tosu/src/utils/osuMods.ts @@ -3,6 +3,7 @@ import { textMD5 } from '@tosu/common'; import { CalculateMods, IMods, + ModsLazer, ModsOrder, bitValues } from '@/utils/osuMods.types'; @@ -299,3 +300,14 @@ export const calculateMods = ( rate: settingsSpeedChange || speedChange }; }; + +export function removeDebuffMods(mods: ModsLazer) { + try { + const _mods = mods.filter( + (r) => !(r.acronym === 'RX' || r.acronym === 'AP') + ); + return _mods; + } catch (error) { + return mods; + } +}