diff --git a/src/app/(stats)/player/[ign]/_client.tsx b/src/app/(stats)/player/[ign]/_client.tsx index 72f86ab..c013389 100644 --- a/src/app/(stats)/player/[ign]/_client.tsx +++ b/src/app/(stats)/player/[ign]/_client.tsx @@ -109,7 +109,7 @@ export function PlayerStats( "paintball": , "walls": , "vampirez": , - "quakecraft": + "quakecraft": } as const const defaultOrder = Object.keys(statsComponents) diff --git a/src/app/(stats)/player/[ign]/_stats/classic/quakecraft.tsx b/src/app/(stats)/player/[ign]/_stats/classic/quakecraft.tsx index 84c5806..f6bf9e7 100644 --- a/src/app/(stats)/player/[ign]/_stats/classic/quakecraft.tsx +++ b/src/app/(stats)/player/[ign]/_stats/classic/quakecraft.tsx @@ -3,8 +3,10 @@ import { formatNumber } from "@/lib/formatters" import { devide } from "@/lib/hypixel/general" import { NonNullStats } from "@/lib/schema/player" import { EmptyStats, GeneralStats } from "../stats-components" +import { QuakeCraftGeneralStats } from "./stats" +import { QuakecraftModeStatsTable } from "./table" -export default function QuakecraftStats({ stats }: { stats: NonNullStats["Quakecraft"] }) { +export default function QuakecraftStats({ stats, godlikes }: { stats: NonNullStats["Quakecraft"], godlikes: number }) { if (!stats) return const kd = formatNumber(devide(stats.kills + stats.kills_teams, stats.deaths + stats.deaths_teams)) @@ -29,6 +31,10 @@ export default function QuakecraftStats({ stats }: { stats: NonNullStats["Quakec ]} > + + + + ) } diff --git a/src/app/(stats)/player/[ign]/_stats/classic/stats.tsx b/src/app/(stats)/player/[ign]/_stats/classic/stats.tsx index f516e94..c8e437d 100644 --- a/src/app/(stats)/player/[ign]/_stats/classic/stats.tsx +++ b/src/app/(stats)/player/[ign]/_stats/classic/stats.tsx @@ -87,3 +87,32 @@ export function VampireZGeneralStats({ stats }: { stats: NonNullable ) } + +export function QuakeCraftGeneralStats({ stats, godlikes }: { stats: NonNullable, godlikes: number }) { + return ( +
+
+ +

+
+

+ + + +
+
+ +

+
+

+ + + + +
+
+ ) +} diff --git a/src/app/(stats)/player/[ign]/_stats/classic/table.tsx b/src/app/(stats)/player/[ign]/_stats/classic/table.tsx index 775bb49..abc3c74 100644 --- a/src/app/(stats)/player/[ign]/_stats/classic/table.tsx +++ b/src/app/(stats)/player/[ign]/_stats/classic/table.tsx @@ -1,9 +1,82 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table" import { formatNumber } from "@/lib/formatters" -import { getArenaBrawlModeName, getArenaBrawlModeStats, getArenaBrawlMostPlayedMode, getArenaBrawlOverallStats } from "@/lib/hypixel/classic/general" +import { + getArenaBrawlModeName, + getArenaBrawlModeStats, + getArenaBrawlMostPlayedMode, + getArenaBrawlOverallStats, + getQuakecraftModeName, + getQuakecraftModeStats, + getQuakecraftMostPlayedMode +} from "@/lib/hypixel/classic/general" import { NonNullStats } from "@/lib/schema/player" import { cn } from "@/lib/utils" +export function QuakecraftModeStatsTable({ stats }: { stats: NonNullable }) { + return ( + + + + + + + +
+ ) +} + +function QuakecraftModeStat( + { modeId, stats }: { modeId: Parameters[0], stats: NonNullable } +) { + if (modeId === "all") { + const modeStats = getQuakecraftModeStats(modeId, stats) + return ( + + Overall + {modeStats.map((v, i) => { + return {formatNumber(v)} + })} + + ) + } + + const modeStats = getQuakecraftModeStats(modeId, stats) + const modeName = getQuakecraftModeName(modeId) + const mostPlayed = getQuakecraftMostPlayedMode(stats) === modeId + + return ( + + {modeName} + {modeStats.map((v, i) => { + return {formatNumber(v)} + })} + + ) +} + +function QuakecraftModeStatsTableHeader() { + const headerElements = [ + "Mode", + "Kills", + "Deaths", + "KD", + "Wins", + "Killstreaks", + "Headshots", + "Shots Fired", + "HK", + "KS" + ] + + return ( + + + {headerElements.map((v, i) => {v})} + + + ) +} + export function ArenaBrawlModeStatsTable({ stats }: { stats: NonNullable }) { return ( diff --git a/src/lib/hypixel/classic/general.ts b/src/lib/hypixel/classic/general.ts index 3f4a1fe..7ed3c53 100644 --- a/src/lib/hypixel/classic/general.ts +++ b/src/lib/hypixel/classic/general.ts @@ -1,7 +1,61 @@ -import { ARENABRAWLMODES } from "@/data/hypixel/classic" +import { ARENABRAWLMODES, QUAKECRAFTMODES } from "@/data/hypixel/classic" import { NonNullStats } from "@/lib/schema/player" import { devide } from "../general" +export function getQuakecraftModeName(modeId: Exclude | "solo") { + if (modeId === "solo") return QUAKECRAFTMODES.find(m => m.id === "")!.name + return QUAKECRAFTMODES.find(m => m.id === modeId)!.name +} + +export function getQuakecraftMostPlayedMode(stats: NonNullable) { + if (stats.wins + stats.wins_teams === 0) return null + + return stats.wins > stats.wins_teams ? "solo" : "teams" +} + +export function getQuakecraftModeStats( + modeId: Exclude | "solo" | "all", + stats: NonNullable +) { + if (modeId === "all") { + return [ + stats.kills + stats.kills_teams, + stats.deaths + stats.deaths_teams, + devide(stats.kills + stats.kills_teams, stats.deaths + stats.deaths_teams), + stats.wins + stats.wins_teams, + stats.killstreaks + stats.killstreaks_teams, + stats.headshots + stats.headshots_teams, + stats.shots_fired + stats.shots_fired_teams, + devide(stats.headshots + stats.headshots_teams, stats.kills_since_update_feb_2017 + stats.kills_since_update_feb_2017_teams), + devide(stats.kills_since_update_feb_2017 + stats.kills_since_update_feb_2017_teams, stats.shots_fired + stats.shots_fired_teams) + ] + } else if (modeId === "solo") { + return [ + stats.kills, + stats.deaths, + devide(stats.kills, stats.deaths), + stats.wins, + stats.killstreaks, + stats.headshots, + stats.shots_fired, + devide(stats.headshots, stats.kills_since_update_feb_2017), + devide(stats.kills_since_update_feb_2017, stats.shots_fired) + ] + } else { + return [ + stats[`kills_${modeId}`], + stats[`deaths_${modeId}`], + devide(stats[`kills_${modeId}`], stats[`deaths_${modeId}`]), + stats[`wins_${modeId}`], + stats[`killstreaks_${modeId}`], + stats[`headshots_${modeId}`], + stats[`shots_fired_${modeId}`], + devide(stats[`headshots_${modeId}`], stats[`kills_since_update_feb_2017_${modeId}`]), + devide(stats[`kills_since_update_feb_2017_${modeId}`], stats[`shots_fired_${modeId}`]) + ] + } +} + export function getArenaBrawlModeName(modeId: typeof ARENABRAWLMODES[number]["id"]) { return ARENABRAWLMODES.find(m => m.id === modeId)!.name } diff --git a/src/lib/schema/stats/classic.ts b/src/lib/schema/stats/classic.ts index 7b0b7d9..4055dbb 100644 --- a/src/lib/schema/stats/classic.ts +++ b/src/lib/schema/stats/classic.ts @@ -50,16 +50,22 @@ export const vampireZStatsSchema = z.object({ }) export const quakecraftStatsSchema = z.object({ + coins: z.number().default(0), kills: z.number().default(0), deaths: z.number().default(0), + killstreaks: z.number().default(0), wins: z.number().default(0), headshots: z.number().default(0), kills_since_update_feb_2017: z.number().default(0), shots_fired: z.number().default(0), kills_teams: z.number().default(0), deaths_teams: z.number().default(0), + killstreaks_teams: z.number().default(0), wins_teams: z.number().default(0), headshots_teams: z.number().default(0), kills_since_update_feb_2017_teams: z.number().default(0), - shots_fired_teams: z.number().default(0) + shots_fired_teams: z.number().default(0), + highest_killstreak: z.number().default(0), + dash_cooldown: z.coerce.number().default(0), + dash_power: z.coerce.number().default(0) })