Added zombie type stats
This commit is contained in:
@@ -1,7 +1,51 @@
|
||||
import { PIXELPARTYMODES, WINS } from "@/data/hypixel/arcade"
|
||||
import { PIXELPARTYMODES, WINS, ZOMBIESMODES, ZOMBIESTYPES } from "@/data/hypixel/arcade"
|
||||
import { NonNullStats } from "@/lib/schema/player"
|
||||
import { devide } from "../general"
|
||||
|
||||
export function getArcadeZombiesType(typeId: typeof ZOMBIESTYPES[number]["id"]) {
|
||||
return ZOMBIESTYPES.find(t => t.id === typeId)!
|
||||
}
|
||||
|
||||
export function getArcadeZombiesTypeStats(stats: NonNullable<NonNullStats["Arcade"]>) {
|
||||
const nums: { id: typeof ZOMBIESTYPES[number]["id"], wins: number }[] = []
|
||||
|
||||
for (const type of ZOMBIESTYPES) {
|
||||
nums.push({ id: type.id, wins: stats[`${type.id}_zombie_kills_zombies`] })
|
||||
}
|
||||
|
||||
return nums
|
||||
}
|
||||
|
||||
export function getArcadeZombiesMode(modeId: typeof ZOMBIESMODES[number]["id"]) {
|
||||
return ZOMBIESMODES.find(m => m.id === modeId)!
|
||||
}
|
||||
|
||||
export function getArcadeZombiesBestMode(stats: NonNullable<NonNullStats["Arcade"]>) {
|
||||
const modes = ZOMBIESMODES.map(mode => ({
|
||||
modeId: mode.id,
|
||||
bestRound: stats[`best_round_zombies_${mode.id}`]
|
||||
}))
|
||||
|
||||
if (modes.map(m => m.bestRound).reduce((a, b) => a + b) === 0) return null
|
||||
|
||||
const bestMode = modes.reduce((max, current) => current.bestRound > max.bestRound ? current : max)
|
||||
|
||||
return bestMode.modeId
|
||||
}
|
||||
|
||||
export function getArcadeZombiesModeStats(modeId: typeof ZOMBIESMODES[number]["id"], stats: NonNullable<NonNullStats["Arcade"]>) {
|
||||
return [
|
||||
stats[`times_knocked_down_zombies_${modeId}`],
|
||||
stats[`players_revived_zombies_${modeId}`],
|
||||
stats[`doors_opened_zombies_${modeId}`],
|
||||
stats[`windows_repaired_zombies_${modeId}`],
|
||||
stats[`zombie_kills_zombies_${modeId}`],
|
||||
stats[`deaths_zombies_${modeId}`],
|
||||
stats[`best_round_zombies_${modeId}`],
|
||||
stats[`wins_zombies_${modeId}`]
|
||||
]
|
||||
}
|
||||
|
||||
export function getArcadeMostPlayedPixelPartyMode(stats: NonNullable<NonNullStats["Arcade"]>["pixel_party"]) {
|
||||
if (!stats) return null
|
||||
const played = [
|
||||
|
||||
@@ -912,6 +912,67 @@ function arcadeModeWins() {
|
||||
return Object.fromEntries(entries) as Record<`${typeof ids[number]}`, z.ZodDefault<z.ZodNumber>>
|
||||
}
|
||||
|
||||
function arcadeZombiesModeStats() {
|
||||
const ids = [
|
||||
"deadend",
|
||||
"badblood",
|
||||
"alienarcadium"
|
||||
] as const
|
||||
|
||||
const stats = [
|
||||
"times_knocked_down_zombies",
|
||||
"players_revived_zombies",
|
||||
"doors_opened_zombies",
|
||||
"windows_repaired_zombies",
|
||||
"zombie_kills_zombies",
|
||||
"deaths_zombies",
|
||||
"best_round_zombies",
|
||||
"wins_zombies"
|
||||
] 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>>
|
||||
}
|
||||
|
||||
function arcadeZombiesTypeStats() {
|
||||
const ids = [
|
||||
"basic",
|
||||
"blaze",
|
||||
"empowered",
|
||||
"ender",
|
||||
"endermite",
|
||||
"fire",
|
||||
"guardian",
|
||||
"magma",
|
||||
"magma_cube",
|
||||
"pig_zombie",
|
||||
"skelefish",
|
||||
"tnt_baby",
|
||||
"tnt",
|
||||
"inferno",
|
||||
"broodmother",
|
||||
"king_slime",
|
||||
"wither",
|
||||
"herobrine",
|
||||
"mega_blob",
|
||||
"mega_magma",
|
||||
"world_ender"
|
||||
] as const
|
||||
|
||||
const entries = new Map<string, z.ZodDefault<z.ZodNumber>>()
|
||||
for (const id of ids) {
|
||||
entries.set(`${id}_zombie_kills_zombies`, z.number().default(0))
|
||||
}
|
||||
|
||||
return Object.fromEntries(entries) as Record<`${typeof ids[number]}_zombie_kills_zombies`, z.ZodDefault<z.ZodNumber>>
|
||||
}
|
||||
|
||||
export const arcadeStatsSchema = z.object({
|
||||
miniwalls_activeKit: z.string().optional(),
|
||||
wither_kills_mini_walls: z.number().default(0),
|
||||
@@ -949,5 +1010,7 @@ export const arcadeStatsSchema = z.object({
|
||||
dropper: z.object({
|
||||
wins: z.number().default(0)
|
||||
}).optional(),
|
||||
...arcadeModeWins()
|
||||
...arcadeModeWins(),
|
||||
...arcadeZombiesModeStats(),
|
||||
...arcadeZombiesTypeStats()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user