diff --git a/src/app/(main)/page.tsx b/src/app/(main)/page.tsx index ac0e99e..8aec473 100644 --- a/src/app/(main)/page.tsx +++ b/src/app/(main)/page.tsx @@ -2,7 +2,7 @@ import { SearchBar } from "@/components/search-bar" export default function Home() { return ( -
+

Stats Hypixel

diff --git a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-table.tsx b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-table.tsx index 19e9653..d18c769 100644 --- a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-table.tsx +++ b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-table.tsx @@ -1,8 +1,9 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { formatNumber } from "@/lib/formatters" import { concatStatArrays } from "@/lib/funcs" -import { _BedwarsStats, getBedwarsModeStats } from "@/lib/hypixel/bedwars" +import { _BedwarsStats, getBedwarsModeStats, getBestMode } from "@/lib/hypixel/bedwars" import { Player } from "@/lib/schema/player" +import { cn } from "@/lib/utils" export default function BedwarsStatTable({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { return ( @@ -70,10 +71,10 @@ function BedwarsTableHeader() { function SoloStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("solo", stats as _BedwarsStats) - + const isBest = getBestMode(stats as _BedwarsStats) === "solo" return ( - + Solo {modeStats.map((v, i) => { return {typeof v === "number" ? formatNumber(v) : v} @@ -84,10 +85,10 @@ function SoloStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { function DoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("doubles", stats as _BedwarsStats) - + const isBest = getBestMode(stats as _BedwarsStats) === "doubles" return ( - + Doubles {modeStats.map((v, i) => { return {typeof v === "number" ? formatNumber(v) : v} @@ -98,10 +99,10 @@ function DoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] } function ThreesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("3s", stats as _BedwarsStats) - + const isBest = getBestMode(stats as _BedwarsStats) === "3s" return ( - + 3v3v3v3 {modeStats.map((v, i) => { return {typeof v === "number" ? formatNumber(v) : v} @@ -112,10 +113,10 @@ function ThreesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) function FoursStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("4s", stats as _BedwarsStats) - + const isBest = getBestMode(stats as _BedwarsStats) === "4s" return ( - + 4v4v4v4 {modeStats.map((v, i) => { return {typeof v === "number" ? formatNumber(v) : v} @@ -145,7 +146,6 @@ function CoreModeStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] function FourVFourStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("4v4", stats as _BedwarsStats) - return ( 4v4 @@ -159,7 +159,6 @@ function FourVFourStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] function RushDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("rush_2s", stats as _BedwarsStats) - return ( Rush Doubles @@ -173,7 +172,6 @@ function RushDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars function Rush4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("rush_4s", stats as _BedwarsStats) - return ( Rush 4v4v4v4 @@ -187,7 +185,6 @@ function Rush4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) function UltimateDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("ultimate_2s", stats as _BedwarsStats) - return ( Ultimate Doubles @@ -201,7 +198,6 @@ function UltimateDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bed function Ultimate4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("ultimate_4s", stats as _BedwarsStats) - return ( Ultimate 4v4v4v4 @@ -215,7 +211,6 @@ function Ultimate4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars" function LuckyDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("lucky_2s", stats as _BedwarsStats) - return ( Lucky Doubles @@ -229,7 +224,6 @@ function LuckyDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwar function Lucky4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("lucky_4s", stats as _BedwarsStats) - return ( Lucky 4v4v4v4 @@ -243,7 +237,6 @@ function Lucky4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] } function VoidlessDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("voidless_2s", stats as _BedwarsStats) - return ( Voidless Doubles @@ -257,7 +250,6 @@ function VoidlessDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bed function Voidless4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("voidless_4s", stats as _BedwarsStats) - return ( Voidless 4v4v4v4 @@ -271,7 +263,6 @@ function Voidless4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars" function ArmedDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("armed_2s", stats as _BedwarsStats) - return ( Armed Doubles @@ -285,7 +276,6 @@ function ArmedDoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwar function Armed4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("armed_4s", stats as _BedwarsStats) - return ( Armed 4v4v4v4 @@ -299,7 +289,6 @@ function Armed4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] } function Swap4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("swap_4s", stats as _BedwarsStats) - return ( Swap 4v4v4v4 @@ -313,7 +302,6 @@ function Swap4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) function Underworld4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("underworld_4s", stats as _BedwarsStats) - return ( Underworld 4v4v4v4 @@ -327,7 +315,6 @@ function Underworld4sStats({ stats }: { stats: Player["player"]["stats"]["Bedwar function CastleStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { const modeStats = getBedwarsModeStats("castle", stats as _BedwarsStats) - return ( Castle diff --git a/src/app/(stats)/player/[ign]/page.tsx b/src/app/(stats)/player/[ign]/page.tsx index 264f444..7bab0ff 100644 --- a/src/app/(stats)/player/[ign]/page.tsx +++ b/src/app/(stats)/player/[ign]/page.tsx @@ -72,7 +72,7 @@ async function SuspendedPage({ ign: pign }: { ign: string }) {
-
+
diff --git a/src/lib/hypixel/bedwars.ts b/src/lib/hypixel/bedwars.ts index 69defd2..ac5a4f4 100644 --- a/src/lib/hypixel/bedwars.ts +++ b/src/lib/hypixel/bedwars.ts @@ -94,6 +94,28 @@ export type BedwarsModeStats = { beds_lost_bedwars: number } +export function getBestMode(stats: _BedwarsStats): "solo" | "doubles" | "3s" | "4s" | null { + const { wins_bedwars: solo } = getBedwarsModeStats("solo", stats, true) + const { wins_bedwars: doubles } = getBedwarsModeStats("doubles", stats, true) + const { wins_bedwars: threes } = getBedwarsModeStats("3s", stats, true) + const { wins_bedwars: fours } = getBedwarsModeStats("4s", stats, true) + + const max = Math.max(solo, doubles, threes, fours) + + switch (max) { + case solo: + return "solo" + case doubles: + return "doubles" + case threes: + return "3s" + case fours: + return "4s" + default: + return null + } +} + export function getBedwarsModeStats(mode: Mode, stats: _BedwarsStats, raw: true): BedwarsModeStats export function getBedwarsModeStats(mode: Mode, stats: _BedwarsStats, raw?: false): (string | number)[] export function getBedwarsModeStats(mode: Mode, stats: _BedwarsStats, raw = false) {