add acc ranges to the score (eg: A, S, SS, etc)
All checks were successful
Deploy / deploy (push) Successful in 5m19s
All checks were successful
Deploy / deploy (push) Successful in 5m19s
This commit is contained in:
parent
bb5506148c
commit
442e52d22d
@ -4,7 +4,11 @@ import * as Sentry from "@sentry/nextjs";
|
|||||||
import NextError from "next/error";
|
import NextError from "next/error";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
|
|
||||||
export default function GlobalError({ error }: { error: Error & { digest?: string } }) {
|
export default function GlobalError({
|
||||||
|
error,
|
||||||
|
}: {
|
||||||
|
error: Error & { digest?: string };
|
||||||
|
}) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Sentry.captureException(error);
|
Sentry.captureException(error);
|
||||||
}, [error]);
|
}, [error]);
|
||||||
|
@ -28,7 +28,7 @@ const scoreBadges: ScoreBadge[] = [
|
|||||||
* @param acc - The accuracy for the score
|
* @param acc - The accuracy for the score
|
||||||
* @returns The corresponding color for the accuracy.
|
* @returns The corresponding color for the accuracy.
|
||||||
*/
|
*/
|
||||||
export function getScoreColorFromAccuracy(acc: number): ScoreBadge {
|
export function getScoreBadgeFromAccuracy(acc: number): ScoreBadge {
|
||||||
// Check for SS+ first since it has no upper limit
|
// Check for SS+ first since it has no upper limit
|
||||||
if (acc >= 95) {
|
if (acc >= 95) {
|
||||||
return scoreBadges[0]; // SS+ color
|
return scoreBadges[0]; // SS+ color
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { formatNumberWithCommas, formatPp } from "@/common/number-utils";
|
import {formatNumberWithCommas, formatPp} from "@/common/number-utils";
|
||||||
import { GlobeAmericasIcon } from "@heroicons/react/24/solid";
|
import {GlobeAmericasIcon} from "@heroicons/react/24/solid";
|
||||||
import Card from "../card";
|
import Card from "../card";
|
||||||
import CountryFlag from "../country-flag";
|
import CountryFlag from "../country-flag";
|
||||||
import { Avatar, AvatarImage } from "../ui/avatar";
|
import {Avatar, AvatarImage} from "../ui/avatar";
|
||||||
import ClaimProfile from "./claim-profile";
|
import ClaimProfile from "./claim-profile";
|
||||||
import PlayerStats from "./player-stats";
|
import PlayerStats from "./player-stats";
|
||||||
import ScoreSaberPlayer from "@/common/model/player/impl/scoresaber-player";
|
import ScoreSaberPlayer from "@/common/model/player/impl/scoresaber-player";
|
||||||
import Tooltip from "@/components/tooltip";
|
import Tooltip from "@/components/tooltip";
|
||||||
import { ReactElement } from "react";
|
import {ReactElement} from "react";
|
||||||
import PlayerTrackedStatus from "@/components/player/player-tracked-status";
|
import PlayerTrackedStatus from "@/components/player/player-tracked-status";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import ScoreSaberLeaderboardToken from "@/common/model/token/scoresaber/score-saber-leaderboard-token";
|
import ScoreSaberLeaderboardToken from "@/common/model/token/scoresaber/score-saber-leaderboard-token";
|
||||||
import ScoreSaberScoreToken from "@/common/model/token/scoresaber/score-saber-score-token";
|
import ScoreSaberScoreToken from "@/common/model/token/scoresaber/score-saber-score-token";
|
||||||
import { formatNumberWithCommas, formatPp } from "@/common/number-utils";
|
import { formatNumberWithCommas, formatPp } from "@/common/number-utils";
|
||||||
import { getScoreColorFromAccuracy } from "@/common/song-utils";
|
import { getScoreBadgeFromAccuracy } from "@/common/song-utils";
|
||||||
import StatValue from "@/components/stat-value";
|
import StatValue from "@/components/stat-value";
|
||||||
import { XMarkIcon } from "@heroicons/react/24/solid";
|
import { XMarkIcon } from "@heroicons/react/24/solid";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
import Tooltip from "@/components/tooltip";
|
||||||
|
|
||||||
type Badge = {
|
type Badge = {
|
||||||
name: string;
|
name: string;
|
||||||
@ -39,14 +40,36 @@ const badges: Badge[] = [
|
|||||||
leaderboard: ScoreSaberLeaderboardToken,
|
leaderboard: ScoreSaberLeaderboardToken,
|
||||||
) => {
|
) => {
|
||||||
const acc = (score.baseScore / leaderboard.maxScore) * 100;
|
const acc = (score.baseScore / leaderboard.maxScore) * 100;
|
||||||
return getScoreColorFromAccuracy(acc).color;
|
return getScoreBadgeFromAccuracy(acc).color;
|
||||||
},
|
},
|
||||||
create: (
|
create: (
|
||||||
score: ScoreSaberScoreToken,
|
score: ScoreSaberScoreToken,
|
||||||
leaderboard: ScoreSaberLeaderboardToken,
|
leaderboard: ScoreSaberLeaderboardToken,
|
||||||
) => {
|
) => {
|
||||||
const acc = (score.baseScore / leaderboard.maxScore) * 100;
|
const acc = (score.baseScore / leaderboard.maxScore) * 100;
|
||||||
return `${acc.toFixed(2)}%`;
|
const scoreBadge = getScoreBadgeFromAccuracy(acc);
|
||||||
|
let accDetails = `Accuracy ${scoreBadge.name != "-" ? scoreBadge.name : ""}`;
|
||||||
|
if (scoreBadge.max == null) {
|
||||||
|
accDetails += ` (> ${scoreBadge.min}%)`;
|
||||||
|
} else if (scoreBadge.min == null) {
|
||||||
|
accDetails += ` (< ${scoreBadge.max}%)`;
|
||||||
|
} else {
|
||||||
|
accDetails += ` (${scoreBadge.min}% - ${scoreBadge.max}%)`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Tooltip
|
||||||
|
display={
|
||||||
|
<div>
|
||||||
|
<p>{accDetails}</p>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<p className="cursor-default">{acc.toFixed(2)}%</p>
|
||||||
|
</Tooltip>
|
||||||
|
</>
|
||||||
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { useContext } from "react";
|
import {useContext} from "react";
|
||||||
import { DatabaseContext } from "@/components/loaders/database-loader";
|
import {DatabaseContext} from "@/components/loaders/database-loader";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the database context.
|
* Gets the database context.
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import * as Sentry from '@sentry/nextjs';
|
import * as Sentry from "@sentry/nextjs";
|
||||||
|
|
||||||
export async function register() {
|
export async function register() {
|
||||||
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
if (process.env.NEXT_RUNTIME === "nodejs") {
|
||||||
await import('../sentry.server.config');
|
await import("../sentry.server.config");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.NEXT_RUNTIME === 'edge') {
|
if (process.env.NEXT_RUNTIME === "edge") {
|
||||||
await import('../sentry.edge.config');
|
await import("../sentry.edge.config");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user