Skip to content

Commit

Permalink
fix: Remove RX and AP from pp and attributes calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
cyperdark committed Nov 22, 2024
1 parent ad9623c commit a6d74a6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
9 changes: 5 additions & 4 deletions packages/tosu/src/states/beatmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions packages/tosu/src/states/gameplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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(
Expand All @@ -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);

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions packages/tosu/src/states/resultScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions packages/tosu/src/utils/osuMods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { textMD5 } from '@tosu/common';
import {
CalculateMods,
IMods,
ModsLazer,
ModsOrder,
bitValues
} from '@/utils/osuMods.types';
Expand Down Expand Up @@ -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;
}
}

0 comments on commit a6d74a6

Please sign in to comment.