Finished duels stats

This commit is contained in:
2025-09-02 13:57:52 +02:00
parent 83031f6526
commit 2b262025df
4 changed files with 82 additions and 30 deletions

View File

@@ -1,6 +1,7 @@
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { formatNumber } from "@/lib/formatters"
import { getBestDuelsMode, getDuelsModeStats, getModeTitle } from "@/lib/hypixel/duels/duels"
import { getBestDuelsMode, getDevision, getDuelsModeStats, getMode } from "@/lib/hypixel/duels/duels"
import { romanize } from "@/lib/hypixel/general"
import { NonNullStats } from "@/lib/schema/player"
export default function DuelsStatTable({ stats }: { stats: NonNullStats["Duels"] }) {
@@ -72,20 +73,18 @@ function DuelsTableHeader() {
)
}
function DuelsStat(
{ modeId, stats }: { modeId: Parameters<typeof getModeTitle>[0], stats: NonNullStats["Duels"] }
) {
function DuelsStat({ modeId, stats }: { modeId: Parameters<typeof getMode>[0], stats: NonNullStats["Duels"] }) {
if (!stats) return null
const modeStats = getDuelsModeStats(modeId, stats)
const title = getModeTitle(modeId)
const mode = getMode(modeId)
const bestMode = getBestDuelsMode(stats) === modeId
const divisionLabel = "I"
const div = getDevision(mode.divId, stats)
return (
<TableRow>
<TableCell className={bestMode ? "font-bold text-mc-light-purple" : undefined}>{title}</TableCell>
<TableCell>{divisionLabel}</TableCell>
<TableCell className={bestMode ? "font-bold text-mc-light-purple" : undefined}>{mode.name}</TableCell>
<TableCell className={div === null ? undefined : `text-mc-${div.color}`}>{div === null ? "?" : romanize(div.level)}</TableCell>
{modeStats.map((v, i) => (
<TableCell className={bestMode ? "font-bold text-mc-light-purple" : undefined} key={i}>
{typeof v === "number" ? formatNumber(v) : v}