diff --git a/src/app/(stats)/player/[ign]/_stats/uhc/uhc.tsx b/src/app/(stats)/player/[ign]/_stats/uhc/uhc.tsx index 073e176..3fde4af 100644 --- a/src/app/(stats)/player/[ign]/_stats/uhc/uhc.tsx +++ b/src/app/(stats)/player/[ign]/_stats/uhc/uhc.tsx @@ -3,6 +3,7 @@ import { Card, CardContent } from "@/components/ui/card" import { Separator } from "@/components/ui/separator" import { formatNumber } from "@/lib/formatters" import { devide } from "@/lib/hypixel/general" +import { getUhcStar } from "@/lib/hypixel/uhc/level" import { NonNullStats } from "@/lib/schema/player" import CollapsedStats from "../../_components/CollapsedStats" @@ -10,6 +11,7 @@ export default function UHCStats({ stats }: { stats: NonNullStats["UHC"] }) { if (!stats) return null const kd = formatNumber(devide(stats.kills, stats.deaths)) + const star = getUhcStar(stats.score) return ( @@ -20,6 +22,10 @@ export default function UHCStats({ stats }: { stats: NonNullStats["UHC"] }) {
Star

, + stat:

{`[${star}✫]`}

+ }, { title:

KD

, stat:

{kd}

diff --git a/src/data/hypixel/uhc.ts b/src/data/hypixel/uhc.ts new file mode 100644 index 0000000..d6ce0db --- /dev/null +++ b/src/data/hypixel/uhc.ts @@ -0,0 +1,28 @@ +export const TITLE = "UHC" as const +export const MODES = [ + { id: ["solo"], name: "Solo" }, + { id: [""], name: "Teams" }, + { id: ["red vs blue", "_red_vs_blue"], name: "Red vs. Blue" }, + { id: ["no diamonds", "_no_diamonds"], name: "No Diamonds" }, + { id: ["vanilla doubles", "_vanilla_doubles"], name: "Vanilla Doubles" }, + { id: ["brawl"], name: "Brawl" }, + { id: ["solo brawl", "_solo_brawl"], name: "Solo Brawl" }, + { id: ["duo brawl", "_duo_brawl"], name: "Duo Brawl" } +] as const +export const STARS = [ + { value: 0, name: "Recruit", color: "gray" }, + { value: 10, name: "Initiate", color: "gray" }, + { value: 60, name: "Soldier", color: "gray" }, + { value: 210, name: "Sergeant", color: "gray" }, + { value: 460, name: "Knight", color: "gray" }, + { value: 960, name: "Captain", color: "gray" }, + { value: 1710, name: "Centurion", color: "gray" }, + { value: 2710, name: "Gladiator", color: "gray" }, + { value: 5210, name: "Warlord", color: "gray" }, + { value: 10210, name: "Champion", color: "gray" }, + { value: 13210, name: "Champion", color: "gray" }, + { value: 16210, name: "Bronze Champion", color: "dark-red" }, + { value: 19210, name: "Silver Champion", color: "white" }, + { value: 22210, name: "Gold Champion", color: "gold" }, + { value: 25210, name: "High Champion", color: "aqua" } +] as const diff --git a/src/lib/hypixel/uhc/level.ts b/src/lib/hypixel/uhc/level.ts new file mode 100644 index 0000000..967f227 --- /dev/null +++ b/src/lib/hypixel/uhc/level.ts @@ -0,0 +1,10 @@ +import { STARS } from "@/data/hypixel/uhc" + +export function getUhcStar(score: number): number { + for (let i = STARS.length - 1; i >= 0; i--) { + if (score >= STARS[i].value) { + return i + 1 + } + } + return 1 +} diff --git a/src/lib/schema/stats.ts b/src/lib/schema/stats.ts index 1111f0d..09780bd 100644 --- a/src/lib/schema/stats.ts +++ b/src/lib/schema/stats.ts @@ -408,5 +408,6 @@ export const buildBattleStatsSchema = z.looseObject({ export const uhcSchema = z.looseObject({ kills: z.number().default(0), deaths: z.number().default(0), - wins: z.number().default(0) + wins: z.number().default(0), + score: z.number().default(0) })