Added warlords mode stats
This commit is contained in:
40
src/app/(stats)/player/[ign]/_stats/warlords/table.tsx
Normal file
40
src/app/(stats)/player/[ign]/_stats/warlords/table.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
||||
import { formatNumber } from "@/lib/formatters"
|
||||
import { getWarlordsModeName, getWarlordsModeStats, getWarlordsMostPlayedMode } from "@/lib/hypixel/warlords/general"
|
||||
import { NonNullStats } from "@/lib/schema/player"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
export function WarlordsModeStatsTable({ stats }: { stats: NonNullable<NonNullStats["Warlords"]> }) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>Mode</TableHead>
|
||||
<TableHead>Wins</TableHead>
|
||||
<TableHead>Kills</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
<WarlordsModeStatsTableStat modeId="capturetheflag" stats={stats} />
|
||||
<WarlordsModeStatsTableStat modeId="domination" stats={stats} />
|
||||
<WarlordsModeStatsTableStat modeId="teamdeathmatch" stats={stats} />
|
||||
</TableBody>
|
||||
</Table>
|
||||
)
|
||||
}
|
||||
|
||||
function WarlordsModeStatsTableStat(
|
||||
{ modeId, stats }: { modeId: Parameters<typeof getWarlordsModeStats>[0], stats: NonNullable<NonNullStats["Warlords"]> }
|
||||
) {
|
||||
const modeStats = getWarlordsModeStats(modeId, stats)
|
||||
const name = getWarlordsModeName(modeId)
|
||||
const mostPlayed = getWarlordsMostPlayedMode(stats)?.id === modeId
|
||||
|
||||
return (
|
||||
<TableRow className={cn(mostPlayed && "text-mc-light-purple")}>
|
||||
<TableCell>{name}</TableCell>
|
||||
<TableCell>{formatNumber(modeStats.wins)}</TableCell>
|
||||
<TableCell>{formatNumber(modeStats.kills)}</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { NonNullStats } from "@/lib/schema/player"
|
||||
import GeneralStats from "../GeneralStats"
|
||||
import { WarlordsWeaponsBar } from "./client"
|
||||
import WarlordsGeneralStats from "./stats"
|
||||
import { WarlordsModeStatsTable } from "./table"
|
||||
|
||||
export default function WarlordsStats({ stats }: { stats: NonNullStats["Warlords"] }) {
|
||||
if (!stats) return null
|
||||
@@ -43,6 +44,8 @@ export default function WarlordsStats({ stats }: { stats: NonNullStats["Warlords
|
||||
<Separator className="my-4" />
|
||||
<WarlordsWeaponsBar stats={stats} />
|
||||
<Separator className="my-4" />
|
||||
<WarlordsModeStatsTable stats={stats} />
|
||||
<Separator className="my-4" />
|
||||
</GeneralStats>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user