Finished UHC stats

This commit is contained in:
2025-09-04 23:00:24 +02:00
parent 27a8e89d7b
commit 1ac24b8a30
3 changed files with 106 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import { MODES } from "@/data/hypixel/uhc"
import { NonNullStats } from "@/lib/schema/player"
import { devide } from "../general"
export function getStatsCombined(stats: NonNullable<NonNullStats["UHC"]>) {
return {
@@ -10,6 +11,44 @@ export function getStatsCombined(stats: NonNullable<NonNullStats["UHC"]>) {
}
}
export function getUHCModeName(modeId: typeof MODES[number]["id"]) {
return MODES.find(m => m.id === modeId)!.name
}
export function getUHCModeStats(modeId: typeof MODES[number]["id"] | "all_modes", stats: NonNullable<NonNullStats["UHC"]>) {
if (modeId === "all_modes") {
const statsCombined = getStatsCombined(stats)
return [
statsCombined.kills,
statsCombined.deaths,
devide(statsCombined.kills, statsCombined.deaths),
statsCombined.wins,
devide(statsCombined.kills, statsCombined.kills),
statsCombined.heads
]
}
if (modeId === "") {
return [
stats[`kills`],
stats[`deaths`],
devide(stats[`kills`], stats[`deaths`]),
stats[`wins`],
devide(stats[`kills`], stats[`wins`]),
stats[`heads_eaten`]
]
}
return [
stats[`kills_${modeId}`],
stats[`deaths_${modeId}`],
devide(stats[`kills_${modeId}`], stats[`deaths_${modeId}`]),
stats[`wins_${modeId}`],
devide(stats[`kills_${modeId}`], stats[`wins_${modeId}`]),
stats[`heads_eaten_${modeId}`]
]
}
function getUHCWins(stats: NonNullable<NonNullStats["UHC"]>) {
let wins = 0
const ids = MODES.filter(m => m.id !== "").map(m => m.id)