From a4bf768c8369ac58c76cde682770d740901a25cd Mon Sep 17 00:00:00 2001 From: Taken Date: Wed, 20 Aug 2025 12:54:49 +0200 Subject: [PATCH] Updated bw stats --- .../player/[ign]/_components/Stats.tsx | 20 ++++ .../player/[ign]/_stats/bedwars/bedwars.tsx | 100 ++---------------- .../player/[ign]/_stats/bedwars/stats.tsx | 81 ++++++++++++++ src/lib/hypixel/bedwars.ts | 26 ++++- src/lib/schema/player.ts | 14 ++- đ | 50 +++++++++ ž | 52 +++++++++ 7 files changed, 249 insertions(+), 94 deletions(-) create mode 100644 src/app/(stats)/player/[ign]/_components/Stats.tsx create mode 100644 src/app/(stats)/player/[ign]/_stats/bedwars/stats.tsx create mode 100644 đ create mode 100644 ž diff --git a/src/app/(stats)/player/[ign]/_components/Stats.tsx b/src/app/(stats)/player/[ign]/_components/Stats.tsx new file mode 100644 index 0000000..d28b804 --- /dev/null +++ b/src/app/(stats)/player/[ign]/_components/Stats.tsx @@ -0,0 +1,20 @@ +import { cn } from "@/lib/utils" +import { ReactNode } from "react" + +export function BasicStat({ title, value, className }: { title: string, value: string | number, className?: string }) { + return ( +

+ {title} + {value} +

+ ) +} + +export function Stat({ title, children }: { title: string, children: ReactNode }) { + return ( +

+ {title} + {children} +

+ ) +} diff --git a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx index 2c21555..72261f2 100644 --- a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx +++ b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx @@ -2,7 +2,6 @@ import { Card, CardContent } from "@/components/ui/card" import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible" -import { formatNumber } from "@/lib/formatters" import { getBWLevelForExp, getTotalExpForLevel } from "@/lib/hypixel/bedwarsLevel" import { getProgress } from "@/lib/hypixel/general" import { Player } from "@/lib/schema/player" @@ -10,7 +9,8 @@ import { Separator } from "@radix-ui/react-separator" import { ChevronDown, ChevronUp, Menu } from "lucide-react" import { useEffect, useRef, useState } from "react" import CollapsedStats from "../../_components/CollapsedStats" -import { BedwarsLevel, BedWarsPrestige, BedwarsProgress } from "./bedwars-components" +import { BedwarsLevel, BedwarsProgress } from "./bedwars-components" +import BedwarsGeneralStats from "./stats" export default function BedwarsStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const ref = useRef(null) @@ -65,23 +65,23 @@ export default function BedwarsStats({ stats }: { stats: Player["player"]["stats }, { title:

WS

, - stat:

{stats.winstreak ?? "?"}

+ stat:

{stats.winstreak ?? "?"}

}, { title:

KD

, - stat:

{kd}

+ stat:

{kd}

}, { title:

FKD

, - stat:

{fkd}

+ stat:

{fkd}

}, { title:

WL

, - stat:

{wl}

+ stat:

{wl}

}, { title:

BBL

, - stat:

{bbl}

+ stat:

{bbl}

} ]} /> @@ -96,91 +96,7 @@ export default function BedwarsStats({ stats }: { stats: Player["player"]["stats -
-
-
-

- {"Level: "} - {`${level}.${percent.toFixed(0)}`} -

-

- {"Prestige: "} - -

-

- {"Tokens: "} - {formatNumber(stats.coins)} -

-
-
-

- {"Kills: "} - {formatNumber(stats.kills_bedwars)} -

-

- {"Deaths: "} - {formatNumber(stats.deaths_bedwars)} -

-

- {"Kill/Death Ratio: "} - {kd} -

-

- {"Final Kills: "} - {formatNumber(stats.final_kills_bedwars)} -

-

- {"Final Deaths: "} - {formatNumber(stats.final_deaths_bedwars)} -

-

- {"Final Kill/Death Ratio: "} - {fkd} -

-
-
-
-
-

- {"Winstreak: "} - {stats.winstreak ?? "?"} -

-

- {"Wins: "} - {formatNumber(stats.wins_bedwars)} -

-

- {"Losses: "} - {formatNumber(stats.losses_bedwars)} -

-

- {"Win/Loss Ratio: "} - {wl} -

-
-
-

- {"Beds Broken: "} - {stats.beds_broken_bedwars} -

-

- {"Beds Lost: "} - {stats.beds_lost_bedwars} -

-

- {"Beds Broken/Lost: "} - {bbl} -

-
-
-

- {"Total Challenges Completed: "} - {stats.total_challenges_completed} -

-
-
-
-
+
diff --git a/src/app/(stats)/player/[ign]/_stats/bedwars/stats.tsx b/src/app/(stats)/player/[ign]/_stats/bedwars/stats.tsx new file mode 100644 index 0000000..9047ed8 --- /dev/null +++ b/src/app/(stats)/player/[ign]/_stats/bedwars/stats.tsx @@ -0,0 +1,81 @@ +import { formatNumber } from "@/lib/formatters" +import { getLatestRoom, getWalletMax } from "@/lib/hypixel/bedwars" +import { Player } from "@/lib/schema/player" +import { BasicStat, Stat } from "../../_components/Stats" +import { BedWarsPrestige } from "./bedwars-components" + +export default function BedwarsGeneralStats( + { statsChecked, level, percent, kd, fkd, bbl, wl }: { + statsChecked: Player["player"]["stats"]["Bedwars"] + level: number + percent: number + kd: string + fkd: string + bbl: string + wl: string + } +) { + const stats = statsChecked! + + return ( +
+
+ + + + + +

+
+

+ + + + + + +
+
+ + + + +

+
+

+ + + +

+
+

+ +
+
+ + + {stats.slumber?.tickets === undefined ? "None" : formatNumber(stats.slumber.tickets)} + + + {`/${formatNumber(getWalletMax(stats.slumber?.bag_type))}`} + + + + + +

+
+

+ + + + + +
+
+ ) +} diff --git a/src/lib/hypixel/bedwars.ts b/src/lib/hypixel/bedwars.ts index 8e993bf..5adda71 100644 --- a/src/lib/hypixel/bedwars.ts +++ b/src/lib/hypixel/bedwars.ts @@ -1,4 +1,4 @@ -import { PRESTIGE_ICONS, PRESTIGES } from "@/data/hypixel/bedwars" +import { PRESTIGE_ICONS, PRESTIGES, SLUMBER_ROOMS, SLUMBER_WALLETS } from "@/data/hypixel/bedwars" import { floorLevel } from "./formatters" export function getBedwarsStar(level: number) { @@ -36,3 +36,27 @@ export function getPrestigeName(level: number) { return PRESTIGES.find(p => p.level === floored)!.name } + +export function getWalletMax(name?: string) { + if (!name) return 25 + + const wallets = SLUMBER_WALLETS as Record + + if (!wallets[name]) return 25 + + return wallets[name] +} + +export function getLatestRoom(rooms?: Record) { + if (!rooms) return null + + let latestRoom = null + + for (const room of SLUMBER_ROOMS) { + if (rooms[room.id]) { + latestRoom = room.name + } + } + + return latestRoom +} diff --git a/src/lib/schema/player.ts b/src/lib/schema/player.ts index 766486b..02ad2c3 100644 --- a/src/lib/schema/player.ts +++ b/src/lib/schema/player.ts @@ -24,7 +24,19 @@ export const playerSchema = z.looseObject({ losses_bedwars: z.number().default(0), beds_broken_bedwars: z.number().default(0), beds_lost_bedwars: z.number().default(0), - total_challenges_completed: z.number().default(0) + total_challenges_completed: z.number().default(0), + iron_resources_collected_bedwars: z.number().default(0), + gold_resources_collected_bedwars: z.number().default(0), + diamond_resources_collected_bedwars: z.number().default(0), + emerald_resources_collected_bedwars: z.number().default(0), + _items_purchased_bedwars: z.number().default(0), + slumber: z.looseObject({ + tickets: z.number().default(0), + bag_type: z.string(), + total_tickets_earned: z.number(), + doublers: z.number(), + room: z.record(z.string(), z.boolean()) + }).optional() }).optional() }), quests: z.record( diff --git a/đ b/đ new file mode 100644 index 0000000..2e497e3 --- /dev/null +++ b/đ @@ -0,0 +1,50 @@ +import { PRESTIGE_ICONS, PRESTIGES, SLUMBER_WALLETS } from "@/data/hypixel/bedwars" +import { floorLevel } from "./formatters" + +export function getBedwarsStar(level: number) { + if (level < 1100) { + return PRESTIGE_ICONS[0].symbol + } + + if (level > 1100 && level < 2100) { + return PRESTIGE_ICONS[1].symbol + } + + if (level > 2100 && level < 3100) { + return PRESTIGE_ICONS[2].symbol + } + + return PRESTIGE_ICONS[3].symbol +} + +export function getTextColor(level: number) { + const floored = floorLevel(level, 100) + + if (level > 5000) { + return PRESTIGES[PRESTIGES.length - 1].color + } + + return PRESTIGES.find(l => l.level === floored)!.color +} + +export function getPrestigeName(level: number) { + const floored = floorLevel(level, 100) + + if (level > 5000) { + return PRESTIGES[PRESTIGES.length - 1].name + } + + return PRESTIGES.find(p => p.level === floored)!.name +} + +export function getWalletMax(name?: string) { + if (!name) return 25 + + const wallets = SLUMBER_WALLETS as Record + + if (!wallets[name]) return 25 + + return wallets[name] +} + +export function getLatesRoom(rooms: Record) diff --git a/ž b/ž new file mode 100644 index 0000000..91a5c7f --- /dev/null +++ b/ž @@ -0,0 +1,52 @@ +import { PRESTIGE_ICONS, PRESTIGES, SLUMBER_WALLETS } from "@/data/hypixel/bedwars" +import { floorLevel } from "./formatters" + +export function getBedwarsStar(level: number) { + if (level < 1100) { + return PRESTIGE_ICONS[0].symbol + } + + if (level > 1100 && level < 2100) { + return PRESTIGE_ICONS[1].symbol + } + + if (level > 2100 && level < 3100) { + return PRESTIGE_ICONS[2].symbol + } + + return PRESTIGE_ICONS[3].symbol +} + +export function getTextColor(level: number) { + const floored = floorLevel(level, 100) + + if (level > 5000) { + return PRESTIGES[PRESTIGES.length - 1].color + } + + return PRESTIGES.find(l => l.level === floored)!.color +} + +export function getPrestigeName(level: number) { + const floored = floorLevel(level, 100) + + if (level > 5000) { + return PRESTIGES[PRESTIGES.length - 1].name + } + + return PRESTIGES.find(p => p.level === floored)!.name +} + +export function getWalletMax(name?: string) { + if (!name) return 25 + + const wallets = SLUMBER_WALLETS as Record + + if (!wallets[name]) return 25 + + return wallets[name] +} + +export function getLatesRoom(rooms?: Record) { + if (!rooms) return null +}