diff --git a/src/app/(stats)/player/[ign]/_stats/copsandcrims/copsandcrims.tsx b/src/app/(stats)/player/[ign]/_stats/copsandcrims/copsandcrims.tsx new file mode 100644 index 0000000..93f2353 --- /dev/null +++ b/src/app/(stats)/player/[ign]/_stats/copsandcrims/copsandcrims.tsx @@ -0,0 +1,56 @@ +import { AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion" +import { Card, CardContent } from "@/components/ui/card" +import { Separator } from "@/components/ui/separator" +import { formatNumber } from "@/lib/formatters" +import { getScoreColor } from "@/lib/hypixel/copsandcrims/general" +import { devide } from "@/lib/hypixel/general" +import { NonNullStats } from "@/lib/schema/player" +import CollapsedStats from "../../_components/CollapsedStats" + +export default function CopsAndCrimsStats({ stats }: { stats: NonNullStats["CopsAndCrims"] }) { + if (!stats) return null + + const kills = stats.kills + stats.kills_deathmatch + stats.kills_gungame + const deaths = stats.deaths + stats.deaths_deathmatch + stats.deaths_gungame + const wins = stats.game_wins + stats.game_wins_deathmatch + stats.game_wins_gungame + const kd = formatNumber(devide(kills, deaths)) + const score = Math.floor(kills / 2 + (stats.bombs_planted + stats.bombs_defused) / 3 + wins + devide(kills, stats.shots_fired) * 200) + const scoreColor = getScoreColor(score) + + return ( + + + + +

Cops And Crims

+
+ Score

, + stat:

{formatNumber(score)}

+ }, + { + title:

Kills

, + stat:

{formatNumber(kills)}

+ }, + { + title:

KD

, + stat:

{kd}

+ }, + { + title:

Wins

, + stat:

{formatNumber(wins)}

+ } + ]} + /> +
+
+ + + +
+
+
+ ) +} diff --git a/src/app/(stats)/player/[ign]/page.tsx b/src/app/(stats)/player/[ign]/page.tsx index daac47c..33aa44d 100644 --- a/src/app/(stats)/player/[ign]/page.tsx +++ b/src/app/(stats)/player/[ign]/page.tsx @@ -12,6 +12,7 @@ import { Suspense } from "react" import Sidebar from "./_components/Sidebar" import BedwarsStats from "./_stats/bedwars/bedwars" import BuildBattleStats from "./_stats/build-battle/build-battle" +import CopsAndCrimsStats from "./_stats/copsandcrims/copsandcrims" import DuelsStats from "./_stats/duels/duels" import MegaWallsStats from "./_stats/megawalls/megawalls" import MurderMysteryStats from "./_stats/murder-mystery/murder-mystery" @@ -122,6 +123,7 @@ async function SuspendedPage({ ign: pign }: { ign: string }) { + ) : diff --git a/src/data/hypixel/copsandcrims.ts b/src/data/hypixel/copsandcrims.ts new file mode 100644 index 0000000..8dd06ec --- /dev/null +++ b/src/data/hypixel/copsandcrims.ts @@ -0,0 +1,41 @@ +export const MODES = [ + { id: "", name: "Defusal" }, + { id: "deathmatch", name: "Team Deathmatch" }, + { id: "gungame", name: "Gun Game" } +] as const +export const GUNS = [ + { id: "knife", name: "Knife" }, + { id: "pistol", name: "Pistol" }, + { id: "handgun", name: "Handgun" }, + { id: "magnum", name: "Magnum" }, + { id: "sniper", name: "Sniper" }, + { id: "bullpup", name: "Bullpup" }, + { id: "smg", name: "SMG" }, + { id: "rifle", name: "Rifle" }, + { id: "carbine", name: "Carbine" }, + { id: "scoped_rifle", name: "Scoped Rifle" }, + { id: "shotgun", name: "Shotgun" }, + { id: "auto_shotgun", name: "Auto Shotgun" } +] as const +export const SCORE = [ + { score: 0, color: "gray" }, + { score: 2500, color: "white" }, + { score: 5000, color: "yellow" }, + { score: 20000, color: "gold" }, + { score: 50000, color: "dark-aqua" }, + { score: 100000, color: "red" } +] as const +export const UPGRADES = [ + { id: "damage_increase", name: "Damage Increase" }, + { id: "recoil_reduction", name: "Recoil Reduction" }, + { id: "charge_bonus", name: "Target Acquire" }, // For sniper only + { id: "reload_speed_reduction", name: "Reload Time Reduction" }, + { id: "cost_reduction", name: "Cost Reduction" }, + { id: "attack_delay", name: "Attack Delay" } // For knife only +] as const +export const UPGRADELEVELS = [ + { level: 0, color: "gray" }, + { level: 3, color: "yellow" }, + { level: 6, color: "red" }, + { level: 9, color: "dark-red" } +] as const diff --git a/src/lib/hypixel/copsandcrims/general.ts b/src/lib/hypixel/copsandcrims/general.ts new file mode 100644 index 0000000..dbac303 --- /dev/null +++ b/src/lib/hypixel/copsandcrims/general.ts @@ -0,0 +1,9 @@ +import { SCORE } from "@/data/hypixel/copsandcrims" + +export function getScoreColor(score: number) { + for (const scoreThreshold of SCORE.slice().reverse()) { + if (scoreThreshold.score <= score) return scoreThreshold.color + } + + return SCORE.at(0)!.color +} diff --git a/src/lib/schema/player.ts b/src/lib/schema/player.ts index 83e48ab..a4def76 100644 --- a/src/lib/schema/player.ts +++ b/src/lib/schema/player.ts @@ -2,6 +2,7 @@ import z from "zod" import { bedwarsStatsSchema, buildBattleStatsSchema, + copsAndCrimsStatsSchema, duelsStatsSchema, megawallsStats, murderMysteryStatsSchema, @@ -32,10 +33,12 @@ export const playerSchema = z.looseObject({ UHC: uhcSchema.optional(), Pit: pitStats.optional(), TNTGames: tntGamesStatsSchema.optional(), - Walls3: megawallsStats.optional() - }).transform(({ Walls3, ...rest }) => { + Walls3: megawallsStats.optional(), + MCGO: copsAndCrimsStatsSchema.optional() + }).transform(({ Walls3, MCGO, ...rest }) => { return { MegaWalls: Walls3, + CopsAndCrims: MCGO, ...rest } }).optional(), diff --git a/src/lib/schema/stats.ts b/src/lib/schema/stats.ts index 202b170..6ceec75 100644 --- a/src/lib/schema/stats.ts +++ b/src/lib/schema/stats.ts @@ -659,3 +659,18 @@ export const megawallsStats = z.looseObject({ ...megawallsClassStats().classStats, ...megawallsModeStats() }) + +export const copsAndCrimsStatsSchema = z.looseObject({ + kills: z.number().default(0), + deaths: z.number().default(0), + game_wins: z.number().default(0), + kills_deathmatch: z.number().default(0), + deaths_deathmatch: z.number().default(0), + game_wins_deathmatch: z.number().default(0), + kills_gungame: z.number().default(0), + deaths_gungame: z.number().default(0), + game_wins_gungame: z.number().default(0), + bombs_planted: z.number().default(0), + bombs_defused: z.number().default(0), + shots_fired: z.number().default(0) +})