Added blitz stat card
This commit is contained in:
17
src/lib/hypixel/blitz/general.ts
Normal file
17
src/lib/hypixel/blitz/general.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { KITS } from "@/data/hypixel/blitz"
|
||||
import { NonNullStats } from "@/lib/schema/player"
|
||||
|
||||
export function getBlitzMostPlayedKit(stats: NonNullable<NonNullStats["Blitz"]>) {
|
||||
let mostPlayedKit: typeof KITS[number] | null = null
|
||||
let maxTimePlayed = 0
|
||||
|
||||
for (const kit of KITS) {
|
||||
const timePlayed = stats[`time_played_${kit.id}`]
|
||||
if (timePlayed > maxTimePlayed) {
|
||||
maxTimePlayed = timePlayed
|
||||
mostPlayedKit = kit
|
||||
}
|
||||
}
|
||||
|
||||
return mostPlayedKit
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import z from "zod"
|
||||
import {
|
||||
bedwarsStatsSchema,
|
||||
blitzStatsSchema,
|
||||
buildBattleStatsSchema,
|
||||
copsAndCrimsStatsSchema,
|
||||
duelsStatsSchema,
|
||||
@@ -36,11 +37,13 @@ export const playerSchema = z.looseObject({
|
||||
TNTGames: tntGamesStatsSchema.optional(),
|
||||
Walls3: megawallsStats.optional(),
|
||||
MCGO: copsAndCrimsStatsSchema.optional(),
|
||||
WoolGames: woolGamesStatsSchema.optional()
|
||||
}).transform(({ Walls3, MCGO, ...rest }) => {
|
||||
WoolGames: woolGamesStatsSchema.optional(),
|
||||
HungerGames: blitzStatsSchema.optional()
|
||||
}).transform(({ Walls3, MCGO, HungerGames, ...rest }) => {
|
||||
return {
|
||||
MegaWalls: Walls3,
|
||||
CopsAndCrims: MCGO,
|
||||
Blitz: HungerGames,
|
||||
...rest
|
||||
}
|
||||
}).optional(),
|
||||
|
||||
@@ -789,3 +789,69 @@ export const woolGamesStatsSchema = z.object({
|
||||
}).optional()
|
||||
}).optional()
|
||||
})
|
||||
|
||||
function blitzKitPlayedStats() {
|
||||
const ids = [
|
||||
"arachnologist",
|
||||
"archer",
|
||||
"armorer",
|
||||
"astronaut",
|
||||
"baker",
|
||||
"blaze",
|
||||
"creepertamer",
|
||||
"diver",
|
||||
"donkeytamer",
|
||||
"farmer",
|
||||
"florist",
|
||||
"golem",
|
||||
"guardian",
|
||||
"horsetamer",
|
||||
"hunter",
|
||||
"hype train",
|
||||
"jockey",
|
||||
"knight",
|
||||
"meatmaster",
|
||||
"necromancer",
|
||||
"paladin",
|
||||
"phoenix",
|
||||
"pigman",
|
||||
"ranger",
|
||||
"reaper",
|
||||
"reddragon",
|
||||
"rogue",
|
||||
"scout",
|
||||
"shadow knight",
|
||||
"slimeyslime",
|
||||
"snowman",
|
||||
"speleologist",
|
||||
"tim",
|
||||
"toxicologist",
|
||||
"troll",
|
||||
"viking",
|
||||
"warlock",
|
||||
"warrior",
|
||||
"wolftamer"
|
||||
] as const
|
||||
|
||||
const stats = [
|
||||
"time_played"
|
||||
] 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 blitzStatsSchema = z.object({
|
||||
kills: z.number().default(0),
|
||||
deaths: z.number().default(0),
|
||||
wins_solo_normal: z.number().default(0),
|
||||
wins_team_normal: z.number().default(0),
|
||||
...blitzKitPlayedStats()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user