Added warlords stats card
This commit is contained in:
24
src/lib/hypixel/warlords/general.ts
Normal file
24
src/lib/hypixel/warlords/general.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { CLASSES } from "@/data/hypixel/warlords"
|
||||
import { NonNullStats } from "@/lib/schema/player"
|
||||
|
||||
export function getWarlordsLosses(stats: NonNullable<NonNullStats["Warlords"]>) {
|
||||
return stats.mage_plays + stats.paladin_plays + stats.shaman_plays + stats.warrior_plays - stats.wins
|
||||
}
|
||||
|
||||
export function getWarlordsMostPlayedClass(stats: NonNullable<NonNullStats["Warlords"]>) {
|
||||
let mostPlayedClass: typeof CLASSES[number] | null = null
|
||||
let maxPlays = 0
|
||||
|
||||
for (const classObj of CLASSES) {
|
||||
if (classObj.id === "") continue
|
||||
|
||||
const plays = stats[`${classObj.id}_plays`]
|
||||
|
||||
if (plays > maxPlays) {
|
||||
maxPlays = plays
|
||||
mostPlayedClass = classObj
|
||||
}
|
||||
}
|
||||
|
||||
return mostPlayedClass
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import { smashHerosStats } from "./stats/smashheros"
|
||||
import { speedUhcStatsSchema } from "./stats/speeduhc"
|
||||
import { tntGamesStatsSchema } from "./stats/tnt-games"
|
||||
import { uhcSchema } from "./stats/uhc"
|
||||
import { warlordsStatsSchema } from "./stats/warlords"
|
||||
import { woolGamesStatsSchema } from "./stats/woolgames"
|
||||
|
||||
export const playerSchema = z.looseObject({
|
||||
@@ -42,13 +43,15 @@ export const playerSchema = z.looseObject({
|
||||
HungerGames: blitzStatsSchema.optional(),
|
||||
Arcade: arcadeStatsSchema.optional(),
|
||||
SpeedUHC: speedUhcStatsSchema.optional(),
|
||||
SuperSmash: smashHerosStats.optional()
|
||||
}).transform(({ Walls3, MCGO, HungerGames, SuperSmash, ...rest }) => {
|
||||
SuperSmash: smashHerosStats.optional(),
|
||||
Battleground: warlordsStatsSchema.optional()
|
||||
}).transform(({ Walls3, MCGO, HungerGames, SuperSmash, Battleground, ...rest }) => {
|
||||
return {
|
||||
MegaWalls: Walls3,
|
||||
CopsAndCrims: MCGO,
|
||||
Blitz: HungerGames,
|
||||
SmashHeros: SuperSmash,
|
||||
Warlords: Battleground,
|
||||
...rest
|
||||
}
|
||||
}).optional(),
|
||||
|
||||
25
src/lib/schema/stats/warlords.ts
Normal file
25
src/lib/schema/stats/warlords.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import z from "zod"
|
||||
|
||||
export const warlordsStatsSchema = z.object({
|
||||
kills: z.number().default(0),
|
||||
assists: z.number().default(0),
|
||||
deaths: z.number().default(0),
|
||||
wins: z.number().default(0),
|
||||
coins: z.number().default(0),
|
||||
magic_dust: z.number().default(0),
|
||||
void_shards: z.number().default(0),
|
||||
flag_conquer_self: z.number().default(0),
|
||||
flag_returns: z.number().default(0),
|
||||
mage_plays: z.number().default(0),
|
||||
paladin_plays: z.number().default(0),
|
||||
shaman_plays: z.number().default(0),
|
||||
warrior_plays: z.number().default(0),
|
||||
mage_wins: z.number().default(0),
|
||||
paladin_wins: z.number().default(0),
|
||||
shaman_wins: z.number().default(0),
|
||||
warrior_wins: z.number().default(0),
|
||||
mage_losses: z.number().default(0),
|
||||
paladin_losses: z.number().default(0),
|
||||
shaman_losses: z.number().default(0),
|
||||
warrior_losses: z.number().default(0)
|
||||
})
|
||||
Reference in New Issue
Block a user