diff --git a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-table.tsx b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-table.tsx new file mode 100644 index 0000000..8095b13 --- /dev/null +++ b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars-table.tsx @@ -0,0 +1,111 @@ +import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" +import { _BedwarsStats, getBedwarsModeStats } from "@/lib/hypixel/bedwars" +import { Player } from "@/lib/schema/player" + +export default function BedwarsStatTable({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { + return ( + + + + + + + + +
+ ) +} + +function BedwarsTableHeader() { + const headerElements = [ + "Mode", + "Kills", + "Deaths", + "KD", + "Kills", + "Deaths", + "KD", + "Wins", + "Losses", + "WL", + "WS", + "BB", + "BL", + "BBL" + ] + + return ( + + + + Normal + Finals + + + {headerElements.map((v, i) => { + return {v} + })} + + + ) +} + +function SoloStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { + const modeStats = getBedwarsModeStats("solo", stats as _BedwarsStats) + + if (!modeStats) return null + + return ( + + Solo + {modeStats.map((v, i) => { + return {v} + })} + + ) +} + +function DoublesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { + const modeStats = getBedwarsModeStats("doubles", stats as _BedwarsStats) + + if (!modeStats) return null + + return ( + + Doubles + {modeStats.map((v, i) => { + return {v} + })} + + ) +} + +function ThreesStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { + const modeStats = getBedwarsModeStats("3s", stats as _BedwarsStats) + + if (!modeStats) return null + + return ( + + 3v3v3v3 + {modeStats.map((v, i) => { + return {v} + })} + + ) +} + +function FoursStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { + const modeStats = getBedwarsModeStats("4s", stats as _BedwarsStats) + + if (!modeStats) return null + + return ( + + 4v4v4v4 + {modeStats.map((v, i) => { + return {v} + })} + + ) +} diff --git a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx index 72261f2..22ad207 100644 --- a/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx +++ b/src/app/(stats)/player/[ign]/_stats/bedwars/bedwars.tsx @@ -10,6 +10,7 @@ import { ChevronDown, ChevronUp, Menu } from "lucide-react" import { useEffect, useRef, useState } from "react" import CollapsedStats from "../../_components/CollapsedStats" import { BedwarsLevel, BedwarsProgress } from "./bedwars-components" +import BedwarsStatTable from "./bedwars-table" import BedwarsGeneralStats from "./stats" export default function BedwarsStats({ stats }: { stats: Player["player"]["stats"]["Bedwars"] }) { @@ -97,6 +98,8 @@ export default function BedwarsStats({ stats }: { stats: Player["player"]["stats + + diff --git a/src/app/(stats)/player/[ign]/_stats/bedwars/stats.tsx b/src/app/(stats)/player/[ign]/_stats/bedwars/stats.tsx index 9047ed8..3c3ae9e 100644 --- a/src/app/(stats)/player/[ign]/_stats/bedwars/stats.tsx +++ b/src/app/(stats)/player/[ign]/_stats/bedwars/stats.tsx @@ -18,7 +18,7 @@ export default function BedwarsGeneralStats( const stats = statsChecked! return ( -
+
diff --git a/src/components/ui/table.tsx b/src/components/ui/table.tsx new file mode 100644 index 0000000..51b74dd --- /dev/null +++ b/src/components/ui/table.tsx @@ -0,0 +1,116 @@ +"use client" + +import * as React from "react" + +import { cn } from "@/lib/utils" + +function Table({ className, ...props }: React.ComponentProps<"table">) { + return ( +
+ + + ) +} + +function TableHeader({ className, ...props }: React.ComponentProps<"thead">) { + return ( + + ) +} + +function TableBody({ className, ...props }: React.ComponentProps<"tbody">) { + return ( + + ) +} + +function TableFooter({ className, ...props }: React.ComponentProps<"tfoot">) { + return ( + tr]:last:border-b-0", + className + )} + {...props} + /> + ) +} + +function TableRow({ className, ...props }: React.ComponentProps<"tr">) { + return ( + + ) +} + +function TableHead({ className, ...props }: React.ComponentProps<"th">) { + return ( +
[role=checkbox]]:translate-y-[2px]", + className + )} + {...props} + /> + ) +} + +function TableCell({ className, ...props }: React.ComponentProps<"td">) { + return ( + [role=checkbox]]:translate-y-[2px]", + className + )} + {...props} + /> + ) +} + +function TableCaption({ + className, + ...props +}: React.ComponentProps<"caption">) { + return ( +
+ ) +} + +export { + Table, + TableHeader, + TableBody, + TableFooter, + TableHead, + TableRow, + TableCell, + TableCaption, +} diff --git a/src/lib/hypixel/api/player.ts b/src/lib/hypixel/api/player.ts index 36b5abf..590c9b3 100644 --- a/src/lib/hypixel/api/player.ts +++ b/src/lib/hypixel/api/player.ts @@ -18,4 +18,3 @@ export async function getPlayer(uuid: string) { return data.player } - diff --git a/src/lib/hypixel/bedwars.ts b/src/lib/hypixel/bedwars.ts index 5adda71..8e31242 100644 --- a/src/lib/hypixel/bedwars.ts +++ b/src/lib/hypixel/bedwars.ts @@ -60,3 +60,36 @@ export function getLatestRoom(rooms?: Record) { return latestRoom } + +export type _BedwarsStats = Record & { [key: `${string}_winstreak`]: number | undefined } + +export function getBedwarsModeStats(mode: "solo" | "doubles" | "3s" | "4s", stats: _BedwarsStats) { + switch (mode) { + case "solo": + return bedwarsModeStats("eight_one", stats) + case "doubles": + return bedwarsModeStats("eight_two", stats) + case "3s": + return bedwarsModeStats("four_three", stats) + case "4s": + return bedwarsModeStats("four_four", stats) + } +} + +function bedwarsModeStats(prefix: string, stats: _BedwarsStats) { + return [ + stats[`${prefix}_kills_bedwars`], + stats[`${prefix}_deaths_bedwars`], + (stats[`${prefix}_kills_bedwars`] / stats[`${prefix}_deaths_bedwars`]).toFixed(2), + stats[`${prefix}_final_kills_bedwars`], + stats[`${prefix}_final_deaths_bedwars`], + (stats[`${prefix}_final_kills_bedwars`] / stats[`${prefix}_final_deaths_bedwars`]).toFixed(2), + stats[`${prefix}_wins_bedwars`], + stats[`${prefix}_losses_bedwars`], + (stats[`${prefix}_wins_bedwars`] / stats[`${prefix}_losses_bedwars`]).toFixed(2), + stats[`${prefix}_winstreak`] ?? "?", + stats[`${prefix}_beds_broken_bedwars`], + stats[`${prefix}_beds_lost_bedwars`], + (stats[`${prefix}_beds_broken_bedwars`] / stats[`${prefix}_beds_lost_bedwars`]).toFixed(2) + ] +} diff --git a/src/lib/hypixel/validatePlayer.ts b/src/lib/hypixel/validatePlayer.ts index 91b70cd..766cd3c 100644 --- a/src/lib/hypixel/validatePlayer.ts +++ b/src/lib/hypixel/validatePlayer.ts @@ -9,7 +9,7 @@ export async function validatePlayer(ign: string) { if (!uuid) { return { error: true, - message: "Player not found", + message: "Player not found" } } @@ -18,12 +18,13 @@ export async function validatePlayer(ign: string) { if (!player) { return { error: true, - message: "Player never logged on to Hypixel", + message: "Player never logged on to Hypixel" } } return { error: false, - message: "Player found", + message: "Player found" } -} \ No newline at end of file +} + diff --git a/src/lib/schema/player.ts b/src/lib/schema/player.ts index 02ad2c3..25fa969 100644 --- a/src/lib/schema/player.ts +++ b/src/lib/schema/player.ts @@ -36,7 +36,43 @@ export const playerSchema = z.looseObject({ total_tickets_earned: z.number(), doublers: z.number(), room: z.record(z.string(), z.boolean()) - }).optional() + }).optional(), + eight_one_winstreak: z.number().optional(), + eight_one_kills_bedwars: z.number().default(0), + eight_one_deaths_bedwars: z.number().default(0), + eight_one_final_kills_bedwars: z.number().default(0), + eight_one_final_deaths_bedwars: z.number().default(0), + eight_one_wins_bedwars: z.number().default(0), + eight_one_losses_bedwars: z.number().default(0), + eight_one_beds_broken_bedwars: z.number().default(0), + eight_one_beds_lost_bedwars: z.number().default(0), + eight_two_winstreak: z.number().optional(), + eight_two_kills_bedwars: z.number().default(0), + eight_two_deaths_bedwars: z.number().default(0), + eight_two_final_kills_bedwars: z.number().default(0), + eight_two_final_deaths_bedwars: z.number().default(0), + eight_two_wins_bedwars: z.number().default(0), + eight_two_losses_bedwars: z.number().default(0), + eight_two_beds_broken_bedwars: z.number().default(0), + eight_two_beds_lost_bedwars: z.number().default(0), + four_three_winstreak: z.number().optional(), + four_three_kills_bedwars: z.number().default(0), + four_three_deaths_bedwars: z.number().default(0), + four_three_final_kills_bedwars: z.number().default(0), + four_three_final_deaths_bedwars: z.number().default(0), + four_three_wins_bedwars: z.number().default(0), + four_three_losses_bedwars: z.number().default(0), + four_three_beds_broken_bedwars: z.number().default(0), + four_three_beds_lost_bedwars: z.number().default(0), + four_four_winstreak: z.number().optional(), + four_four_kills_bedwars: z.number().default(0), + four_four_deaths_bedwars: z.number().default(0), + four_four_final_kills_bedwars: z.number().default(0), + four_four_final_deaths_bedwars: z.number().default(0), + four_four_wins_bedwars: z.number().default(0), + four_four_losses_bedwars: z.number().default(0), + four_four_beds_broken_bedwars: z.number().default(0), + four_four_beds_lost_bedwars: z.number().default(0) }).optional() }), quests: z.record( diff --git a/đ b/đ deleted file mode 100644 index 2e497e3..0000000 --- a/đ +++ /dev/null @@ -1,50 +0,0 @@ -import { PRESTIGE_ICONS, PRESTIGES, SLUMBER_WALLETS } from "@/data/hypixel/bedwars" -import { floorLevel } from "./formatters" - -export function getBedwarsStar(level: number) { - if (level < 1100) { - return PRESTIGE_ICONS[0].symbol - } - - if (level > 1100 && level < 2100) { - return PRESTIGE_ICONS[1].symbol - } - - if (level > 2100 && level < 3100) { - return PRESTIGE_ICONS[2].symbol - } - - return PRESTIGE_ICONS[3].symbol -} - -export function getTextColor(level: number) { - const floored = floorLevel(level, 100) - - if (level > 5000) { - return PRESTIGES[PRESTIGES.length - 1].color - } - - return PRESTIGES.find(l => l.level === floored)!.color -} - -export function getPrestigeName(level: number) { - const floored = floorLevel(level, 100) - - if (level > 5000) { - return PRESTIGES[PRESTIGES.length - 1].name - } - - return PRESTIGES.find(p => p.level === floored)!.name -} - -export function getWalletMax(name?: string) { - if (!name) return 25 - - const wallets = SLUMBER_WALLETS as Record - - if (!wallets[name]) return 25 - - return wallets[name] -} - -export function getLatesRoom(rooms: Record) diff --git a/ž b/ž deleted file mode 100644 index 91a5c7f..0000000 --- a/ž +++ /dev/null @@ -1,52 +0,0 @@ -import { PRESTIGE_ICONS, PRESTIGES, SLUMBER_WALLETS } from "@/data/hypixel/bedwars" -import { floorLevel } from "./formatters" - -export function getBedwarsStar(level: number) { - if (level < 1100) { - return PRESTIGE_ICONS[0].symbol - } - - if (level > 1100 && level < 2100) { - return PRESTIGE_ICONS[1].symbol - } - - if (level > 2100 && level < 3100) { - return PRESTIGE_ICONS[2].symbol - } - - return PRESTIGE_ICONS[3].symbol -} - -export function getTextColor(level: number) { - const floored = floorLevel(level, 100) - - if (level > 5000) { - return PRESTIGES[PRESTIGES.length - 1].color - } - - return PRESTIGES.find(l => l.level === floored)!.color -} - -export function getPrestigeName(level: number) { - const floored = floorLevel(level, 100) - - if (level > 5000) { - return PRESTIGES[PRESTIGES.length - 1].name - } - - return PRESTIGES.find(p => p.level === floored)!.name -} - -export function getWalletMax(name?: string) { - if (!name) return 25 - - const wallets = SLUMBER_WALLETS as Record - - if (!wallets[name]) return 25 - - return wallets[name] -} - -export function getLatesRoom(rooms?: Record) { - if (!rooms) return null -}