Added tnt games stats
This commit is contained in:
39
src/app/(stats)/player/[ign]/_stats/tnt-games/stats.tsx
Normal file
39
src/app/(stats)/player/[ign]/_stats/tnt-games/stats.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
import { formatNumber, formatSecondsToTime } from "@/lib/formatters"
|
||||
import { devide } from "@/lib/hypixel/general"
|
||||
import { NonNullStats } from "@/lib/schema/player"
|
||||
import { BasicStat } from "../../_components/Stats"
|
||||
|
||||
export default function TNTGamesGeneralStats({ stats }: { stats: NonNullable<NonNullStats["TNTGames"]> }) {
|
||||
return (
|
||||
<div className="flex flex-col gap-6">
|
||||
<div>
|
||||
<BasicStat title="Token: " value={formatNumber(stats.coins)} className="text-mc-dark-green" />
|
||||
<BasicStat title="Wins: " value={formatNumber(stats.wins)} />
|
||||
</div>
|
||||
<div className="grid grid-cols-2 grid-rows-2">
|
||||
<div>
|
||||
<h2 className="text-xl font-bold">TNT Tag</h2>
|
||||
<BasicStat title="Kills: " value={formatNumber(stats.kills_tntag)} />
|
||||
<BasicStat title="Wins: " value={formatNumber(stats.wins_tntag)} />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-xl font-bold">TNT Run</h2>
|
||||
<BasicStat title="Wins: " value={formatNumber(stats.wins_tntrun)} />
|
||||
<BasicStat title="Record Time: " value={formatSecondsToTime(stats.record_tntrun)} />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-xl font-bold">PvP Run</h2>
|
||||
<BasicStat title="Kills: " value={formatNumber(stats.kills_pvprun)} />
|
||||
<BasicStat title="Wins: " value={formatNumber(stats.wins_pvprun)} />
|
||||
<BasicStat title="Record Time: " value={formatSecondsToTime(stats.record_pvprun)} />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-xl font-bold">Bow Spleef</h2>
|
||||
<BasicStat title="Wins: " value={formatNumber(stats.wins_bowspleef)} />
|
||||
<BasicStat title="Losses: " value={formatNumber(stats.deaths_bowspleef)} />
|
||||
<BasicStat title="Win/Loss Ratio: " value={formatNumber(devide(stats.wins_bowspleef, stats.deaths_bowspleef))} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
37
src/app/(stats)/player/[ign]/_stats/tnt-games/tnt-games.tsx
Normal file
37
src/app/(stats)/player/[ign]/_stats/tnt-games/tnt-games.tsx
Normal file
@@ -0,0 +1,37 @@
|
||||
import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion"
|
||||
import { Card, CardContent } from "@/components/ui/card"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import { NonNullStats } from "@/lib/schema/player"
|
||||
import CollapsedStats from "../../_components/CollapsedStats"
|
||||
import TNTGamesGeneralStats from "./stats"
|
||||
import TNTWizardsStats from "./wizards"
|
||||
|
||||
export default function TNTGamesStats({ stats }: { stats: NonNullStats["TNTGames"] }) {
|
||||
if (!stats) return null
|
||||
|
||||
return (
|
||||
<AccordionItem value="tnt-games">
|
||||
<Card className="py-0">
|
||||
<CardContent>
|
||||
<AccordionTrigger className="items-center py-2 hover:no-underline hover:cursor-pointer">
|
||||
<h1 className="text-xl font-bold">TNT Games</h1>
|
||||
<div className="flex gap-4">
|
||||
<CollapsedStats
|
||||
stats={[{
|
||||
title: <p>Wins</p>,
|
||||
stat: <p className="text-muted-foreground">{stats.wins}</p>
|
||||
}]}
|
||||
/>
|
||||
</div>
|
||||
</AccordionTrigger>
|
||||
<AccordionContent>
|
||||
<Separator className="my-4" />
|
||||
<TNTGamesGeneralStats stats={stats} />
|
||||
<Separator className="my-4" />
|
||||
<TNTWizardsStats stats={stats} />
|
||||
</AccordionContent>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</AccordionItem>
|
||||
)
|
||||
}
|
||||
102
src/app/(stats)/player/[ign]/_stats/tnt-games/wizards.tsx
Normal file
102
src/app/(stats)/player/[ign]/_stats/tnt-games/wizards.tsx
Normal file
@@ -0,0 +1,102 @@
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
||||
import { formatNumber } from "@/lib/formatters"
|
||||
import { devide, romanize } from "@/lib/hypixel/general"
|
||||
import { getTNTGameMode, getTNTModeStats } from "@/lib/hypixel/tnt-games/general"
|
||||
import { NonNullStats } from "@/lib/schema/player"
|
||||
import { GenericProgressNoTooltip } from "../../_components/GenericProgress"
|
||||
import { BasicStat } from "../../_components/Stats"
|
||||
|
||||
export default function TNTWizardsStats({ stats }: { stats: NonNullable<NonNullStats["TNTGames"]> }) {
|
||||
return (
|
||||
<div className="space-y-4">
|
||||
<h2 className="text-xl font-bold">TNT Wizards</h2>
|
||||
<div>
|
||||
<BasicStat title="Wins: " value={formatNumber(stats.wins_capture)} />
|
||||
<BasicStat title="Kills: " value={formatNumber(stats.kills_capture)} />
|
||||
<BasicStat title="Deaths: " value={formatNumber(stats.deaths_capture)} />
|
||||
<BasicStat title="Kill/Death Ratio: " value={formatNumber(devide(stats.kills_capture, stats.deaths_capture))} />
|
||||
</div>
|
||||
<Table>
|
||||
<TNTWizardsTableHeader />
|
||||
<TableBody>
|
||||
<TableStats id="ancient" stats={stats} />
|
||||
<TableStats id="blood" stats={stats} />
|
||||
<TableStats id="fire" stats={stats} />
|
||||
<TableStats id="hydro" stats={stats} />
|
||||
<TableStats id="ice" stats={stats} />
|
||||
<TableStats id="kinetic" stats={stats} />
|
||||
<TableStats id="storm" stats={stats} />
|
||||
<TableStats id="toxic" stats={stats} />
|
||||
<TableStats id="wither" stats={stats} />
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function TableStats({ id, stats }: { id: Parameters<typeof getTNTGameMode>[0], stats: NonNullable<NonNullStats["TNTGames"]> }) {
|
||||
const gm = getTNTGameMode(id)
|
||||
const modeStats = getTNTModeStats(id, stats)
|
||||
return (
|
||||
<TableRow>
|
||||
<TableCell className={`text-mc-${gm.color}`}>{gm.name}</TableCell>
|
||||
{modeStats.map((m, i) => {
|
||||
if (i === modeStats.length - 2) {
|
||||
if (m === 0) {
|
||||
return <TableCell key={i}>?</TableCell>
|
||||
}
|
||||
return (
|
||||
<TableCell key={i}>
|
||||
{
|
||||
<GenericProgressNoTooltip
|
||||
text={romanize(m)}
|
||||
percent={m / 7 * 100}
|
||||
className={`bg-mc-${gm.color}`}
|
||||
/>
|
||||
}
|
||||
</TableCell>
|
||||
)
|
||||
}
|
||||
if (i === modeStats.length - 1) {
|
||||
if (m === 0) {
|
||||
return <TableCell key={i}>?</TableCell>
|
||||
}
|
||||
return (
|
||||
<TableCell key={i}>
|
||||
{
|
||||
<GenericProgressNoTooltip
|
||||
text={romanize(m)}
|
||||
percent={m / 7 * 100}
|
||||
className={`bg-mc-${gm.color}`}
|
||||
/>
|
||||
}
|
||||
</TableCell>
|
||||
)
|
||||
}
|
||||
return <TableCell key={i}>{formatNumber(m)}</TableCell>
|
||||
})}
|
||||
</TableRow>
|
||||
)
|
||||
}
|
||||
|
||||
function TNTWizardsTableHeader() {
|
||||
const headerElements = [
|
||||
"Wizard",
|
||||
"Kills",
|
||||
"Deaths",
|
||||
"Assists",
|
||||
"KD",
|
||||
"Power",
|
||||
"Regen"
|
||||
]
|
||||
|
||||
return (
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
{headerElements.map((v, i) => {
|
||||
return <TableHead key={i} className="font-bold">{v}</TableHead>
|
||||
})}
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user