Skip to content

Commit

Permalink
Merge pull request #181 from KotRikD/fix/bpm-mods-multiplier
Browse files Browse the repository at this point in the history
Multiply bpm by selected mods
  • Loading branch information
KotRikD authored Sep 4, 2024
2 parents 29caa72 + 38a2ee3 commit 3fe5a19
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 12 additions & 2 deletions packages/tosu/src/entities/BeatmapPpData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { BeatmapStrains } from '@/api/types/v1';
import { AbstractEntity } from '@/entities/AbstractEntity';
import { OsuInstance } from '@/objects/instanceManager/osuInstance';
import { fixDecimals } from '@/utils/converters';
import { OsuMods } from '@/utils/osuMods.types';

interface BeatmapPPAcc {
'100': number;
Expand Down Expand Up @@ -634,15 +635,24 @@ export class BeatmapPPData extends AbstractEntity {
}
}

updateRealTimeBPM(timeMS: number) {
updateRealTimeBPM(timeMS: number, mods: number) {
if (!this.lazerBeatmap) return;

this.realtimeBPM =
const multiply =
(mods & OsuMods.DoubleTime) === OsuMods.DoubleTime ||
(mods & OsuMods.Nightcore) === OsuMods.Nightcore
? 1.5
: (mods & OsuMods.HalfTime) === OsuMods.HalfTime
? 0.75
: 1;
const bpm =
this.lazerBeatmap.controlPoints.timingPoints
// @ts-ignore
.toReversed()
.find((r) => r.startTime <= timeMS && r.bpm !== 0)?.bpm ||
this.lazerBeatmap.controlPoints.timingPoints[0]?.bpm ||
0.0;

this.realtimeBPM = Math.round(bpm * multiply);
}
}
5 changes: 4 additions & 1 deletion packages/tosu/src/objects/instanceManager/osuInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ export class OsuInstance {
this.previousMP3Length = menuData.MP3Length;
}

beatmapPpData.updateRealTimeBPM(allTimesData.PlayTime);
beatmapPpData.updateRealTimeBPM(
allTimesData.PlayTime,
currentMods
);

switch (allTimesData.Status) {
case 0:
Expand Down

0 comments on commit 3fe5a19

Please sign in to comment.