Added duels kits stats table
This commit is contained in:
@@ -6,7 +6,7 @@ import { NonNullStats } from "@/lib/schema/player"
|
||||
import { cn } from "@/lib/utils"
|
||||
import GeneralStats from "../GeneralStats"
|
||||
import BlitzGeneralStats from "./stats"
|
||||
import { BlitzModeStatsTable } from "./table"
|
||||
import { BlitzKitStatsTable, BlitzModeStatsTable } from "./table"
|
||||
|
||||
export default function BlitzStats({ stats }: { stats: NonNullStats["Blitz"] }) {
|
||||
if (!stats) return null
|
||||
@@ -47,6 +47,7 @@ export default function BlitzStats({ stats }: { stats: NonNullStats["Blitz"] })
|
||||
<Separator className="my-4" />
|
||||
<BlitzModeStatsTable stats={stats} />
|
||||
<Separator className="my-4" />
|
||||
<BlitzKitStatsTable stats={stats} />
|
||||
</GeneralStats>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
||||
import { formatNumber } from "@/lib/formatters"
|
||||
import { formatNumber, formatSecondsToTime } from "@/lib/formatters"
|
||||
import { getAllBlitzKitStats, getBlitzKitLevel, getBlitzKitName, getBlitzMostPlayedKit } from "@/lib/hypixel/blitz/general"
|
||||
import { romanize } from "@/lib/hypixel/general"
|
||||
import { NonNullStats } from "@/lib/schema/player"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
export function BlitzModeStatsTable({ stats }: { stats: NonNullable<NonNullStats["Blitz"]> }) {
|
||||
return (
|
||||
@@ -27,3 +30,55 @@ export function BlitzModeStatsTable({ stats }: { stats: NonNullable<NonNullStats
|
||||
</Table>
|
||||
)
|
||||
}
|
||||
|
||||
export function BlitzKitStatsTableHeader() {
|
||||
const headerElements = [
|
||||
"Kit",
|
||||
"Exp",
|
||||
"Prestige",
|
||||
"Kills",
|
||||
"Wins",
|
||||
"Losses",
|
||||
"WL",
|
||||
"Time Played"
|
||||
]
|
||||
|
||||
return (
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
{headerElements.map((v, i) => <TableHead key={i} className="font-bold">{v}</TableHead>)}
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
)
|
||||
}
|
||||
|
||||
export function BlitzKitStatsTable({ stats }: { stats: NonNullable<NonNullStats["Blitz"]> }) {
|
||||
const kitStats = getAllBlitzKitStats(stats)
|
||||
return (
|
||||
<Table>
|
||||
<BlitzKitStatsTableHeader />
|
||||
<TableBody>
|
||||
{kitStats.map((r, i) => {
|
||||
const { id, nums } = r
|
||||
const kitName = getBlitzKitName(id)
|
||||
const kitLevel = getBlitzKitLevel(id, stats)
|
||||
const mostPlayed = getBlitzMostPlayedKit(stats)?.id
|
||||
return (
|
||||
<TableRow className={cn(mostPlayed === id && "text-mc-light-purple font-bold")} key={i}>
|
||||
<TableCell className={cn(kitLevel === 10 && "text-mc-dark-red")}>{`${kitName} ${romanize(kitLevel)}`}</TableCell>
|
||||
{nums.map((v, j) => {
|
||||
if (j === nums.length - 1) {
|
||||
return <TableCell key={j}>{formatSecondsToTime(v)}</TableCell>
|
||||
}
|
||||
if (j === 1) {
|
||||
return <TableCell key={j}>{v === 0 ? "-" : romanize(v)}</TableCell>
|
||||
}
|
||||
return <TableCell key={j}>{formatNumber(v)}</TableCell>
|
||||
})}
|
||||
</TableRow>
|
||||
)
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user