diff --git a/projects/backend/src/service/score.service.ts b/projects/backend/src/service/score.service.ts index d577063..c9bc852 100644 --- a/projects/backend/src/service/score.service.ts +++ b/projects/backend/src/service/score.service.ts @@ -28,7 +28,8 @@ import { BeatLeaderScoreToken } from "@ssr/common/types/token/beatleader/beatlea import { AdditionalScoreData, AdditionalScoreDataModel, -} from "../../../common/src/model/additional-score-data/additional-score-data"; +} from "@ssr/common/model/additional-score-data/additional-score-data"; +import { BeatLeaderScoreImprovementToken } from "@ssr/common/types/token/beatleader/beatleader-score-improvement-token"; const playerScoresCache = new SSRCache({ ttl: 1000 * 60, // 1 minute @@ -182,6 +183,10 @@ export class ScoreService { return; } + const getMisses = (score: BeatLeaderScoreToken | BeatLeaderScoreImprovementToken) => { + return score.missedNotes + score.badCuts + score.bombCuts; + }; + const difficulty = leaderboard.difficulty; const difficultyKey = `${difficulty.difficultyName.replace("Plus", "+")}-${difficulty.modeName}`; const rawScoreImprovement = score.scoreImprovement; @@ -191,7 +196,7 @@ export class ScoreService { songDifficulty: difficultyKey, songScore: score.baseScore, misses: { - misses: score.missedNotes + score.badCuts + score.bombCuts, + misses: getMisses(score), missedNotes: score.missedNotes, bombCuts: score.bombCuts, badCuts: score.badCuts, @@ -209,18 +214,13 @@ export class ScoreService { data.scoreImprovement = { score: rawScoreImprovement.score, misses: { - misses: rawScoreImprovement.missedNotes + rawScoreImprovement.badCuts + rawScoreImprovement.bombCuts, + misses: getMisses(rawScoreImprovement), missedNotes: rawScoreImprovement.missedNotes, bombCuts: rawScoreImprovement.bombCuts, badCuts: rawScoreImprovement.badCuts, wallsHit: rawScoreImprovement.wallsHit, }, accuracy: rawScoreImprovement.accuracy * 100, - fullCombo: - rawScoreImprovement.missedNotes == 0 && - rawScoreImprovement.bombCuts == 0 && - rawScoreImprovement.badCuts == 0 && - rawScoreImprovement.wallsHit == 0, handAccuracy: { left: rawScoreImprovement.accLeft, right: rawScoreImprovement.accRight, diff --git a/projects/common/src/model/additional-score-data/additional-score-data.ts b/projects/common/src/model/additional-score-data/additional-score-data.ts index 89b1f0e..91c0782 100644 --- a/projects/common/src/model/additional-score-data/additional-score-data.ts +++ b/projects/common/src/model/additional-score-data/additional-score-data.ts @@ -103,11 +103,6 @@ export class AdditionalScoreData { */ misses: Misses; - /** - * Whether the play was a full combo. - */ - fullCombo: boolean; - /** * The change in the hand accuracy. */ diff --git a/projects/common/src/utils/number-utils.ts b/projects/common/src/utils/number-utils.ts index 7f4830e..ad0e6db 100644 --- a/projects/common/src/utils/number-utils.ts +++ b/projects/common/src/utils/number-utils.ts @@ -41,3 +41,16 @@ export function formatNumber(num: number, type: "number" | "pp" = "number") { } return formatNumberWithCommas(num); } + +/** + * Ensures a number is always positive + * + * @param num the number to ensure + * @returns the positive number + */ +export function ensurePositiveNumber(num: number) { + if (num == -0) { + return 0; + } + return num < 0 ? num * -1 : num; +} diff --git a/projects/website/src/common/change.tsx b/projects/website/src/common/change.tsx index db98c4e..17e0ead 100644 --- a/projects/website/src/common/change.tsx +++ b/projects/website/src/common/change.tsx @@ -8,7 +8,7 @@ import React from "react"; * @param formatValue the function to format the value */ export function renderChange(change: number | undefined, isPp: boolean, formatValue: (value: number) => string) { - if (change === 0 || (change && change < 0.01) || change === undefined) { + if (change === 0 || (change && change > 0 && change < 0.01) || change === undefined) { return null; } diff --git a/projects/website/src/components/score/badges/score-misses.tsx b/projects/website/src/components/score/badges/score-misses.tsx index 69da21b..b6ef722 100644 --- a/projects/website/src/components/score/badges/score-misses.tsx +++ b/projects/website/src/components/score/badges/score-misses.tsx @@ -20,11 +20,11 @@ export default function ScoreMissesBadge({ score, hideXMark }: ScoreMissesBadgeP const previousScoreMisses: Misses | undefined = misses && additionalData && scoreImprovement && { - misses: misses.misses - scoreImprovement.misses.misses, - missedNotes: misses.missedNotes - scoreImprovement.misses.missedNotes, - badCuts: misses.badCuts - scoreImprovement.misses.badCuts, - bombCuts: misses.bombCuts - scoreImprovement.misses.bombCuts, - wallsHit: misses.wallsHit - scoreImprovement.misses.wallsHit, + misses: (scoreImprovement.misses.misses - misses.misses) * -1, + missedNotes: (scoreImprovement.misses.missedNotes + misses.missedNotes) * -1, + badCuts: (scoreImprovement.misses.badCuts + misses.badCuts) * -1, + bombCuts: (scoreImprovement.misses.bombCuts + misses.bombCuts) * -1, + wallsHit: (scoreImprovement.misses.wallsHit - misses.wallsHit) * -1, }; return ( @@ -48,10 +48,9 @@ export default function ScoreMissesBadge({ score, hideXMark }: ScoreMissesBadgeP badCuts={previousScoreMisses.badCuts} bombCuts={previousScoreMisses.bombCuts} wallsHit={previousScoreMisses.wallsHit} - fullCombo={scoreImprovement.fullCombo} >
- {scoreImprovement.fullCombo ? ( + {previousScoreMisses.misses == 0 ? (

FC

) : ( formatNumberWithCommas(previousScoreMisses.misses) diff --git a/projects/website/src/components/score/score-misses-tooltip.tsx b/projects/website/src/components/score/score-misses-tooltip.tsx index 1862160..cfa4c80 100644 --- a/projects/website/src/components/score/score-misses-tooltip.tsx +++ b/projects/website/src/components/score/score-misses-tooltip.tsx @@ -1,4 +1,4 @@ -import { formatNumberWithCommas } from "@ssr/common/utils/number-utils"; +import { ensurePositiveNumber, formatNumberWithCommas } from "@ssr/common/utils/number-utils"; import Tooltip from "@/components/tooltip"; type ScoreMissesTooltipProps = { @@ -29,12 +29,12 @@ export function ScoreMissesTooltip({ {!fullCombo ? ( <>

Misses

-

Missed Notes: {formatNumberWithCommas(missedNotes)}

-

Bad Cuts: {formatNumberWithCommas(badCuts)}

+

Missed Notes: {formatNumberWithCommas(ensurePositiveNumber(missedNotes))}

+

Bad Cuts: {formatNumberWithCommas(ensurePositiveNumber(badCuts))}

{bombCuts !== undefined && wallsHit !== undefined && ( <> -

Bomb Cuts: {formatNumberWithCommas(bombCuts)}

-

Wall Hits: {formatNumberWithCommas(wallsHit)}

+

Bomb Cuts: {formatNumberWithCommas(ensurePositiveNumber(bombCuts))}

+

Wall Hits: {formatNumberWithCommas(ensurePositiveNumber(wallsHit))}

)}