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 { 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 (
|
return (
|
||||||
<Table>
|
<Table>
|
||||||
<WoolGamesTableHeader />
|
<WoolGamesTableHeader />
|
||||||
<TableBody>
|
<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>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
)
|
)
|
||||||
@@ -33,3 +42,23 @@ function WoolGamesTableHeader() {
|
|||||||
</TableHeader>
|
</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 { WoolGamesCaptureTheWool, WoolGamesSheepWars, WoolGamesWoolWars } from "./modes"
|
||||||
import WoolGamesProgress from "./progress"
|
import WoolGamesProgress from "./progress"
|
||||||
import WoolGamesGeneralStats from "./stats"
|
import WoolGamesGeneralStats from "./stats"
|
||||||
import WoolGamesStatTable from "./table"
|
import WoolGamesWoolWarsStatTable from "./table"
|
||||||
|
|
||||||
export default function WoolGamesStats({ stats }: { stats: NonNullStats["WoolGames"] }) {
|
export default function WoolGamesStats({ stats }: { stats: NonNullStats["WoolGames"] }) {
|
||||||
if (!stats) return null
|
if (!stats) return null
|
||||||
@@ -47,7 +47,7 @@ export default function WoolGamesStats({ stats }: { stats: NonNullStats["WoolGam
|
|||||||
<WoolGamesSheepWars sw={stats.sheep_wars} />
|
<WoolGamesSheepWars sw={stats.sheep_wars} />
|
||||||
<Separator className="my-4" />
|
<Separator className="my-4" />
|
||||||
<WoolGamesWoolWars ww={stats.wool_wars} />
|
<WoolGamesWoolWars ww={stats.wool_wars} />
|
||||||
<WoolGamesStatTable stats={stats} />
|
<WoolGamesWoolWarsStatTable stats={stats.wool_wars} />
|
||||||
<Separator className="my-4" />
|
<Separator className="my-4" />
|
||||||
</GeneralStats>
|
</GeneralStats>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,29 @@
|
|||||||
import { CLASSES, DIFFICULTIES, EASY_XP, ICONS, NORMAL_XP, PRESTIGES } from "@/data/hypixel/woolgames"
|
import { CLASSES, DIFFICULTIES, EASY_XP, ICONS, NORMAL_XP, PRESTIGES } from "@/data/hypixel/woolgames"
|
||||||
import { getColorFromCode } from "@/lib/colors"
|
import { getColorFromCode } from "@/lib/colors"
|
||||||
import { floorLevel } from "../general"
|
import { NonNullStats } from "@/lib/schema/player"
|
||||||
|
import { devide, floorLevel } from "../general"
|
||||||
|
|
||||||
|
export function getWoolGamesWoolWarsClassStats(
|
||||||
|
classId: typeof CLASSES[number]["id"],
|
||||||
|
stats: NonNullable<NonNullStats["WoolGames"]>["wool_wars"]
|
||||||
|
) {
|
||||||
|
const nums: number[] = []
|
||||||
|
for (let i = 0; i++; i < 7) {
|
||||||
|
nums.push(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stats) return nums
|
||||||
|
|
||||||
|
return [
|
||||||
|
stats.stats?.classes[classId]?.kills || 0,
|
||||||
|
stats.stats?.classes[classId]?.assists || 0,
|
||||||
|
stats.stats?.classes[classId]?.deaths || 0,
|
||||||
|
devide(stats.stats?.classes[classId]?.kills || 0, stats.stats?.classes[classId]?.deaths || 0),
|
||||||
|
stats.stats?.classes[classId]?.wool_placed || 0,
|
||||||
|
stats.stats?.classes[classId]?.blocks_broken || 0,
|
||||||
|
stats.stats?.classes[classId]?.powerups_gotten || 0
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
export function getWoolGamesWoolWarsClass(val?: string) {
|
export function getWoolGamesWoolWarsClass(val?: string) {
|
||||||
const klass = CLASSES.find(c => c.id === val?.toLowerCase())
|
const klass = CLASSES.find(c => c.id === val?.toLowerCase())
|
||||||
|
|||||||
@@ -785,7 +785,7 @@ export const woolGamesStatsSchema = z.object({
|
|||||||
engineer: woolGamesClassStats.optional(),
|
engineer: woolGamesClassStats.optional(),
|
||||||
golem: woolGamesClassStats.optional(),
|
golem: woolGamesClassStats.optional(),
|
||||||
assault: woolGamesClassStats.optional()
|
assault: woolGamesClassStats.optional()
|
||||||
}).optional()
|
}).default({})
|
||||||
}).optional()
|
}).optional()
|
||||||
}).optional()
|
}).optional()
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user