Skip to content

Commit

Permalink
fix: Fix beatmap gamemode & New field isConvert in v2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
cyperdark committed Nov 3, 2024
1 parent f582339 commit 6331b4f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/tosu/src/api/types/v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export interface Profile {
}

export interface Beatmap {
isConvert: boolean;
time: BeatmapTime;
status: NumberName;
checksum: string;
Expand Down
8 changes: 8 additions & 0 deletions packages/tosu/src/api/utils/buildResultV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ export const buildResult = (instanceManager: InstanceManager): ApiAnswer => {
? gamePlayData.Mods
: allTimesData.MenuMods;

const currentMode =
allTimesData.Status === 2
? gamePlayData.Mode
: allTimesData.Status === 7
? resultsScreenData.Mode
: menuData.MenuGameMode;

const resultScreenHits = {
300: resultsScreenData.Hit300,
geki: resultsScreenData.HitGeki,
Expand Down Expand Up @@ -211,6 +218,7 @@ export const buildResult = (instanceManager: InstanceManager): ApiAnswer => {
backgroundColour: userProfile.backgroundColour?.toString(16)
},
beatmap: {
isConvert: beatmapPpData.Mode !== currentMode,
time: {
live: allTimesData.PlayTime,
firstObject: beatmapPpData.timings.firstObj,
Expand Down
3 changes: 2 additions & 1 deletion packages/tosu/src/entities/BeatmapPpData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,8 @@ export class BeatmapPPData extends AbstractEntity {
this.timings.firstObj = firstObj;
this.timings.full = full;

this.Mode = this.beatmap.mode;

this.resetReportCount('BPPD(updateMapMetadataTimings)');
} catch (exc) {
this.reportError(
Expand Down Expand Up @@ -596,7 +598,6 @@ export class BeatmapPPData extends AbstractEntity {

this.strains = oldStrains;
this.strainsAll = resultStrains;
this.Mode = strains.mode;

strains.free();

Expand Down

0 comments on commit 6331b4f

Please sign in to comment.