diff --git a/src/app/(stats)/player/[ign]/_client.tsx b/src/app/(stats)/player/[ign]/_client.tsx index 17d7e82..d39133b 100644 --- a/src/app/(stats)/player/[ign]/_client.tsx +++ b/src/app/(stats)/player/[ign]/_client.tsx @@ -22,6 +22,7 @@ import MegaWallsStats from "./_stats/megawalls/megawalls" import MurderMysteryStats from "./_stats/murder-mystery/murder-mystery" import PitStats from "./_stats/pit/pit" import SkyWarsStats from "./_stats/skywars/skywars" +import SpeedUHCStats from "./_stats/speeduhc/speeduhc" import TNTGamesStats from "./_stats/tnt-games/tnt-games" import UHCStats from "./_stats/uhc/uhc" import WoolGamesStats from "./_stats/woolgames/woolgames" @@ -92,10 +93,11 @@ export function PlayerStats( "copsandcrims": , "woolgames": , "blitz": , - "arcade": + "arcade": , + "speeduhc": } as const - const defaultOrder = Object.keys(statsComponents).sort() + const defaultOrder = Object.keys(statsComponents) const orderToUse = layout || defaultOrder const [statsOrder, setStatsOrder] = useState(layout || defaultOrder) diff --git a/src/app/(stats)/player/[ign]/_stats/speeduhc/progress.tsx b/src/app/(stats)/player/[ign]/_stats/speeduhc/progress.tsx new file mode 100644 index 0000000..9e167d4 --- /dev/null +++ b/src/app/(stats)/player/[ign]/_stats/speeduhc/progress.tsx @@ -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 +} diff --git a/src/app/(stats)/player/[ign]/_stats/speeduhc/speeduhc.tsx b/src/app/(stats)/player/[ign]/_stats/speeduhc/speeduhc.tsx new file mode 100644 index 0000000..09352a4 --- /dev/null +++ b/src/app/(stats)/player/[ign]/_stats/speeduhc/speeduhc.tsx @@ -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 ( + Star

, + stat:

{`[${Math.floor(star)}❋]`}

+ }, + { + title:

KD

, + stat:

{kd}

+ }, + { + title:

Wins

, + stat:

{formatNumber(stats.wins)}

+ }, + { + title:

WL

, + stat:

{wl}

+ } + ]} + > + + +
+ ) +} diff --git a/src/data/hypixel/speeduhc.ts b/src/data/hypixel/speeduhc.ts new file mode 100644 index 0000000..93e8b57 --- /dev/null +++ b/src/data/hypixel/speeduhc.ts @@ -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 diff --git a/src/lib/hypixel/speeduhc/general.ts b/src/lib/hypixel/speeduhc/general.ts new file mode 100644 index 0000000..bc12cef --- /dev/null +++ b/src/lib/hypixel/speeduhc/general.ts @@ -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 +} diff --git a/src/lib/schema/player.ts b/src/lib/schema/player.ts index 3fd8288..9896c1f 100644 --- a/src/lib/schema/player.ts +++ b/src/lib/schema/player.ts @@ -10,6 +10,7 @@ import { murderMysteryStatsSchema, pitStats, skywarsStatsSchema, + speedUhcStatsSchema, tntGamesStatsSchema, uhcSchema, woolGamesStatsSchema @@ -40,7 +41,8 @@ export const playerSchema = z.looseObject({ MCGO: copsAndCrimsStatsSchema.optional(), WoolGames: woolGamesStatsSchema.optional(), HungerGames: blitzStatsSchema.optional(), - Arcade: arcadeStatsSchema.optional() + Arcade: arcadeStatsSchema.optional(), + SpeedUHC: speedUhcStatsSchema.optional() }).transform(({ Walls3, MCGO, HungerGames, ...rest }) => { return { MegaWalls: Walls3, diff --git a/src/lib/schema/stats.ts b/src/lib/schema/stats.ts index 897b741..3b15df7 100644 --- a/src/lib/schema/stats.ts +++ b/src/lib/schema/stats.ts @@ -1047,3 +1047,11 @@ export const arcadeStatsSchema = z.object({ ...arcadeZombiesModeStats(), ...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) +})