Added uhc acordion
This commit is contained in:
@@ -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 (
|
||||
<AccordionItem value="uhc">
|
||||
@@ -20,6 +22,10 @@ export default function UHCStats({ stats }: { stats: NonNullStats["UHC"] }) {
|
||||
<div className="flex gap-4">
|
||||
<CollapsedStats
|
||||
stats={[
|
||||
{
|
||||
title: <p>Star</p>,
|
||||
stat: <p className="text-mc-gold">{`[${star}✫]`}</p>
|
||||
},
|
||||
{
|
||||
title: <p>KD</p>,
|
||||
stat: <p className="text-muted-foreground">{kd}</p>
|
||||
|
||||
28
src/data/hypixel/uhc.ts
Normal file
28
src/data/hypixel/uhc.ts
Normal file
@@ -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
|
||||
10
src/lib/hypixel/uhc/level.ts
Normal file
10
src/lib/hypixel/uhc/level.ts
Normal file
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user