From 8283324136c580da4f915d23d63436f76a5372e5 Mon Sep 17 00:00:00 2001 From: Taken Date: Fri, 12 Sep 2025 19:34:15 +0200 Subject: [PATCH] Added wool games table --- .../player/[ign]/_stats/woolgames/table.tsx | 33 +++++++++++++++++-- .../[ign]/_stats/woolgames/woolgames.tsx | 4 +-- src/lib/hypixel/woolgames/general.ts | 25 +++++++++++++- src/lib/schema/stats.ts | 2 +- 4 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/app/(stats)/player/[ign]/_stats/woolgames/table.tsx b/src/app/(stats)/player/[ign]/_stats/woolgames/table.tsx index aae2717..05e8675 100644 --- a/src/app/(stats)/player/[ign]/_stats/woolgames/table.tsx +++ b/src/app/(stats)/player/[ign]/_stats/woolgames/table.tsx @@ -1,11 +1,20 @@ -import { Table, TableBody, TableHead, TableHeader, TableRow } from "@/components/ui/table" +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" +import { formatNumber } from "@/lib/formatters" +import { getWoolGamesWoolWarsClass, getWoolGamesWoolWarsClassColor, getWoolGamesWoolWarsClassStats } from "@/lib/hypixel/woolgames/general" import { NonNullStats } from "@/lib/schema/player" +import { cn } from "@/lib/utils" -export default function WoolGamesStatTable({ stats }: { stats: NonNullable }) { +export default function WoolGamesWoolWarsStatTable({ stats }: { stats: NonNullable["wool_wars"] }) { return ( + + + + + +
) @@ -33,3 +42,23 @@ function WoolGamesTableHeader() { ) } + +function StatRow( + { classId, stats }: { + classId: Parameters[0] + stats: NonNullable["wool_wars"] + } +) { + const classStats = getWoolGamesWoolWarsClassStats(classId, stats) + const klass = getWoolGamesWoolWarsClass(classId) + const classColor = getWoolGamesWoolWarsClassColor(klass?.difficulty) + + return ( + + {klass !== null ? klass.name : "Unknown"} + {classStats.map((v, i) => { + return {formatNumber(v)} + })} + + ) +} diff --git a/src/app/(stats)/player/[ign]/_stats/woolgames/woolgames.tsx b/src/app/(stats)/player/[ign]/_stats/woolgames/woolgames.tsx index b8a628c..3067f76 100644 --- a/src/app/(stats)/player/[ign]/_stats/woolgames/woolgames.tsx +++ b/src/app/(stats)/player/[ign]/_stats/woolgames/woolgames.tsx @@ -7,7 +7,7 @@ import GeneralStats from "../GeneralStats" import { WoolGamesCaptureTheWool, WoolGamesSheepWars, WoolGamesWoolWars } from "./modes" import WoolGamesProgress from "./progress" import WoolGamesGeneralStats from "./stats" -import WoolGamesStatTable from "./table" +import WoolGamesWoolWarsStatTable from "./table" export default function WoolGamesStats({ stats }: { stats: NonNullStats["WoolGames"] }) { if (!stats) return null @@ -47,7 +47,7 @@ export default function WoolGamesStats({ stats }: { stats: NonNullStats["WoolGam - + ) diff --git a/src/lib/hypixel/woolgames/general.ts b/src/lib/hypixel/woolgames/general.ts index 58e258f..b27f4c6 100644 --- a/src/lib/hypixel/woolgames/general.ts +++ b/src/lib/hypixel/woolgames/general.ts @@ -1,6 +1,29 @@ import { CLASSES, DIFFICULTIES, EASY_XP, ICONS, NORMAL_XP, PRESTIGES } from "@/data/hypixel/woolgames" import { getColorFromCode } from "@/lib/colors" -import { floorLevel } from "../general" +import { NonNullStats } from "@/lib/schema/player" +import { devide, floorLevel } from "../general" + +export function getWoolGamesWoolWarsClassStats( + classId: typeof CLASSES[number]["id"], + stats: NonNullable["wool_wars"] +) { + const nums: number[] = [] + for (let i = 0; i++; i < 7) { + nums.push(0) + } + + if (!stats) return nums + + return [ + stats.stats?.classes[classId]?.kills || 0, + stats.stats?.classes[classId]?.assists || 0, + stats.stats?.classes[classId]?.deaths || 0, + devide(stats.stats?.classes[classId]?.kills || 0, stats.stats?.classes[classId]?.deaths || 0), + stats.stats?.classes[classId]?.wool_placed || 0, + stats.stats?.classes[classId]?.blocks_broken || 0, + stats.stats?.classes[classId]?.powerups_gotten || 0 + ] +} export function getWoolGamesWoolWarsClass(val?: string) { const klass = CLASSES.find(c => c.id === val?.toLowerCase()) diff --git a/src/lib/schema/stats.ts b/src/lib/schema/stats.ts index f8232ac..da2ab13 100644 --- a/src/lib/schema/stats.ts +++ b/src/lib/schema/stats.ts @@ -785,7 +785,7 @@ export const woolGamesStatsSchema = z.object({ engineer: woolGamesClassStats.optional(), golem: woolGamesClassStats.optional(), assault: woolGamesClassStats.optional() - }).optional() + }).default({}) }).optional() }).optional() })