Added mega walls card

This commit is contained in:
2025-09-07 11:36:19 +02:00
parent 4612222207
commit 33d02113da
6 changed files with 195 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
import { CLASSES, DIFFICULTIES } from "@/data/hypixel/megawalls"
import { NonNullStats } from "@/lib/schema/player"
export function getMostPlayed(stats: NonNullable<NonNullStats["MegaWalls"]>) {
let mostPlayedClass: typeof CLASSES[number] | null = null
let maxPlays = 0
for (const classObj of CLASSES) {
const wins = stats[`${classObj.id}_wins`] || 0
const losses = stats[`${classObj.id}_losses`] || 0
const totalPlays = wins + losses
if (totalPlays > maxPlays) {
maxPlays = totalPlays
mostPlayedClass = classObj
}
}
return mostPlayedClass
}
export function getDifficultyColor(val: 1 | 2 | 3 | 4) {
return DIFFICULTIES[val]
}

View File

@@ -3,6 +3,7 @@ import {
bedwarsStatsSchema,
buildBattleStatsSchema,
duelsStatsSchema,
megawallsStats,
murderMysteryStatsSchema,
pitStats,
skywarsStatsSchema,
@@ -30,7 +31,13 @@ export const playerSchema = z.looseObject({
BuildBattle: buildBattleStatsSchema.optional(),
UHC: uhcSchema.optional(),
Pit: pitStats.optional(),
TNTGames: tntGamesStatsSchema.optional()
TNTGames: tntGamesStatsSchema.optional(),
Walls3: megawallsStats.optional()
}).transform(({ Walls3, ...rest }) => {
return {
MegaWalls: Walls3,
...rest
}
}).optional(),
quests: z.record(
z.string(),

View File

@@ -553,3 +553,60 @@ export const tntGamesStatsSchema = z.looseObject({
deaths_capture: z.number().default(0),
...tntGamesModeStats()
})
function megawallsModeStats() {
const ids = [
"angel",
"arcanist",
"assassin",
"automaton",
"blaze",
"cow",
"creeper",
"dragon",
"dreadlord",
"enderman",
"golem",
"herobrine",
"hunter",
"moleman",
"phoenix",
"pigman",
"pirate",
"renegade",
"shaman",
"shark",
"sheep",
"skeleton",
"snowman",
"spider",
"squid",
"werewolf",
"zombie"
] as const
const stats = [
"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(`${id}_${stat}`, z.number().default(0))
}
}
return Object.fromEntries(entries) as Record<`${typeof ids[number]}_${typeof stats[number]}`, z.ZodDefault<z.ZodNumber>>
}
export const megawallsStats = z.looseObject({
kills: z.number().default(0),
deaths: z.number().default(0),
wins: z.number().default(0),
losses: z.number().default(0),
final_kills: z.number().default(0),
final_deaths: z.number().default(0),
...megawallsModeStats()
})