diff --git a/src/app/(stats)/player/[ign]/_stats/arcade/stats.tsx b/src/app/(stats)/player/[ign]/_stats/arcade/stats.tsx index 0ed0108..f41ae91 100644 --- a/src/app/(stats)/player/[ign]/_stats/arcade/stats.tsx +++ b/src/app/(stats)/player/[ign]/_stats/arcade/stats.tsx @@ -3,7 +3,7 @@ import { devide } from "@/lib/hypixel/general" import { NonNullStats } from "@/lib/schema/player" import { capitalizeFirstLetter } from "@/lib/utils" import { BasicStat } from "../../_components/Stats" -import { PixelPartyStatsTable } from "./table" +import { ArcadePixelPartyStatsTable, ArcadeZombieStatsTable, ArcadeZombieTypesTable } from "./table" export function ArcadeZombieStats({ stats }: { stats: NonNullable }) { const bha = devide(stats.bullets_hit_zombies, stats.bullets_shot_zombies) * 100 @@ -38,6 +38,8 @@ export function ArcadeZombieStats({ stats }: { stats: NonNullable + + ) } @@ -63,7 +65,7 @@ export function ArcadePixelPartyStats({ stats }: { stats: NonNullable - + ) } diff --git a/src/app/(stats)/player/[ign]/_stats/arcade/table.tsx b/src/app/(stats)/player/[ign]/_stats/arcade/table.tsx index bc59a51..6303e9e 100644 --- a/src/app/(stats)/player/[ign]/_stats/arcade/table.tsx +++ b/src/app/(stats)/player/[ign]/_stats/arcade/table.tsx @@ -1,23 +1,128 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { formatNumber } from "@/lib/formatters" -import { getArcadeMostPlayedPixelPartyMode, getArcadePixelPartyModeName, getArcadePixelPartyModeStats } from "@/lib/hypixel/arcade/general" +import { + getArcadeMostPlayedPixelPartyMode, + getArcadePixelPartyModeName, + getArcadePixelPartyModeStats, + getArcadeZombiesBestMode, + getArcadeZombiesMode, + getArcadeZombiesModeStats, + getArcadeZombiesType, + getArcadeZombiesTypeStats +} from "@/lib/hypixel/arcade/general" import { NonNullStats } from "@/lib/schema/player" import { cn } from "@/lib/utils" -export function PixelPartyStatsTable({ stats }: { stats: NonNullable["pixel_party"] }) { +export function ArcadeZombieTypesTable({ stats }: { stats: NonNullable }) { return ( - + + +
+ ) +} + +function ArcadeZombieTypes({ stats }: { stats: NonNullable }) { + const wins = getArcadeZombiesTypeStats(stats) + + return ( + + {wins.map((w, i) => { + const { id, wins } = w + const type = getArcadeZombiesType(id) + + return ( + + {type.name} + {formatNumber(wins)} + + ) + })} + + ) +} + +function ArcadeZombieTypesTableHeader() { + const headerElements = [ + "Zombies", + "Kills" + ] + + return ( + + + {headerElements.map((v, i) => {v})} + + + ) +} + +export function ArcadeZombieStatsTable({ stats }: { stats: NonNullable }) { + return ( + + - - - + + +
) } -function PixelPartyTableStat( +function ArcadeZombiesTableStat( + { modeId, stats }: { modeId: Parameters[0], stats: NonNullable } +) { + const mode = getArcadeZombiesMode(modeId) + const modeStats = getArcadeZombiesModeStats(modeId, stats) + const isMostPlayed = getArcadeZombiesBestMode(stats) === modeId + + return ( + + {mode.name} + {modeStats.map((v, i) => { + return {formatNumber(v)} + })} + + ) +} + +function ArcadeZombiesTableHeader() { + const headerElements = [ + "Map", + "Downs", + "Revives", + "Doors Opened", + "Windows Repaired", + "Zombies Killed", + "Deaths", + "Best Round", + "Wins" + ] + + return ( + + + {headerElements.map((v, i) => {v})} + + + ) +} + +export function ArcadePixelPartyStatsTable({ stats }: { stats: NonNullable["pixel_party"] }) { + return ( + + + + + + + +
+ ) +} + +function ArcadePixelPartyTableStat( { modeId, stats }: { modeId: Parameters[0], stats: NonNullable["pixel_party"] } ) { const modeName = getArcadePixelPartyModeName(modeId) @@ -35,7 +140,7 @@ function PixelPartyTableStat( ) } -function PixelPartyStatsTableHeader() { +function ArcadePixelPartyStatsTableHeader() { const headerElements = [ "Mode", "Wins", diff --git a/src/data/hypixel/arcade.ts b/src/data/hypixel/arcade.ts index 88ce7ae..7a7ac83 100644 --- a/src/data/hypixel/arcade.ts +++ b/src/data/hypixel/arcade.ts @@ -26,30 +26,30 @@ export const WINS = [ export const ZOMBIESMODES = [ { id: "deadend", name: "Dead End", color: "gold" }, { id: "badblood", name: "Bad Blood", color: "red" }, - { id: "alienarcadium", name: "Alien Arcadium", color: "pink" } + { id: "alienarcadium", name: "Alien Arcadium", color: "light-purple" } ] as const export const ZOMBIESTYPES = [ - { id: "basic", name: "Basic" }, - { id: "blaze", name: "Blaze" }, - { id: "empowered", name: "Empowered" }, - { id: "ender", name: "Ender" }, - { id: "endermite", name: "Endermite" }, - { id: "fire", name: "Fire" }, - { id: "guardian", name: "Guardian" }, - { id: "magma", name: "Magma" }, - { id: "magma_cube", name: "Magma Cube" }, - { id: "pig_zombie", name: "Pig Zombie" }, - { id: "skelefish", name: "Skelefish" }, - { id: "tnt_baby", name: "TNT Baby" }, + { id: "basic", name: "Basic", color: null }, + { id: "blaze", name: "Blaze", color: null }, + { id: "empowered", name: "Empowered", color: null }, + { id: "ender", name: "Ender", color: null }, + { id: "endermite", name: "Endermite", color: null }, + { id: "fire", name: "Fire", color: null }, + { id: "guardian", name: "Guardian", color: null }, + { id: "magma", name: "Magma", color: null }, + { id: "magma_cube", name: "Magma Cube", color: null }, + { id: "pig_zombie", name: "Pig Zombie", color: null }, + { id: "skelefish", name: "Skelefish", color: null }, + { id: "tnt_baby", name: "TNT Baby", color: null }, { id: "tnt", name: "Bombie", color: "gold" }, { id: "inferno", name: "Inferno", color: "gold" }, { id: "broodmother", name: "Broodmother", color: "gold" }, { id: "king_slime", name: "King Slime", color: "red" }, { id: "wither", name: "Wither", color: "red" }, { id: "herobrine", name: "Herobrine", color: "red" }, - { id: "mega_blob", name: "Mega Blob", color: "pink" }, - { id: "mega_magma", name: "Mega Magma", color: "pink" }, - { id: "world_ender", name: "World Ender", color: "pink" } + { id: "mega_blob", name: "Mega Blob", color: "light-purple" }, + { id: "mega_magma", name: "Mega Magma", color: "light-purple" }, + { id: "world_ender", name: "World Ender", color: "light-purple" } ] as const export const PIXELPARTYMODES = [ { id: "normal", name: "Normal" }, diff --git a/src/lib/hypixel/arcade/general.ts b/src/lib/hypixel/arcade/general.ts index 308020a..e49f7dd 100644 --- a/src/lib/hypixel/arcade/general.ts +++ b/src/lib/hypixel/arcade/general.ts @@ -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) { + 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) { + 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) { + 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["pixel_party"]) { if (!stats) return null const played = [ diff --git a/src/lib/schema/stats.ts b/src/lib/schema/stats.ts index 9d79782..8748315 100644 --- a/src/lib/schema/stats.ts +++ b/src/lib/schema/stats.ts @@ -912,6 +912,67 @@ function arcadeModeWins() { return Object.fromEntries(entries) as Record<`${typeof ids[number]}`, z.ZodDefault> } +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>() + 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> +} + +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>() + 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> +} + 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() })