From e0a54114d043ec2d520d3f88c4c66a7c54b87e7c Mon Sep 17 00:00:00 2001 From: Taken Date: Sun, 7 Sep 2025 18:38:17 +0200 Subject: [PATCH] Added mw modes table --- .../[ign]/_stats/megawalls/megawalls.tsx | 5 + .../player/[ign]/_stats/megawalls/table.tsx | 93 +++++++++++++++++++ src/lib/hypixel/megawalls/general.ts | 18 +++- src/lib/schema/stats.ts | 28 +++++- 4 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 src/app/(stats)/player/[ign]/_stats/megawalls/table.tsx diff --git a/src/app/(stats)/player/[ign]/_stats/megawalls/megawalls.tsx b/src/app/(stats)/player/[ign]/_stats/megawalls/megawalls.tsx index 0f35507..a4e8a2c 100644 --- a/src/app/(stats)/player/[ign]/_stats/megawalls/megawalls.tsx +++ b/src/app/(stats)/player/[ign]/_stats/megawalls/megawalls.tsx @@ -8,6 +8,7 @@ import { NonNullStats } from "@/lib/schema/player" import { cn } from "@/lib/utils" import CollapsedStats from "../../_components/CollapsedStats" import MegaWallsGeneralStats from "./stats" +import { MegaWallsClassesTable, MegaWallsModesTable } from "./table" export default function MegaWallsStats({ stats }: { stats: NonNullStats["MegaWalls"] }) { if (!stats) return null @@ -59,6 +60,10 @@ export default function MegaWallsStats({ stats }: { stats: NonNullStats["MegaWal + + + + diff --git a/src/app/(stats)/player/[ign]/_stats/megawalls/table.tsx b/src/app/(stats)/player/[ign]/_stats/megawalls/table.tsx new file mode 100644 index 0000000..6326c61 --- /dev/null +++ b/src/app/(stats)/player/[ign]/_stats/megawalls/table.tsx @@ -0,0 +1,93 @@ +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" +import { formatNumber } from "@/lib/formatters" +import { getMegaWallsModeName, getMegaWallsModeStats } from "@/lib/hypixel/megawalls/general" +import { NonNullStats } from "@/lib/schema/player" + +export function MegaWallsModesTable({ stats }: { stats: NonNullable }) { + return ( + + + + + + + +
+ ) +} + +export function MegaWallsClassesTable({ stats }: { stats: NonNullable }) { + return ( + + + + +
+ ) +} + +function MegaWallsClassTableHeader() { + const headerElements = [ + "Class", + "Kills", + "Deaths", + "KD", + "Kills", + "Deaths", + "KD", + "Wins", + "Losses", + "WL", + "Prestige", + "Ender Chest" + ] + + return ( + + + + Normal + Finals + + + {headerElements.map((v, i) => {v})} + + + ) +} + +function MegaWallsTableHeader() { + const headerElements = [ + "Mode", + "Kills", + "Deaths", + "KD", + "Wins", + "Losses", + "WL" + ] + + return ( + + + {headerElements.map((v, i) => {v})} + + + ) +} + +function MegaWallsModeStat( + { modeId, stats }: { modeId: Parameters[0], stats: NonNullable } +) { + const modeName = getMegaWallsModeName(modeId) + const modeStat = getMegaWallsModeStats(modeId, stats) + + return ( + + {modeName} + {modeStat.map((s, i) => { + return {formatNumber(s)} + })} + + ) +} diff --git a/src/lib/hypixel/megawalls/general.ts b/src/lib/hypixel/megawalls/general.ts index f49ec5d..314eb35 100644 --- a/src/lib/hypixel/megawalls/general.ts +++ b/src/lib/hypixel/megawalls/general.ts @@ -1,5 +1,6 @@ -import { CLASSES, DIFFICULTIES } from "@/data/hypixel/megawalls" +import { CLASSES, DIFFICULTIES, MODES } from "@/data/hypixel/megawalls" import { NonNullStats } from "@/lib/schema/player" +import { devide } from "../general" export function getMostPlayed(stats: NonNullable) { let mostPlayedClass: typeof CLASSES[number] | null = null @@ -22,3 +23,18 @@ export function getMostPlayed(stats: NonNullable) { export function getDifficultyColor(val: 1 | 2 | 3 | 4) { return DIFFICULTIES[val] } + +export function getMegaWallsModeName(modeId: typeof MODES[number]["id"]) { + return MODES.find(m => m.id === modeId)!.name +} + +export function getMegaWallsModeStats(modeId: typeof MODES[number]["id"], stats: NonNullable) { + return [ + stats[`kills_${modeId}`], + stats[`deaths_${modeId}`], + devide(stats[`kills_${modeId}`], stats[`deaths_${modeId}`]), + stats[`wins_${modeId}`], + stats[`losses_${modeId}`], + devide(stats[`wins_${modeId}`], stats[`losses_${modeId}`]) + ] +} diff --git a/src/lib/schema/stats.ts b/src/lib/schema/stats.ts index c0f7182..0702d70 100644 --- a/src/lib/schema/stats.ts +++ b/src/lib/schema/stats.ts @@ -554,7 +554,7 @@ export const tntGamesStatsSchema = z.looseObject({ ...tntGamesModeStats() }) -function megawallsModeStats() { +function megawallsClassStats() { const ids = [ "angel", "arcanist", @@ -601,6 +601,31 @@ function megawallsModeStats() { return Object.fromEntries(entries) as Record<`${typeof ids[number]}_${typeof stats[number]}`, z.ZodDefault> } +function megawallsModeStats() { + const ids = [ + "standard", + "face_off", + "gvg" + ] as const + + const stats = [ + "kills", + "deaths", + "wins", + "losses" + ] as const + + const entries = new Map>() + + for (const id of ids) { + for (const stat of stats) { + entries.set(`${stat}_${id}`, z.number().default(0)) + } + } + + return Object.fromEntries(entries) as Record<`${typeof stats[number]}_${typeof ids[number]}`, z.ZodDefault> +} + export const megawallsStats = z.looseObject({ kills: z.number().default(0), assists: z.number().default(0), @@ -615,5 +640,6 @@ export const megawallsStats = z.looseObject({ coins: z.number().default(0), wither_damage: z.number().default(0), witherDamage: z.number().default(0), + ...megawallsClassStats(), ...megawallsModeStats() })