Updated mw stats
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
||||||
import { formatNumber } from "@/lib/formatters"
|
import { formatNumber } from "@/lib/formatters"
|
||||||
import { getMegaWallsModeName, getMegaWallsModeStats } from "@/lib/hypixel/megawalls/general"
|
import { romanize } from "@/lib/hypixel/general"
|
||||||
|
import { getAllClassStats, getDifficultyColor, getMegaWallsClass, getMegaWallsModeName, getMegaWallsModeStats } from "@/lib/hypixel/megawalls/general"
|
||||||
import { NonNullStats } from "@/lib/schema/player"
|
import { NonNullStats } from "@/lib/schema/player"
|
||||||
|
|
||||||
export function MegaWallsModesTable({ stats }: { stats: NonNullable<NonNullStats["MegaWalls"]> }) {
|
export function MegaWallsModesTable({ stats }: { stats: NonNullable<NonNullStats["MegaWalls"]> }) {
|
||||||
@@ -20,8 +21,7 @@ export function MegaWallsClassesTable({ stats }: { stats: NonNullable<NonNullSta
|
|||||||
return (
|
return (
|
||||||
<Table>
|
<Table>
|
||||||
<MegaWallsClassTableHeader />
|
<MegaWallsClassTableHeader />
|
||||||
<TableBody>
|
<MegaWallsClassStats stats={stats} />
|
||||||
</TableBody>
|
|
||||||
</Table>
|
</Table>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -76,6 +76,30 @@ function MegaWallsTableHeader() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function MegaWallsClassStats({ stats }: { stats: NonNullable<NonNullStats["MegaWalls"]> }) {
|
||||||
|
const classStats = getAllClassStats(stats)
|
||||||
|
return (
|
||||||
|
<TableBody>
|
||||||
|
{classStats.map((c, i) => {
|
||||||
|
const { id, val } = c
|
||||||
|
const klass = getMegaWallsClass(id)
|
||||||
|
const difColor = getDifficultyColor(klass.difficulty)
|
||||||
|
return (
|
||||||
|
<TableRow key={i}>
|
||||||
|
<TableCell className={`text-mc-${difColor}`}>{klass.name}</TableCell>
|
||||||
|
{val.map((v, j) => {
|
||||||
|
if (j === val.length - 2) {
|
||||||
|
return <TableCell key={j}>{v === 0 ? "-" : romanize(v)}</TableCell>
|
||||||
|
}
|
||||||
|
return <TableCell key={j}>{formatNumber(v)}</TableCell>
|
||||||
|
})}
|
||||||
|
</TableRow>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</TableBody>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function MegaWallsModeStat(
|
function MegaWallsModeStat(
|
||||||
{ modeId, stats }: { modeId: Parameters<typeof getMegaWallsModeStats>[0], stats: NonNullable<NonNullStats["MegaWalls"]> }
|
{ modeId, stats }: { modeId: Parameters<typeof getMegaWallsModeStats>[0], stats: NonNullable<NonNullStats["MegaWalls"]> }
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -28,6 +28,36 @@ export function getMegaWallsModeName(modeId: typeof MODES[number]["id"]) {
|
|||||||
return MODES.find(m => m.id === modeId)!.name
|
return MODES.find(m => m.id === modeId)!.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getMegaWallsClass(classId: typeof CLASSES[number]["id"]) {
|
||||||
|
return CLASSES.find(c => c.id === classId)!
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAllClassStats(stats: NonNullable<NonNullStats["MegaWalls"]>) {
|
||||||
|
const statsArr: { id: typeof CLASSES[number]["id"], val: number[] }[] = []
|
||||||
|
|
||||||
|
for (const klass of CLASSES) {
|
||||||
|
statsArr.push({ id: klass.id, val: megaWalsClassStats(klass.id, stats) })
|
||||||
|
}
|
||||||
|
|
||||||
|
return statsArr
|
||||||
|
}
|
||||||
|
|
||||||
|
export function megaWalsClassStats(classId: typeof CLASSES[number]["id"], stats: NonNullable<NonNullStats["MegaWalls"]>) {
|
||||||
|
return [
|
||||||
|
stats[`${classId}_kills`],
|
||||||
|
stats[`${classId}_deaths`],
|
||||||
|
devide(stats[`${classId}_kills`], stats[`${classId}_deaths`]),
|
||||||
|
stats[`${classId}_final_kills`],
|
||||||
|
stats[`${classId}_final_deaths`],
|
||||||
|
devide(stats[`${classId}_final_kills`], stats[`${classId}_final_deaths`]),
|
||||||
|
stats[`${classId}_wins`],
|
||||||
|
stats[`${classId}_losses`],
|
||||||
|
devide(stats[`${classId}_wins`], stats[`${classId}_deaths`]),
|
||||||
|
stats.classes === undefined ? 0 : stats.classes[classId].prestige,
|
||||||
|
stats.classes === undefined ? 0 : stats.classes[classId].enderchest_rows
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
export function getMegaWallsModeStats(modeId: typeof MODES[number]["id"], stats: NonNullable<NonNullStats["MegaWalls"]>) {
|
export function getMegaWallsModeStats(modeId: typeof MODES[number]["id"], stats: NonNullable<NonNullStats["MegaWalls"]>) {
|
||||||
return [
|
return [
|
||||||
stats[`kills_${modeId}`],
|
stats[`kills_${modeId}`],
|
||||||
|
|||||||
@@ -586,19 +586,38 @@ function megawallsClassStats() {
|
|||||||
] as const
|
] as const
|
||||||
|
|
||||||
const stats = [
|
const stats = [
|
||||||
|
"kills",
|
||||||
|
"deaths",
|
||||||
|
"final_kills",
|
||||||
|
"final_deaths",
|
||||||
"wins",
|
"wins",
|
||||||
"losses"
|
"losses"
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
|
const classesOther = [
|
||||||
|
"prestige",
|
||||||
|
"enderchest_rows"
|
||||||
|
] as const
|
||||||
|
|
||||||
const entries = new Map<string, z.ZodDefault<z.ZodNumber>>()
|
const entries = new Map<string, z.ZodDefault<z.ZodNumber>>()
|
||||||
|
const classes = new Map<string, z.ZodObject<{ prestige: z.ZodDefault<z.ZodNumber>, enderchest_rows: z.ZodDefault<z.ZodNumber> }, z.core.$loose>>()
|
||||||
|
|
||||||
for (const id of ids) {
|
for (const id of ids) {
|
||||||
for (const stat of stats) {
|
for (const stat of stats) {
|
||||||
entries.set(`${id}_${stat}`, z.number().default(0))
|
entries.set(`${id}_${stat}`, z.number().default(0))
|
||||||
}
|
}
|
||||||
|
for (const klass of classesOther) {
|
||||||
|
classes.set(id, z.looseObject({ prestige: z.number().default(0), enderchest_rows: z.number().default(0) }))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Object.fromEntries(entries) as Record<`${typeof ids[number]}_${typeof stats[number]}`, z.ZodDefault<z.ZodNumber>>
|
return {
|
||||||
|
classStats: Object.fromEntries(entries) as Record<`${typeof ids[number]}_${typeof stats[number]}`, z.ZodDefault<z.ZodNumber>>,
|
||||||
|
classOther: Object.fromEntries(classes) as Record<
|
||||||
|
`${typeof ids[number]}`,
|
||||||
|
z.ZodObject<{ prestige: z.ZodDefault<z.ZodNumber>, enderchest_rows: z.ZodDefault<z.ZodNumber> }, z.core.$loose>
|
||||||
|
>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function megawallsModeStats() {
|
function megawallsModeStats() {
|
||||||
@@ -640,6 +659,7 @@ 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(),
|
classes: z.looseObject(megawallsClassStats().classOther).optional(),
|
||||||
|
...megawallsClassStats().classStats,
|
||||||
...megawallsModeStats()
|
...megawallsModeStats()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user