Added mw modes table
This commit is contained in:
@@ -8,6 +8,7 @@ import { NonNullStats } from "@/lib/schema/player"
|
|||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import CollapsedStats from "../../_components/CollapsedStats"
|
import CollapsedStats from "../../_components/CollapsedStats"
|
||||||
import MegaWallsGeneralStats from "./stats"
|
import MegaWallsGeneralStats from "./stats"
|
||||||
|
import { MegaWallsClassesTable, MegaWallsModesTable } from "./table"
|
||||||
|
|
||||||
export default function MegaWallsStats({ stats }: { stats: NonNullStats["MegaWalls"] }) {
|
export default function MegaWallsStats({ stats }: { stats: NonNullStats["MegaWalls"] }) {
|
||||||
if (!stats) return null
|
if (!stats) return null
|
||||||
@@ -59,6 +60,10 @@ export default function MegaWallsStats({ stats }: { stats: NonNullStats["MegaWal
|
|||||||
<Separator className="my-4" />
|
<Separator className="my-4" />
|
||||||
<MegaWallsGeneralStats stats={stats} />
|
<MegaWallsGeneralStats stats={stats} />
|
||||||
<Separator className="my-4" />
|
<Separator className="my-4" />
|
||||||
|
<MegaWallsClassesTable stats={stats} />
|
||||||
|
<Separator className="my-4" />
|
||||||
|
<MegaWallsModesTable stats={stats} />
|
||||||
|
<Separator className="my-4" />
|
||||||
</AccordionContent>
|
</AccordionContent>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
93
src/app/(stats)/player/[ign]/_stats/megawalls/table.tsx
Normal file
93
src/app/(stats)/player/[ign]/_stats/megawalls/table.tsx
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
||||||
|
import { formatNumber } from "@/lib/formatters"
|
||||||
|
import { getMegaWallsModeName, getMegaWallsModeStats } from "@/lib/hypixel/megawalls/general"
|
||||||
|
import { NonNullStats } from "@/lib/schema/player"
|
||||||
|
|
||||||
|
export function MegaWallsModesTable({ stats }: { stats: NonNullable<NonNullStats["MegaWalls"]> }) {
|
||||||
|
return (
|
||||||
|
<Table>
|
||||||
|
<MegaWallsTableHeader />
|
||||||
|
<TableBody>
|
||||||
|
<MegaWallsModeStat modeId="standard" stats={stats} />
|
||||||
|
<MegaWallsModeStat modeId="face_off" stats={stats} />
|
||||||
|
<MegaWallsModeStat modeId="gvg" stats={stats} />
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function MegaWallsClassesTable({ stats }: { stats: NonNullable<NonNullStats["MegaWalls"]> }) {
|
||||||
|
return (
|
||||||
|
<Table>
|
||||||
|
<MegaWallsClassTableHeader />
|
||||||
|
<TableBody>
|
||||||
|
</TableBody>
|
||||||
|
</Table>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function MegaWallsClassTableHeader() {
|
||||||
|
const headerElements = [
|
||||||
|
"Class",
|
||||||
|
"Kills",
|
||||||
|
"Deaths",
|
||||||
|
"KD",
|
||||||
|
"Kills",
|
||||||
|
"Deaths",
|
||||||
|
"KD",
|
||||||
|
"Wins",
|
||||||
|
"Losses",
|
||||||
|
"WL",
|
||||||
|
"Prestige",
|
||||||
|
"Ender Chest"
|
||||||
|
]
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TableHeader>
|
||||||
|
<TableRow>
|
||||||
|
<TableHead></TableHead>
|
||||||
|
<TableHead colSpan={3} className="font-bold">Normal</TableHead>
|
||||||
|
<TableHead colSpan={3} className="font-bold">Finals</TableHead>
|
||||||
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
{headerElements.map((v, i) => <TableHead key={i} className="font-bold">{v}</TableHead>)}
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function MegaWallsTableHeader() {
|
||||||
|
const headerElements = [
|
||||||
|
"Mode",
|
||||||
|
"Kills",
|
||||||
|
"Deaths",
|
||||||
|
"KD",
|
||||||
|
"Wins",
|
||||||
|
"Losses",
|
||||||
|
"WL"
|
||||||
|
]
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TableHeader>
|
||||||
|
<TableRow>
|
||||||
|
{headerElements.map((v, i) => <TableHead key={i} className="font-bold">{v}</TableHead>)}
|
||||||
|
</TableRow>
|
||||||
|
</TableHeader>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function MegaWallsModeStat(
|
||||||
|
{ modeId, stats }: { modeId: Parameters<typeof getMegaWallsModeStats>[0], stats: NonNullable<NonNullStats["MegaWalls"]> }
|
||||||
|
) {
|
||||||
|
const modeName = getMegaWallsModeName(modeId)
|
||||||
|
const modeStat = getMegaWallsModeStats(modeId, stats)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TableRow>
|
||||||
|
<TableCell>{modeName}</TableCell>
|
||||||
|
{modeStat.map((s, i) => {
|
||||||
|
return <TableCell key={i}>{formatNumber(s)}</TableCell>
|
||||||
|
})}
|
||||||
|
</TableRow>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import { CLASSES, DIFFICULTIES } from "@/data/hypixel/megawalls"
|
import { CLASSES, DIFFICULTIES, MODES } from "@/data/hypixel/megawalls"
|
||||||
import { NonNullStats } from "@/lib/schema/player"
|
import { NonNullStats } from "@/lib/schema/player"
|
||||||
|
import { devide } from "../general"
|
||||||
|
|
||||||
export function getMostPlayed(stats: NonNullable<NonNullStats["MegaWalls"]>) {
|
export function getMostPlayed(stats: NonNullable<NonNullStats["MegaWalls"]>) {
|
||||||
let mostPlayedClass: typeof CLASSES[number] | null = null
|
let mostPlayedClass: typeof CLASSES[number] | null = null
|
||||||
@@ -22,3 +23,18 @@ export function getMostPlayed(stats: NonNullable<NonNullStats["MegaWalls"]>) {
|
|||||||
export function getDifficultyColor(val: 1 | 2 | 3 | 4) {
|
export function getDifficultyColor(val: 1 | 2 | 3 | 4) {
|
||||||
return DIFFICULTIES[val]
|
return DIFFICULTIES[val]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getMegaWallsModeName(modeId: typeof MODES[number]["id"]) {
|
||||||
|
return MODES.find(m => m.id === modeId)!.name
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getMegaWallsModeStats(modeId: typeof MODES[number]["id"], stats: NonNullable<NonNullStats["MegaWalls"]>) {
|
||||||
|
return [
|
||||||
|
stats[`kills_${modeId}`],
|
||||||
|
stats[`deaths_${modeId}`],
|
||||||
|
devide(stats[`kills_${modeId}`], stats[`deaths_${modeId}`]),
|
||||||
|
stats[`wins_${modeId}`],
|
||||||
|
stats[`losses_${modeId}`],
|
||||||
|
devide(stats[`wins_${modeId}`], stats[`losses_${modeId}`])
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
@@ -554,7 +554,7 @@ export const tntGamesStatsSchema = z.looseObject({
|
|||||||
...tntGamesModeStats()
|
...tntGamesModeStats()
|
||||||
})
|
})
|
||||||
|
|
||||||
function megawallsModeStats() {
|
function megawallsClassStats() {
|
||||||
const ids = [
|
const ids = [
|
||||||
"angel",
|
"angel",
|
||||||
"arcanist",
|
"arcanist",
|
||||||
@@ -601,6 +601,31 @@ function megawallsModeStats() {
|
|||||||
return Object.fromEntries(entries) as Record<`${typeof ids[number]}_${typeof stats[number]}`, z.ZodDefault<z.ZodNumber>>
|
return Object.fromEntries(entries) as Record<`${typeof ids[number]}_${typeof stats[number]}`, z.ZodDefault<z.ZodNumber>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function megawallsModeStats() {
|
||||||
|
const ids = [
|
||||||
|
"standard",
|
||||||
|
"face_off",
|
||||||
|
"gvg"
|
||||||
|
] as const
|
||||||
|
|
||||||
|
const stats = [
|
||||||
|
"kills",
|
||||||
|
"deaths",
|
||||||
|
"wins",
|
||||||
|
"losses"
|
||||||
|
] 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 megawallsStats = z.looseObject({
|
export const megawallsStats = z.looseObject({
|
||||||
kills: z.number().default(0),
|
kills: z.number().default(0),
|
||||||
assists: z.number().default(0),
|
assists: z.number().default(0),
|
||||||
@@ -615,5 +640,6 @@ export const megawallsStats = z.looseObject({
|
|||||||
coins: z.number().default(0),
|
coins: z.number().default(0),
|
||||||
wither_damage: z.number().default(0),
|
wither_damage: z.number().default(0),
|
||||||
witherDamage: z.number().default(0),
|
witherDamage: z.number().default(0),
|
||||||
|
...megawallsClassStats(),
|
||||||
...megawallsModeStats()
|
...megawallsModeStats()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user