Finished smash heros card header

This commit is contained in:
2025-09-18 10:19:07 +02:00
parent 28a63b43b0
commit c6a4fe2a55
7 changed files with 142 additions and 4 deletions

View File

@@ -0,0 +1,25 @@
import { DIFFICULTY, HEROES } from "@/data/hypixel/smashheros"
import { NonNullStats } from "@/lib/schema/player"
export function getSmashHerosDifficultyColor(difficulty: number) {
if (difficulty < 1) return DIFFICULTY.at(0)!
if (difficulty > DIFFICULTY.length) return DIFFICULTY.at(-1)!
return DIFFICULTY.at(difficulty - 1)!
}
export function getSmashHerosMostPlayedHero(stats: NonNullable<NonNullStats["SmashHeros"]>) {
if (!stats.class_stats) return null
let maxGames = 0
let mostPlayedHero: typeof HEROES[number] | null = null
for (const hero of HEROES) {
const games = stats.class_stats[hero.id]?.games ?? 0
if (games > maxGames) {
maxGames = games
mostPlayedHero = hero
}
}
return mostPlayedHero
}

View File

@@ -9,6 +9,7 @@ import { megawallsStats } from "./stats/megawalls"
import { murderMysteryStatsSchema } from "./stats/murder-mystery"
import { pitStats } from "./stats/pit"
import { skywarsStatsSchema } from "./stats/skywars"
import { smashHerosStats } from "./stats/smashheros"
import { speedUhcStatsSchema } from "./stats/speeduhc"
import { tntGamesStatsSchema } from "./stats/tnt-games"
import { uhcSchema } from "./stats/uhc"
@@ -40,12 +41,14 @@ export const playerSchema = z.looseObject({
WoolGames: woolGamesStatsSchema.optional(),
HungerGames: blitzStatsSchema.optional(),
Arcade: arcadeStatsSchema.optional(),
SpeedUHC: speedUhcStatsSchema.optional()
}).transform(({ Walls3, MCGO, HungerGames, ...rest }) => {
SpeedUHC: speedUhcStatsSchema.optional(),
SuperSmash: smashHerosStats.optional()
}).transform(({ Walls3, MCGO, HungerGames, SuperSmash, ...rest }) => {
return {
MegaWalls: Walls3,
CopsAndCrims: MCGO,
Blitz: HungerGames,
SmashHeros: SuperSmash,
...rest
}
}).optional(),

View File

@@ -0,0 +1,31 @@
import z from "zod"
const classStats = z.object({
games: z.number().default(0)
}).optional()
export const smashHerosStats = z.object({
kills: z.number().default(0),
deaths: z.number().default(0),
wins: z.number().default(0),
losses: z.number().default(0),
smashLevel: z.number().default(0),
class_stats: z.object({
BOTMUN: classStats,
THE_BULK: classStats,
CAKE_MONSTER: classStats,
FROSTY: classStats,
GENERAL_CLUCK: classStats,
GREEN_HOOD: classStats,
GOKU: classStats,
MARAUDER: classStats,
PUG: classStats,
SANIC: classStats,
SERGEANT_SHIELD: classStats,
SHOOP_DA_WHOOP: classStats,
SKULLFIRE: classStats,
SPODERMAN: classStats,
TINMAN: classStats,
DUSK_CRAWLER: classStats
}).optional()
})