diff --git a/src/app/(stats)/player/[ign]/_stats/arcade/arcade.tsx b/src/app/(stats)/player/[ign]/_stats/arcade/arcade.tsx index 7601d37..e896d16 100644 --- a/src/app/(stats)/player/[ign]/_stats/arcade/arcade.tsx +++ b/src/app/(stats)/player/[ign]/_stats/arcade/arcade.tsx @@ -1,7 +1,10 @@ import { Separator } from "@/components/ui/separator" +import { formatNumber } from "@/lib/formatters" import { getArcadeTotalWins } from "@/lib/hypixel/arcade/general" import { NonNullStats } from "@/lib/schema/player" +import { BasicStat } from "../../_components/Stats" import GeneralStats from "../GeneralStats" +import { ArcadeMiniWallsStats, ArcadePixelPartyStats } from "./stats" export default function ArcadeStats({ stats }: { stats: NonNullStats["Arcade"] }) { if (!stats) return null @@ -18,6 +21,14 @@ export default function ArcadeStats({ stats }: { stats: NonNullStats["Arcade"] } }]} > +
+ +
+ + + + + ) } diff --git a/src/app/(stats)/player/[ign]/_stats/arcade/stats.tsx b/src/app/(stats)/player/[ign]/_stats/arcade/stats.tsx new file mode 100644 index 0000000..0b736cc --- /dev/null +++ b/src/app/(stats)/player/[ign]/_stats/arcade/stats.tsx @@ -0,0 +1,65 @@ +import { formatNumber } from "@/lib/formatters" +import { devide } from "@/lib/hypixel/general" +import { NonNullStats } from "@/lib/schema/player" +import { capitalizeFirstLetter } from "@/lib/utils" +import { BasicStat } from "../../_components/Stats" +import { PixelPartyStatsTable } from "./table" + +export function ArcadePixelPartyStats({ stats }: { stats: NonNullable }) { + const losses = (stats.pixel_party?.games_played || 0) - (stats.pixel_party?.wins || 0) + const wl = formatNumber(devide(stats.pixel_party?.wins || 0, losses)) + return ( + <> +

Pixel Party

+
+
+ + + +
+
+ + + +
+
+ +
+
+ + + ) +} + +export function ArcadeMiniWallsStats({ stats }: { stats: NonNullable }) { + const kd = formatNumber(devide(stats.kills_mini_walls + stats.final_kills_mini_walls, stats.deaths_mini_walls)) + const ac = formatNumber(devide(stats.arrows_hit_mini_walls, stats.arrows_shot_mini_walls)) + return ( + <> +

Mini Walls

+
+
+ + + +
+
+ + + + +
+
+ + + +
+
+ + ) +} diff --git a/src/app/(stats)/player/[ign]/_stats/arcade/table.tsx b/src/app/(stats)/player/[ign]/_stats/arcade/table.tsx new file mode 100644 index 0000000..bc59a51 --- /dev/null +++ b/src/app/(stats)/player/[ign]/_stats/arcade/table.tsx @@ -0,0 +1,56 @@ +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" +import { formatNumber } from "@/lib/formatters" +import { getArcadeMostPlayedPixelPartyMode, getArcadePixelPartyModeName, getArcadePixelPartyModeStats } from "@/lib/hypixel/arcade/general" +import { NonNullStats } from "@/lib/schema/player" +import { cn } from "@/lib/utils" + +export function PixelPartyStatsTable({ stats }: { stats: NonNullable["pixel_party"] }) { + return ( + + + + + + + +
+ ) +} + +function PixelPartyTableStat( + { modeId, stats }: { modeId: Parameters[0], stats: NonNullable["pixel_party"] } +) { + const modeName = getArcadePixelPartyModeName(modeId) + const modeStats = getArcadePixelPartyModeStats(modeId, stats) + const mostPlayed = getArcadeMostPlayedPixelPartyMode(stats) === modeId + const isMostPlayed = modeId !== "all_modes" && mostPlayed + + return ( + + {modeName} + {modeStats.map((v, i) => { + return {formatNumber(v)} + })} + + ) +} + +function PixelPartyStatsTableHeader() { + const headerElements = [ + "Mode", + "Wins", + "Losses", + "WL", + "Games Played", + "Rounds Completed", + "Power-Ups Collected" + ] + + return ( + + + {headerElements.map((v, i) => {v})} + + + ) +} diff --git a/src/app/(stats)/player/[ign]/_stats/uhc/table.tsx b/src/app/(stats)/player/[ign]/_stats/uhc/table.tsx index a88ce38..edf801b 100644 --- a/src/app/(stats)/player/[ign]/_stats/uhc/table.tsx +++ b/src/app/(stats)/player/[ign]/_stats/uhc/table.tsx @@ -2,6 +2,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@ import { formatNumber } from "@/lib/formatters" import { getUHCModeName, getUHCModeStats } from "@/lib/hypixel/uhc/general" import { NonNullStats } from "@/lib/schema/player" +import { cn } from "@/lib/utils" export default function UHCStatTable({ stats }: { stats: NonNullable }) { return ( @@ -50,8 +51,8 @@ function TableStat( const modeName = getUHCModeName(modeId === "teams" || modeId === "all_modes" ? "" : modeId) return ( - - {modeId === "all_modes" ? "Overall" : modeName} + + {modeId === "all_modes" ? "Overall" : modeName} {modeStats.map((v, i) => { return ( diff --git a/src/data/hypixel/arcade.ts b/src/data/hypixel/arcade.ts index b302128..88ce7ae 100644 --- a/src/data/hypixel/arcade.ts +++ b/src/data/hypixel/arcade.ts @@ -22,3 +22,37 @@ export const WINS = [ "wins_mini_walls", "wins_zombies" ] as const + +export const ZOMBIESMODES = [ + { id: "deadend", name: "Dead End", color: "gold" }, + { id: "badblood", name: "Bad Blood", color: "red" }, + { id: "alienarcadium", name: "Alien Arcadium", color: "pink" } +] as const +export const ZOMBIESTYPES = [ + { id: "basic", name: "Basic" }, + { id: "blaze", name: "Blaze" }, + { id: "empowered", name: "Empowered" }, + { id: "ender", name: "Ender" }, + { id: "endermite", name: "Endermite" }, + { id: "fire", name: "Fire" }, + { id: "guardian", name: "Guardian" }, + { id: "magma", name: "Magma" }, + { id: "magma_cube", name: "Magma Cube" }, + { id: "pig_zombie", name: "Pig Zombie" }, + { id: "skelefish", name: "Skelefish" }, + { id: "tnt_baby", name: "TNT Baby" }, + { id: "tnt", name: "Bombie", color: "gold" }, + { id: "inferno", name: "Inferno", color: "gold" }, + { id: "broodmother", name: "Broodmother", color: "gold" }, + { id: "king_slime", name: "King Slime", color: "red" }, + { id: "wither", name: "Wither", color: "red" }, + { id: "herobrine", name: "Herobrine", color: "red" }, + { id: "mega_blob", name: "Mega Blob", color: "pink" }, + { id: "mega_magma", name: "Mega Magma", color: "pink" }, + { id: "world_ender", name: "World Ender", color: "pink" } +] as const +export const PIXELPARTYMODES = [ + { id: "normal", name: "Normal" }, + { id: "hyper", name: "Hyper" }, + { id: "", name: "Overall" } +] as const diff --git a/src/lib/hypixel/arcade/general.ts b/src/lib/hypixel/arcade/general.ts index 3a3a32f..308020a 100644 --- a/src/lib/hypixel/arcade/general.ts +++ b/src/lib/hypixel/arcade/general.ts @@ -1,5 +1,50 @@ -import { WINS } from "@/data/hypixel/arcade" +import { PIXELPARTYMODES, WINS } from "@/data/hypixel/arcade" import { NonNullStats } from "@/lib/schema/player" +import { devide } from "../general" + +export function getArcadeMostPlayedPixelPartyMode(stats: NonNullable["pixel_party"]) { + if (!stats) return null + const played = [ + { games: stats.games_played_normal, modeId: "normal" as const }, + { games: stats.games_played_hyper, modeId: "hyper" as const } + ] + + const mostPlayed = played.reduce((max, current) => current.games > max.games ? current : max) + + return mostPlayed.modeId +} + +export function getArcadePixelPartyModeName(modeId: Exclude | "all_modes") { + if (modeId === "all_modes") return PIXELPARTYMODES.find(m => m.id === "")!.name + return PIXELPARTYMODES.find(m => m.id === modeId)!.name +} + +export function getArcadePixelPartyModeStats( + modeId: Exclude | "all_modes", + stats: NonNullable["pixel_party"] +) { + if (!stats) return [0, 0, 0, 0, 0, 0] + + if (modeId === "all_modes") { + return [ + stats["wins"], + stats["games_played"] - stats["wins"], + devide(stats["wins"], stats["games_played"] - stats["wins"]), + stats["games_played"], + stats["rounds_completed"], + stats["power_ups_collected"] + ] + } + + return [ + stats[`wins_${modeId}`], + stats[`games_played_${modeId}`] - stats[`wins_${modeId}`], + devide(stats[`wins_${modeId}`], stats[`games_played_${modeId}`] - stats[`wins_${modeId}`]), + stats[`games_played_${modeId}`], + stats[`rounds_completed_${modeId}`], + stats[`power_ups_collected_${modeId}`] + ] +} export function getArcadeTotalWins(stats: NonNullable) { let wins = 0 diff --git a/src/lib/schema/stats.ts b/src/lib/schema/stats.ts index 5689f76..4995ab3 100644 --- a/src/lib/schema/stats.ts +++ b/src/lib/schema/stats.ts @@ -913,9 +913,28 @@ function arcadeModeWins() { } export const arcadeStatsSchema = z.object({ + miniwalls_activeKit: z.string().optional(), + wither_kills_mini_walls: z.number().default(0), + kills_mini_walls: z.number().default(0), + final_kills_mini_walls: z.number().default(0), + deaths_mini_walls: z.number().default(0), + arrows_hit_mini_walls: z.number().default(0), + arrows_shot_mini_walls: z.number().default(0), coins: z.number().default(0), pixel_party: z.object({ - wins: z.number().default(0) + wins: z.number().default(0), + games_played: z.number().default(0), + rounds_completed: z.number().default(0), + highest_round: z.number().default(0), + power_ups_collected: z.number().default(0), + wins_normal: z.number().default(0), + games_played_normal: z.number().default(0), + rounds_completed_normal: z.number().default(0), + power_ups_collected_normal: z.number().default(0), + wins_hyper: z.number().default(0), + games_played_hyper: z.number().default(0), + rounds_completed_hyper: z.number().default(0), + power_ups_collected_hyper: z.number().default(0) }).optional(), dropper: z.object({ wins: z.number().default(0) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 03aaa4b..2a4228d 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -4,3 +4,7 @@ import { twMerge } from "tailwind-merge" export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } + +export function capitalizeFirstLetter(str: string) { + return str[0].toUpperCase() + str.slice(1, str.length) +}