bl score fixes
This commit is contained in:
parent
9c20aff89d
commit
f090c0dcbb
@ -28,7 +28,8 @@ import { BeatLeaderScoreToken } from "@ssr/common/types/token/beatleader/beatlea
|
|||||||
import {
|
import {
|
||||||
AdditionalScoreData,
|
AdditionalScoreData,
|
||||||
AdditionalScoreDataModel,
|
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({
|
const playerScoresCache = new SSRCache({
|
||||||
ttl: 1000 * 60, // 1 minute
|
ttl: 1000 * 60, // 1 minute
|
||||||
@ -182,6 +183,10 @@ export class ScoreService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getMisses = (score: BeatLeaderScoreToken | BeatLeaderScoreImprovementToken) => {
|
||||||
|
return score.missedNotes + score.badCuts + score.bombCuts;
|
||||||
|
};
|
||||||
|
|
||||||
const difficulty = leaderboard.difficulty;
|
const difficulty = leaderboard.difficulty;
|
||||||
const difficultyKey = `${difficulty.difficultyName.replace("Plus", "+")}-${difficulty.modeName}`;
|
const difficultyKey = `${difficulty.difficultyName.replace("Plus", "+")}-${difficulty.modeName}`;
|
||||||
const rawScoreImprovement = score.scoreImprovement;
|
const rawScoreImprovement = score.scoreImprovement;
|
||||||
@ -191,7 +196,7 @@ export class ScoreService {
|
|||||||
songDifficulty: difficultyKey,
|
songDifficulty: difficultyKey,
|
||||||
songScore: score.baseScore,
|
songScore: score.baseScore,
|
||||||
misses: {
|
misses: {
|
||||||
misses: score.missedNotes + score.badCuts + score.bombCuts,
|
misses: getMisses(score),
|
||||||
missedNotes: score.missedNotes,
|
missedNotes: score.missedNotes,
|
||||||
bombCuts: score.bombCuts,
|
bombCuts: score.bombCuts,
|
||||||
badCuts: score.badCuts,
|
badCuts: score.badCuts,
|
||||||
@ -209,18 +214,13 @@ export class ScoreService {
|
|||||||
data.scoreImprovement = {
|
data.scoreImprovement = {
|
||||||
score: rawScoreImprovement.score,
|
score: rawScoreImprovement.score,
|
||||||
misses: {
|
misses: {
|
||||||
misses: rawScoreImprovement.missedNotes + rawScoreImprovement.badCuts + rawScoreImprovement.bombCuts,
|
misses: getMisses(rawScoreImprovement),
|
||||||
missedNotes: rawScoreImprovement.missedNotes,
|
missedNotes: rawScoreImprovement.missedNotes,
|
||||||
bombCuts: rawScoreImprovement.bombCuts,
|
bombCuts: rawScoreImprovement.bombCuts,
|
||||||
badCuts: rawScoreImprovement.badCuts,
|
badCuts: rawScoreImprovement.badCuts,
|
||||||
wallsHit: rawScoreImprovement.wallsHit,
|
wallsHit: rawScoreImprovement.wallsHit,
|
||||||
},
|
},
|
||||||
accuracy: rawScoreImprovement.accuracy * 100,
|
accuracy: rawScoreImprovement.accuracy * 100,
|
||||||
fullCombo:
|
|
||||||
rawScoreImprovement.missedNotes == 0 &&
|
|
||||||
rawScoreImprovement.bombCuts == 0 &&
|
|
||||||
rawScoreImprovement.badCuts == 0 &&
|
|
||||||
rawScoreImprovement.wallsHit == 0,
|
|
||||||
handAccuracy: {
|
handAccuracy: {
|
||||||
left: rawScoreImprovement.accLeft,
|
left: rawScoreImprovement.accLeft,
|
||||||
right: rawScoreImprovement.accRight,
|
right: rawScoreImprovement.accRight,
|
||||||
|
@ -103,11 +103,6 @@ export class AdditionalScoreData {
|
|||||||
*/
|
*/
|
||||||
misses: Misses;
|
misses: Misses;
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the play was a full combo.
|
|
||||||
*/
|
|
||||||
fullCombo: boolean;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The change in the hand accuracy.
|
* The change in the hand accuracy.
|
||||||
*/
|
*/
|
||||||
|
@ -41,3 +41,16 @@ export function formatNumber(num: number, type: "number" | "pp" = "number") {
|
|||||||
}
|
}
|
||||||
return formatNumberWithCommas(num);
|
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;
|
||||||
|
}
|
||||||
|
@ -8,7 +8,7 @@ import React from "react";
|
|||||||
* @param formatValue the function to format the value
|
* @param formatValue the function to format the value
|
||||||
*/
|
*/
|
||||||
export function renderChange(change: number | undefined, isPp: boolean, formatValue: (value: number) => string) {
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,11 +20,11 @@ export default function ScoreMissesBadge({ score, hideXMark }: ScoreMissesBadgeP
|
|||||||
const previousScoreMisses: Misses | undefined = misses &&
|
const previousScoreMisses: Misses | undefined = misses &&
|
||||||
additionalData &&
|
additionalData &&
|
||||||
scoreImprovement && {
|
scoreImprovement && {
|
||||||
misses: misses.misses - scoreImprovement.misses.misses,
|
misses: (scoreImprovement.misses.misses - misses.misses) * -1,
|
||||||
missedNotes: misses.missedNotes - scoreImprovement.misses.missedNotes,
|
missedNotes: (scoreImprovement.misses.missedNotes + misses.missedNotes) * -1,
|
||||||
badCuts: misses.badCuts - scoreImprovement.misses.badCuts,
|
badCuts: (scoreImprovement.misses.badCuts + misses.badCuts) * -1,
|
||||||
bombCuts: misses.bombCuts - scoreImprovement.misses.bombCuts,
|
bombCuts: (scoreImprovement.misses.bombCuts + misses.bombCuts) * -1,
|
||||||
wallsHit: misses.wallsHit - scoreImprovement.misses.wallsHit,
|
wallsHit: (scoreImprovement.misses.wallsHit - misses.wallsHit) * -1,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -48,10 +48,9 @@ export default function ScoreMissesBadge({ score, hideXMark }: ScoreMissesBadgeP
|
|||||||
badCuts={previousScoreMisses.badCuts}
|
badCuts={previousScoreMisses.badCuts}
|
||||||
bombCuts={previousScoreMisses.bombCuts}
|
bombCuts={previousScoreMisses.bombCuts}
|
||||||
wallsHit={previousScoreMisses.wallsHit}
|
wallsHit={previousScoreMisses.wallsHit}
|
||||||
fullCombo={scoreImprovement.fullCombo}
|
|
||||||
>
|
>
|
||||||
<div className="flex gap-1 items-center">
|
<div className="flex gap-1 items-center">
|
||||||
{scoreImprovement.fullCombo ? (
|
{previousScoreMisses.misses == 0 ? (
|
||||||
<p className="text-green-400">FC</p>
|
<p className="text-green-400">FC</p>
|
||||||
) : (
|
) : (
|
||||||
formatNumberWithCommas(previousScoreMisses.misses)
|
formatNumberWithCommas(previousScoreMisses.misses)
|
||||||
|
@ -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";
|
import Tooltip from "@/components/tooltip";
|
||||||
|
|
||||||
type ScoreMissesTooltipProps = {
|
type ScoreMissesTooltipProps = {
|
||||||
@ -29,12 +29,12 @@ export function ScoreMissesTooltip({
|
|||||||
{!fullCombo ? (
|
{!fullCombo ? (
|
||||||
<>
|
<>
|
||||||
<p className="font-semibold">Misses</p>
|
<p className="font-semibold">Misses</p>
|
||||||
<p>Missed Notes: {formatNumberWithCommas(missedNotes)}</p>
|
<p>Missed Notes: {formatNumberWithCommas(ensurePositiveNumber(missedNotes))}</p>
|
||||||
<p>Bad Cuts: {formatNumberWithCommas(badCuts)}</p>
|
<p>Bad Cuts: {formatNumberWithCommas(ensurePositiveNumber(badCuts))}</p>
|
||||||
{bombCuts !== undefined && wallsHit !== undefined && (
|
{bombCuts !== undefined && wallsHit !== undefined && (
|
||||||
<>
|
<>
|
||||||
<p>Bomb Cuts: {formatNumberWithCommas(bombCuts)}</p>
|
<p>Bomb Cuts: {formatNumberWithCommas(ensurePositiveNumber(bombCuts))}</p>
|
||||||
<p>Wall Hits: {formatNumberWithCommas(wallsHit)}</p>
|
<p>Wall Hits: {formatNumberWithCommas(ensurePositiveNumber(wallsHit))}</p>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
Reference in New Issue
Block a user