Updates speed uhc stats
This commit is contained in:
@@ -22,6 +22,7 @@ import MegaWallsStats from "./_stats/megawalls/megawalls"
|
|||||||
import MurderMysteryStats from "./_stats/murder-mystery/murder-mystery"
|
import MurderMysteryStats from "./_stats/murder-mystery/murder-mystery"
|
||||||
import PitStats from "./_stats/pit/pit"
|
import PitStats from "./_stats/pit/pit"
|
||||||
import SkyWarsStats from "./_stats/skywars/skywars"
|
import SkyWarsStats from "./_stats/skywars/skywars"
|
||||||
|
import SpeedUHCStats from "./_stats/speeduhc/speeduhc"
|
||||||
import TNTGamesStats from "./_stats/tnt-games/tnt-games"
|
import TNTGamesStats from "./_stats/tnt-games/tnt-games"
|
||||||
import UHCStats from "./_stats/uhc/uhc"
|
import UHCStats from "./_stats/uhc/uhc"
|
||||||
import WoolGamesStats from "./_stats/woolgames/woolgames"
|
import WoolGamesStats from "./_stats/woolgames/woolgames"
|
||||||
@@ -92,10 +93,11 @@ export function PlayerStats(
|
|||||||
"copsandcrims": <CopsAndCrimsStats stats={stats.CopsAndCrims} />,
|
"copsandcrims": <CopsAndCrimsStats stats={stats.CopsAndCrims} />,
|
||||||
"woolgames": <WoolGamesStats stats={stats.WoolGames} />,
|
"woolgames": <WoolGamesStats stats={stats.WoolGames} />,
|
||||||
"blitz": <BlitzStats stats={stats.Blitz} />,
|
"blitz": <BlitzStats stats={stats.Blitz} />,
|
||||||
"arcade": <ArcadeStats stats={stats.Arcade} />
|
"arcade": <ArcadeStats stats={stats.Arcade} />,
|
||||||
|
"speeduhc": <SpeedUHCStats stats={stats.SpeedUHC} />
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
const defaultOrder = Object.keys(statsComponents).sort()
|
const defaultOrder = Object.keys(statsComponents)
|
||||||
const orderToUse = layout || defaultOrder
|
const orderToUse = layout || defaultOrder
|
||||||
|
|
||||||
const [statsOrder, setStatsOrder] = useState<string[]>(layout || defaultOrder)
|
const [statsOrder, setStatsOrder] = useState<string[]>(layout || defaultOrder)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { getProgress } from "@/lib/hypixel/general"
|
||||||
|
import { getSpeedUHCScore } from "@/lib/hypixel/speeduhc/general"
|
||||||
|
import { GenericProgress } from "../../_components/GenericProgress"
|
||||||
|
|
||||||
|
export default function SpeedUHCProgress({ level, score }: { level: number, score: number }) {
|
||||||
|
const nextScore = getSpeedUHCScore(level + 1)
|
||||||
|
const percent = getProgress(0, score, nextScore)
|
||||||
|
return <GenericProgress tooltipId="speeduhcprogress" tooltipContent={`${score}/${nextScore} Score`} percent={percent} className="bg-mc-white" />
|
||||||
|
}
|
||||||
43
src/app/(stats)/player/[ign]/_stats/speeduhc/speeduhc.tsx
Normal file
43
src/app/(stats)/player/[ign]/_stats/speeduhc/speeduhc.tsx
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import { Separator } from "@/components/ui/separator"
|
||||||
|
import { formatNumber } from "@/lib/formatters"
|
||||||
|
import { devide } from "@/lib/hypixel/general"
|
||||||
|
import { getSpeedUHCStar } from "@/lib/hypixel/speeduhc/general"
|
||||||
|
import { NonNullStats } from "@/lib/schema/player"
|
||||||
|
import GeneralStats from "../GeneralStats"
|
||||||
|
import SpeedUHCProgress from "./progress"
|
||||||
|
|
||||||
|
export default function SpeedUHCStats({ stats }: { stats: NonNullStats["SpeedUHC"] }) {
|
||||||
|
if (!stats) return null
|
||||||
|
|
||||||
|
const kd = formatNumber(devide(stats.kills, stats.deaths))
|
||||||
|
const wl = formatNumber(devide(stats.wins, stats.losses))
|
||||||
|
const star = getSpeedUHCStar(stats.score)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<GeneralStats
|
||||||
|
id="speeduhc"
|
||||||
|
title="Speed UHC"
|
||||||
|
collapsedStats={[
|
||||||
|
{
|
||||||
|
title: <p>Star</p>,
|
||||||
|
stat: <p className="text-mc-light-purple">{`[${Math.floor(star)}❋]`}</p>
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: <p>KD</p>,
|
||||||
|
stat: <p className="text-muted-foreground">{kd}</p>
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: <p>Wins</p>,
|
||||||
|
stat: <p className="text-muted-foreground">{formatNumber(stats.wins)}</p>
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: <p>WL</p>,
|
||||||
|
stat: <p className="text-muted-foreground">{wl}</p>
|
||||||
|
}
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Separator className="my-4" />
|
||||||
|
<SpeedUHCProgress level={Math.floor(star)} score={stats.score} />
|
||||||
|
</GeneralStats>
|
||||||
|
)
|
||||||
|
}
|
||||||
31
src/data/hypixel/speeduhc.ts
Normal file
31
src/data/hypixel/speeduhc.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
export const MODES = [
|
||||||
|
{ id: "solo_normal", name: "Solo Normal" },
|
||||||
|
{ id: "solo_insane", name: "Solo Insane" },
|
||||||
|
{ id: "team_normal", name: "Teams Normal" },
|
||||||
|
{ id: "team_insane", name: "Teams Insane" },
|
||||||
|
{ id: "", name: "Overall" }
|
||||||
|
] as const
|
||||||
|
export const TITLES = [
|
||||||
|
{ value: 0, name: "Hiker" },
|
||||||
|
{ value: 50, name: "Jogger" },
|
||||||
|
{ value: 300, name: "Runner" },
|
||||||
|
{ value: 1050, name: "Sprinter" },
|
||||||
|
{ value: 2560, name: "Turbo" },
|
||||||
|
{ value: 5550, name: "Sanic" },
|
||||||
|
{ value: 15550, name: "Hot Rod" },
|
||||||
|
{ value: 30550, name: "Bolt" },
|
||||||
|
{ value: 55550, name: "Zoom" },
|
||||||
|
{ value: 85550, name: "God Speed" }
|
||||||
|
] as const
|
||||||
|
export const MASTERIES = [
|
||||||
|
{ id: "mastery_wild_specialist", name: "Wild Specialist" },
|
||||||
|
{ id: "mastery_sniper", name: "Sniper" },
|
||||||
|
{ id: "mastery_berserk", name: "Berserk" },
|
||||||
|
{ id: "mastery_fortune", name: "Fortune" },
|
||||||
|
{ id: "mastery_master_baker", name: "Baker" },
|
||||||
|
{ id: "mastery_invigorate", name: "Invigorate" },
|
||||||
|
{ id: "mastery_huntsman", name: "Huntsman" },
|
||||||
|
{ id: "mastery_vampirism", name: "Vampirism" },
|
||||||
|
{ id: "mastery_guardian", name: "Guardian" },
|
||||||
|
{ id: "", name: "Overall" }
|
||||||
|
] as const
|
||||||
17
src/lib/hypixel/speeduhc/general.ts
Normal file
17
src/lib/hypixel/speeduhc/general.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { TITLES } from "@/data/hypixel/speeduhc"
|
||||||
|
|
||||||
|
export function getSpeedUHCStar(score: number) {
|
||||||
|
for (let i = 0; i < TITLES.length; i++) {
|
||||||
|
if (score < TITLES[i].value) {
|
||||||
|
return i + (score - TITLES[i - 1].value) / (TITLES[i].value - TITLES[i - 1].value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TITLES.length
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getSpeedUHCScore(level: number) {
|
||||||
|
if (level > TITLES.length) return TITLES.at(-1)!.value
|
||||||
|
if (level === 0) return TITLES.at(0)!.value
|
||||||
|
|
||||||
|
return TITLES.at(level - 1)!.value
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import {
|
|||||||
murderMysteryStatsSchema,
|
murderMysteryStatsSchema,
|
||||||
pitStats,
|
pitStats,
|
||||||
skywarsStatsSchema,
|
skywarsStatsSchema,
|
||||||
|
speedUhcStatsSchema,
|
||||||
tntGamesStatsSchema,
|
tntGamesStatsSchema,
|
||||||
uhcSchema,
|
uhcSchema,
|
||||||
woolGamesStatsSchema
|
woolGamesStatsSchema
|
||||||
@@ -40,7 +41,8 @@ export const playerSchema = z.looseObject({
|
|||||||
MCGO: copsAndCrimsStatsSchema.optional(),
|
MCGO: copsAndCrimsStatsSchema.optional(),
|
||||||
WoolGames: woolGamesStatsSchema.optional(),
|
WoolGames: woolGamesStatsSchema.optional(),
|
||||||
HungerGames: blitzStatsSchema.optional(),
|
HungerGames: blitzStatsSchema.optional(),
|
||||||
Arcade: arcadeStatsSchema.optional()
|
Arcade: arcadeStatsSchema.optional(),
|
||||||
|
SpeedUHC: speedUhcStatsSchema.optional()
|
||||||
}).transform(({ Walls3, MCGO, HungerGames, ...rest }) => {
|
}).transform(({ Walls3, MCGO, HungerGames, ...rest }) => {
|
||||||
return {
|
return {
|
||||||
MegaWalls: Walls3,
|
MegaWalls: Walls3,
|
||||||
|
|||||||
@@ -1047,3 +1047,11 @@ export const arcadeStatsSchema = z.object({
|
|||||||
...arcadeZombiesModeStats(),
|
...arcadeZombiesModeStats(),
|
||||||
...arcadeZombiesTypeStats()
|
...arcadeZombiesTypeStats()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const speedUhcStatsSchema = z.object({
|
||||||
|
kills: z.number().default(0),
|
||||||
|
deaths: z.number().default(0),
|
||||||
|
wins: z.number().default(0),
|
||||||
|
losses: z.number().default(0),
|
||||||
|
score: z.number().default(0)
|
||||||
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user