Updated pixel party stats

This commit is contained in:
2025-09-14 20:19:10 +02:00
parent 708146786d
commit 3711b43b4e
8 changed files with 239 additions and 4 deletions

View File

@@ -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<NonNullStats["Arcade"]>["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<typeof PIXELPARTYMODES[number]["id"], ""> | "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<typeof PIXELPARTYMODES[number]["id"], ""> | "all_modes",
stats: NonNullable<NonNullStats["Arcade"]>["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<NonNullStats["Arcade"]>) {
let wins = 0

View File

@@ -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)

View File

@@ -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)
}