Updated table stats

This commit is contained in:
2025-08-21 22:44:46 +02:00
parent b31ef97789
commit b222fb1f60
3 changed files with 337 additions and 50 deletions

View File

@@ -1,4 +1,5 @@
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { formatNumber } from "@/lib/formatters"
import { _BedwarsStats, getBedwarsModeStats } from "@/lib/hypixel/bedwars"
import { Player } from "@/lib/schema/player"
@@ -11,6 +12,21 @@ export default function BedwarsStatTable({ stats }: { stats: Player["player"]["s
<DoublesStats stats={stats} />
<ThreesStats stats={stats} />
<FoursStats stats={stats} />
<CoreModeStats stats={stats} />
<FourVFourStats stats={stats} />
<RushDoublesStats stats={stats} />
<Rush4sStats stats={stats} />
<UltimateDoublesStats stats={stats} />
<Ultimate4sStats stats={stats} />
<LuckyDoublesStats stats={stats} />
<Lucky4sStats stats={stats} />
<VoidlessDoublesStats stats={stats} />
<Voidless4sStats stats={stats} />
<ArmedDoublesStats stats={stats} />
<Armed4sStats stats={stats} />
<Swap4sStats stats={stats} />
<Underworld4sStats stats={stats} />
<CastleStats stats={stats} />
</TableBody>
</Table>
)
@@ -38,12 +54,12 @@ function BedwarsTableHeader() {
<TableHeader>
<TableRow>
<TableHead></TableHead>
<TableHead colSpan={3}>Normal</TableHead>
<TableHead colSpan={3}>Finals</TableHead>
<TableHead colSpan={3} className="font-bold">Normal</TableHead>
<TableHead colSpan={3} className="font-bold">Finals</TableHead>
</TableRow>
<TableRow>
{headerElements.map((v, i) => {
return <TableHead key={i}>{v}</TableHead>
return <TableHead key={i} className="font-bold">{v}</TableHead>
})}
</TableRow>
</TableHeader>
@@ -59,7 +75,7 @@ function SoloStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
<TableRow>
<TableCell>Solo</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{v}</TableCell>
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
@@ -74,7 +90,7 @@ function DoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }
<TableRow>
<TableCell>Doubles</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{v}</TableCell>
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
@@ -89,7 +105,7 @@ function ThreesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] })
<TableRow>
<TableCell>3v3v3v3</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{v}</TableCell>
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
@@ -104,7 +120,245 @@ function FoursStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] })
<TableRow>
<TableCell>4v4v4v4</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{v}</TableCell>
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function CoreModeStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const soloStats = getBedwarsModeStats("solo", stats as _BedwarsStats, true)
const doublesStats = getBedwarsModeStats("doubles", stats as _BedwarsStats, true)
const threesStats = getBedwarsModeStats("3s", stats as _BedwarsStats, true)
const foursStats = getBedwarsModeStats("4s", stats as _BedwarsStats, true)
const fraction = [2, 5, 8]
const combinedStats = soloStats.map((v, i) => {
if (v < 0) return "?"
if (fraction.includes(i) || i === soloStats.length - 1) {
return ((v + doublesStats[i] + threesStats[i] + foursStats[i]) / 4).toFixed(2)
}
return v + doublesStats[i] + threesStats[i] + foursStats[i]
})
return (
<TableRow className="font-bold">
<TableCell>Core Modes</TableCell>
{combinedStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function FourVFourStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("4v4", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>4v4</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function RushDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("rush_2s", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Rush Doubles</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function Rush4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("rush_4s", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Rush 4v4v4v4</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function UltimateDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("ultimate_2s", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Ultimate Doubles</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function Ultimate4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("ultimate_4s", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Ultimate 4v4v4v4</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function LuckyDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("lucky_2s", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Lucky Doubles</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function Lucky4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("lucky_4s", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Lucky 4v4v4v4</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function VoidlessDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("voidless_2s", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Voidless Doubles</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function Voidless4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("voidless_4s", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Voidless 4v4v4v4</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function ArmedDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("armed_2s", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Armed Doubles</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function Armed4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("armed_4s", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Armed 4v4v4v4</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function Swap4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("swap_4s", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Swap 4v4v4v4</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function Underworld4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("underworld_4s", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Underworld 4v4v4v4</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)
}
function CastleStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) {
const modeStats = getBedwarsModeStats("castle", stats as _BedwarsStats)
if (!modeStats) return null
return (
<TableRow>
<TableCell>Castle</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{typeof v === "number" ? formatNumber(v) : v}</TableCell>
})}
</TableRow>
)