Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix beatmap gamemode & New field isConvert in v2 api #212

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/server/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ export default function buildBaseApi(server: Server) {
if (query.nKatu) params.nKatu = +query.nKatu;
if (query.mods) params.mods = +query.mods;
if (query.acc) params.accuracy = +query.acc;
if (query.lazer) params.lazer = query.lazer ?? true;
if (query.lazer) params.lazer = query.lazer === 'true';

const calculate = new rosu.Performance(params).calculate(beatmap);
sendJson(res, calculate);
Expand Down
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
Loading