bl score fixes
All checks were successful
Deploy Backend / docker (ubuntu-latest) (push) Successful in 46s
Deploy Website / docker (ubuntu-latest) (push) Successful in 2m24s

This commit is contained in:
Lee 2024-10-22 17:48:32 +01:00
parent 9c20aff89d
commit f090c0dcbb
6 changed files with 33 additions and 26 deletions

View File

@ -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,

View File

@ -103,11 +103,6 @@ export class AdditionalScoreData {
*/
misses: Misses;
/**
* Whether the play was a full combo.
*/
fullCombo: boolean;
/**
* The change in the hand accuracy.
*/

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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}
>
<div className="flex gap-1 items-center">
{scoreImprovement.fullCombo ? (
{previousScoreMisses.misses == 0 ? (
<p className="text-green-400">FC</p>
) : (
formatNumberWithCommas(previousScoreMisses.misses)

View File

@ -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 ? (
<>
<p className="font-semibold">Misses</p>
<p>Missed Notes: {formatNumberWithCommas(missedNotes)}</p>
<p>Bad Cuts: {formatNumberWithCommas(badCuts)}</p>
<p>Missed Notes: {formatNumberWithCommas(ensurePositiveNumber(missedNotes))}</p>
<p>Bad Cuts: {formatNumberWithCommas(ensurePositiveNumber(badCuts))}</p>
{bombCuts !== undefined && wallsHit !== undefined && (
<>
<p>Bomb Cuts: {formatNumberWithCommas(bombCuts)}</p>
<p>Wall Hits: {formatNumberWithCommas(wallsHit)}</p>
<p>Bomb Cuts: {formatNumberWithCommas(ensurePositiveNumber(bombCuts))}</p>
<p>Wall Hits: {formatNumberWithCommas(ensurePositiveNumber(wallsHit))}</p>
</>
)}
</>