Added mw modes table

This commit is contained in:
2025-09-07 18:38:17 +02:00
parent aa552a9142
commit e0a54114d0
4 changed files with 142 additions and 2 deletions

View File

@@ -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<NonNullStats["MegaWalls"]>) {
let mostPlayedClass: typeof CLASSES[number] | null = null
@@ -22,3 +23,18 @@ export function getMostPlayed(stats: NonNullable<NonNullStats["MegaWalls"]>) {
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<NonNullStats["MegaWalls"]>) {
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}`])
]
}

View File

@@ -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<z.ZodNumber>>
}
function megawallsModeStats() {
const ids = [
"standard",
"face_off",
"gvg"
] as const
const stats = [
"kills",
"deaths",
"wins",
"losses"
] as const
const entries = new Map<string, z.ZodDefault<z.ZodNumber>>()
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<z.ZodNumber>>
}
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()
})