Added card for cops and crims

This commit is contained in:
2025-09-08 14:53:32 +02:00
parent 82636ade5c
commit eb58dde03f
6 changed files with 128 additions and 2 deletions

View File

@@ -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 (
<AccordionItem value="cops-and-crims">
<Card className="py-0">
<CardContent>
<AccordionTrigger className="items-center py-2 hover:no-underline hover:cursor-pointer">
<h1 className="text-xl font-bold">Cops And Crims</h1>
<div className="flex gap-4">
<CollapsedStats
stats={[
{
title: <p>Score</p>,
stat: <p className={`font-bold text-mc-${scoreColor}`}>{formatNumber(score)}</p>
},
{
title: <p>Kills</p>,
stat: <p className="text-muted-foreground">{formatNumber(kills)}</p>
},
{
title: <p>KD</p>,
stat: <p className="text-muted-foreground">{kd}</p>
},
{
title: <p>Wins</p>,
stat: <p className="text-muted-foreground">{formatNumber(wins)}</p>
}
]}
/>
</div>
</AccordionTrigger>
<AccordionContent>
<Separator className="my-4" />
</AccordionContent>
</CardContent>
</Card>
</AccordionItem>
)
}

View File

@@ -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 }) {
<PitStats stats={player.stats.Pit} />
<TNTGamesStats stats={player.stats.TNTGames} />
<MegaWallsStats stats={player.stats.MegaWalls} />
<CopsAndCrimsStats stats={player.stats.CopsAndCrims} />
</Accordion>
</div>
) :

View File

@@ -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

View File

@@ -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
}

View File

@@ -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(),

View File

@@ -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)
})