Added wool games table
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
import { Table, TableBody, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
||||
import { formatNumber } from "@/lib/formatters"
|
||||
import { getWoolGamesWoolWarsClass, getWoolGamesWoolWarsClassColor, getWoolGamesWoolWarsClassStats } from "@/lib/hypixel/woolgames/general"
|
||||
import { NonNullStats } from "@/lib/schema/player"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
export default function WoolGamesStatTable({ stats }: { stats: NonNullable<NonNullStats["WoolGames"]> }) {
|
||||
export default function WoolGamesWoolWarsStatTable({ stats }: { stats: NonNullable<NonNullStats["WoolGames"]>["wool_wars"] }) {
|
||||
return (
|
||||
<Table>
|
||||
<WoolGamesTableHeader />
|
||||
<TableBody>
|
||||
<StatRow classId="tank" stats={stats} />
|
||||
<StatRow classId="archer" stats={stats} />
|
||||
<StatRow classId="swordsman" stats={stats} />
|
||||
<StatRow classId="engineer" stats={stats} />
|
||||
<StatRow classId="golem" stats={stats} />
|
||||
<StatRow classId="assault" stats={stats} />
|
||||
</TableBody>
|
||||
</Table>
|
||||
)
|
||||
@@ -33,3 +42,23 @@ function WoolGamesTableHeader() {
|
||||
</TableHeader>
|
||||
)
|
||||
}
|
||||
|
||||
function StatRow(
|
||||
{ classId, stats }: {
|
||||
classId: Parameters<typeof getWoolGamesWoolWarsClassStats>[0]
|
||||
stats: NonNullable<NonNullStats["WoolGames"]>["wool_wars"]
|
||||
}
|
||||
) {
|
||||
const classStats = getWoolGamesWoolWarsClassStats(classId, stats)
|
||||
const klass = getWoolGamesWoolWarsClass(classId)
|
||||
const classColor = getWoolGamesWoolWarsClassColor(klass?.difficulty)
|
||||
|
||||
return (
|
||||
<TableRow>
|
||||
<TableCell className={cn(classColor && `text-mc-${classColor}`)}>{klass !== null ? klass.name : "Unknown"}</TableCell>
|
||||
{classStats.map((v, i) => {
|
||||
return <TableCell key={i}>{formatNumber(v)}</TableCell>
|
||||
})}
|
||||
</TableRow>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import GeneralStats from "../GeneralStats"
|
||||
import { WoolGamesCaptureTheWool, WoolGamesSheepWars, WoolGamesWoolWars } from "./modes"
|
||||
import WoolGamesProgress from "./progress"
|
||||
import WoolGamesGeneralStats from "./stats"
|
||||
import WoolGamesStatTable from "./table"
|
||||
import WoolGamesWoolWarsStatTable from "./table"
|
||||
|
||||
export default function WoolGamesStats({ stats }: { stats: NonNullStats["WoolGames"] }) {
|
||||
if (!stats) return null
|
||||
@@ -47,7 +47,7 @@ export default function WoolGamesStats({ stats }: { stats: NonNullStats["WoolGam
|
||||
<WoolGamesSheepWars sw={stats.sheep_wars} />
|
||||
<Separator className="my-4" />
|
||||
<WoolGamesWoolWars ww={stats.wool_wars} />
|
||||
<WoolGamesStatTable stats={stats} />
|
||||
<WoolGamesWoolWarsStatTable stats={stats.wool_wars} />
|
||||
<Separator className="my-4" />
|
||||
</GeneralStats>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user