From cf655833b24c6002b5860e617d01397ed216e210 Mon Sep 17 00:00:00 2001 From: Taken Date: Sat, 30 Aug 2025 13:31:11 +0200 Subject: [PATCH] Added heads bar --- .../[ign]/_stats/skywars/components.tsx | 76 +++++++++++- .../player/[ign]/_stats/skywars/skywars.tsx | 33 ++++-- src/data/colors.ts | 2 +- src/data/hypixel/skywars.ts | 8 +- src/lib/hypixel/skywars.ts | 10 +- src/lib/schema/stats.ts | 12 +- đ | 108 ------------------ 7 files changed, 123 insertions(+), 126 deletions(-) delete mode 100644 đ diff --git a/src/app/(stats)/player/[ign]/_stats/skywars/components.tsx b/src/app/(stats)/player/[ign]/_stats/skywars/components.tsx index 17d4af1..a37550d 100644 --- a/src/app/(stats)/player/[ign]/_stats/skywars/components.tsx +++ b/src/app/(stats)/player/[ign]/_stats/skywars/components.tsx @@ -1,14 +1,84 @@ import { formatNumber } from "@/lib/formatters" -import { getPrestigeName, getSkyWarsIcon, getTextColor } from "@/lib/hypixel/skywars" +import { getHeadsColor, getPrestigeName, getSkyWarsIcon, getTextColor } from "@/lib/hypixel/skywars" import { getSkywarsLevel } from "@/lib/hypixel/skyWarsLevel" import { cn } from "@/lib/utils" import GenericProgress from "../../_components/GenericProgress" +type SkywarsHeadsProps = { + heads: number + heads_special: { + eww: number + yucky: number + meh: number + decent: number + salty: number + tasty: number + succulent: number + sweet: number + divine: number + heavenly: number + } +} + +export function SkywarsHeads({ + heads, + heads_special +}: SkywarsHeadsProps) { + const total_special = Object.values(heads_special).reduce((a, b) => a + b) + const percentages = { + heavenly: heads_special.heavenly / heads, + divine: heads_special.divine / heads, + sweet: heads_special.sweet / heads, + succulent: heads_special.succulent / heads, + tasty: heads_special.tasty / heads, + salty: heads_special.salty / heads, + decent: heads_special.decent / heads, + meh: heads_special.meh / heads, + yucky: heads_special.yucky / heads, + eww: heads_special.eww / heads, + rest: (heads - total_special) / heads + } + + const headsArray = Object.entries(percentages) + + return ( +
+

+ {"Total Heads Gathered: "} + {formatNumber(heads)} +

+ {total_special > 0 && ( +
+ {headsArray.map(([key, val], index) => { + const color = getHeadsColor(key) + + return ( +
+
+ ) + })} +
+ )} +
+ ) +} + export function AngelOfDeath( { shards, lifetime_shards, opals, lifetime_opals }: { shards: number, lifetime_shards: number, opals: number, lifetime_opals: number } ) { return ( -
+

{"Shards: "} {shards} @@ -32,7 +102,7 @@ export function AngelOfDeath( export function ShardProgress({ percent }: { percent: number }) { return (

-

Shard Progress

+

Shard Progress

diff --git a/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx b/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx index d4b4a5e..d1c952e 100644 --- a/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx +++ b/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx @@ -10,7 +10,7 @@ import { NonNullStats } from "@/lib/schema/player" import { ChevronDown, ChevronUp } from "lucide-react" import { useEffect, useRef, useState } from "react" import CollapsedStats from "../../_components/CollapsedStats" -import { AngelOfDeath, ShardProgress, SkywarsLevel, SkywarsProgress } from "./components" +import { AngelOfDeath, ShardProgress, SkywarsHeads, SkywarsLevel, SkywarsProgress } from "./components" import SkyWarsGeneralStats from "./stats" import SkywarsStatTable from "./table" @@ -93,13 +93,30 @@ export default function SkyWarsStats( - - +
+ + + +
diff --git a/src/data/colors.ts b/src/data/colors.ts index c391693..7a6de05 100644 --- a/src/data/colors.ts +++ b/src/data/colors.ts @@ -21,7 +21,7 @@ export function getColor(color?: string, type: "text" | "bg" = "text", defaultCo case "DARK_RED": return type === "text" ? "text-mc-dark-red" : "bg-mc-dark-red" case "DARK_AQUA": - return type === "text" ? "text-mc-dark-aqua" : "bg-mc-dark-red" + return type === "text" ? "text-mc-dark-aqua" : "bg-mc-dark-aqua" case "DARK_PURPLE": return type === "text" ? "text-mc-dark-purple" : "bg-mc-dark-purple" case "DARK_GRAY": diff --git a/src/data/hypixel/skywars.ts b/src/data/hypixel/skywars.ts index dc36051..dd193da 100644 --- a/src/data/hypixel/skywars.ts +++ b/src/data/hypixel/skywars.ts @@ -96,14 +96,14 @@ export const MODES = [ ] export const HEADS = [ - { id: "eww", name: "Eww!", color: "darkgray" }, + { id: "eww", name: "Eww!", color: "dark-gray" }, { id: "yucky", name: "Yucky!", color: "gray" }, { id: "meh", name: "Meh", color: "white" }, { id: "decent", name: "Decent", color: "yellow" }, { id: "salty", name: "Salty", color: "green" }, - { id: "tasty", name: "Tasty", color: "darkaqua" }, - { id: "succulent", name: "Succulent", color: "pink" }, + { id: "tasty", name: "Tasty", color: "dark-aqua" }, + { id: "succulent", name: "Succulent", color: "light-purple" }, { id: "sweet", name: "Sweet", color: "aqua" }, { id: "divine", name: "Divine", color: "gold" }, - { id: "heavenly", name: "Heavenly", color: "purple" } + { id: "heavenly", name: "Heavenly", color: "dark-purple" } ] diff --git a/src/lib/hypixel/skywars.ts b/src/lib/hypixel/skywars.ts index 110fd44..96d31a8 100644 --- a/src/lib/hypixel/skywars.ts +++ b/src/lib/hypixel/skywars.ts @@ -1,7 +1,15 @@ -import { ICONS, PRESTIGES } from "@/data/hypixel/skywars" +import { HEADS, ICONS, PRESTIGES } from "@/data/hypixel/skywars" import { floorLevel } from "./formatters" import { devide } from "./general" +export function getHeadsColor(key: string) { + const val = HEADS.find(v => v.id === key)?.color + + if (!val) return null + + return val +} + export function getTextColor(level: number) { const floored = floorLevel(level, 5) diff --git a/src/lib/schema/stats.ts b/src/lib/schema/stats.ts index ef79fbd..1262428 100644 --- a/src/lib/schema/stats.ts +++ b/src/lib/schema/stats.ts @@ -248,5 +248,15 @@ export const skywarsStatsSchema = z.looseObject({ wins_ranked_normal: z.number().default(0), losses_ranked_normal: z.number().default(0), shard: z.number().default(0), - opals: z.number().default(0) + opals: z.number().default(0), + heads_eww: z.number().default(0), + heads_yucky: z.number().default(0), + heads_meh: z.number().default(0), + heads_decent: z.number().default(0), + heads_salty: z.number().default(0), + heads_tasty: z.number().default(0), + heads_succulent: z.number().default(0), + heads_sweet: z.number().default(0), + heads_divine: z.number().default(0), + heads_heavenly: z.number().default(0) }) diff --git a/đ b/đ deleted file mode 100644 index 7116580..0000000 --- a/đ +++ /dev/null @@ -1,108 +0,0 @@ -import DisplayName from "@/components/player/displayname" -import { Card, CardContent } from "@/components/ui/card" -import { getGuild } from "@/lib/hypixel/api/guild" -import { getUuid } from "@/lib/hypixel/api/mojang" -import { getPlayer } from "@/lib/hypixel/api/player" -import { getExactLevel } from "@/lib/hypixel/level" -import { Loader2Icon } from "lucide-react" -import { Suspense } from "react" -import Sidebar from "./_components/Sidebar" -import BedwarsStats from "./_stats/bedwars/bedwars" -import SkyWarsStats from "./_stats/skywars/skywars" - -export default async function PlayerPage({ - params -}: { - params: Promise<{ ign: string }> -}) { - const { ign } = await params - - return ( - - -

{`Loading stats for ${ign}`}

-
- } - > - - - ) -} - -async function SuspendedPage({ ign: pign }: { ign: string }) { - const uuid = await getUuid(pign) - if (!uuid) { - return ( -
-

Player not found

-
- ) - } - - const player = await getPlayer(uuid) - - if (!player) { - return ( -
-

Player not found

-
- ) - } - - const guild = await getGuild(uuid) - const level = getExactLevel(player.networkExp) - - return ( -
-

- -

-

- {player.uuid} -

-
- - {player.stats !== undefined ? - ( -
- - -
- ) : - ( -
- - -

- No stats avaiable. If they are staff then they most likely have their api off. -

-
-
-
- )} -
-
- ) -}