From 38a2ee3f19a5c652bdc76d6e0b1d938af3c6a0b0 Mon Sep 17 00:00:00 2001 From: ck <21735205+cyperdark@users.noreply.github.com> Date: Wed, 4 Sep 2024 19:15:03 +0300 Subject: [PATCH] fix: multiply bpm by current selected mods --- packages/tosu/src/entities/BeatmapPpData/index.ts | 14 ++++++++++++-- .../src/objects/instanceManager/osuInstance.ts | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/tosu/src/entities/BeatmapPpData/index.ts b/packages/tosu/src/entities/BeatmapPpData/index.ts index 36d90be..758c4ea 100644 --- a/packages/tosu/src/entities/BeatmapPpData/index.ts +++ b/packages/tosu/src/entities/BeatmapPpData/index.ts @@ -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; @@ -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); } } diff --git a/packages/tosu/src/objects/instanceManager/osuInstance.ts b/packages/tosu/src/objects/instanceManager/osuInstance.ts index 70533c5..7638959 100644 --- a/packages/tosu/src/objects/instanceManager/osuInstance.ts +++ b/packages/tosu/src/objects/instanceManager/osuInstance.ts @@ -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: