Skip to content

Commit

Permalink
Merge pull request #184 from KotRikD/fix/undefined
Browse files Browse the repository at this point in the history
Attempt to fix undefined on converts
  • Loading branch information
cyperdark authored Sep 9, 2024
2 parents 9b01651 + bb249de commit 8d7c5a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 18 additions & 10 deletions packages/tosu/src/entities/BeatmapPpData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,23 @@ export class BeatmapPPData extends AbstractEntity {
type: 'curr' | 'fc',
attributes: rosu.PerformanceAttributes
) {
if (type !== 'curr' && type !== 'fc') return;

this[`${type}PPAttributes`] = {
ppAccuracy: attributes.ppAccuracy || 0.0,
ppAim: attributes.ppAim || 0.0,
ppDifficulty: attributes.ppDifficulty || 0.0,
ppFlashlight: attributes.ppFlashlight || 0.0,
ppSpeed: attributes.ppSpeed || 0.0
};
try {
if (type !== 'curr' && type !== 'fc') return;

this[`${type}PPAttributes`] = {
ppAccuracy: attributes.ppAccuracy || 0.0,
ppAim: attributes.ppAim || 0.0,
ppDifficulty: attributes.ppDifficulty || 0.0,
ppFlashlight: attributes.ppFlashlight || 0.0,
ppSpeed: attributes.ppSpeed || 0.0
};
} catch (exc) {
wLogger.error(
`BPPD(updatePPAttributes)-${type}`,
(exc as any).message
);
wLogger.debug(`BPPD(updatePPAttributes)-${type}`, exc);
}
}

updateCurrentAttributes(stars: number, pp: number) {
Expand Down Expand Up @@ -292,7 +300,7 @@ export class BeatmapPPData extends AbstractEntity {
const attributes = new rosu.BeatmapAttributesBuilder({
map: this.beatmap,
mods: currentMods,
mode: menuData.MenuGameMode
mode: currentMode
}).build();

const fcPerformance = new rosu.Performance({
Expand Down
2 changes: 1 addition & 1 deletion packages/tosu/src/entities/GamePlayData/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ export class GamePlayData extends AbstractEntity {

if (fcPerformance) {
beatmapPpData.currAttributes.fcPP = fcPerformance.pp;
beatmapPpData.updatePPAttributes('fc', currPerformance);
beatmapPpData.updatePPAttributes('fc', fcPerformance);
}

this.previousPassedObjects = passedObjects;
Expand Down

0 comments on commit 8d7c5a8

Please sign in to comment.