Added best mode stats

This commit is contained in:
2025-09-14 21:05:12 +02:00
parent 3711b43b4e
commit 0d7c79a310
8 changed files with 113 additions and 10 deletions

View File

@@ -1,7 +1,8 @@
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { formatNumber } from "@/lib/formatters"
import { getCopsAndCrimsModeName, getCopsAndCrimsModeStats } from "@/lib/hypixel/copsandcrims/general"
import { getCopsAndCrimsBestMode, getCopsAndCrimsModeName, getCopsAndCrimsModeStats } from "@/lib/hypixel/copsandcrims/general"
import { NonNullStats } from "@/lib/schema/player"
import { cn } from "@/lib/utils"
export default function CopsAndCrimsStatTable({ stats }: { stats: NonNullable<NonNullStats["CopsAndCrims"]> }) {
return (
@@ -44,10 +45,12 @@ function CopsAndCrimsTableStat(
stats: NonNullable<NonNullStats["CopsAndCrims"]>
}
) {
const modeStats = getCopsAndCrimsModeStats(modeId === "regular" ? "" : modeId, stats)
const name = getCopsAndCrimsModeName(modeId === "regular" ? "" : modeId)
const modeStats = getCopsAndCrimsModeStats(modeId === "regular" ? "" : modeId, stats)
const isBest = getCopsAndCrimsBestMode(stats) === modeId
return (
<TableRow>
<TableRow className={cn(isBest && "text-mc-light-purple")}>
<TableCell>{name}</TableCell>
{modeStats.map((v, i) => {
return <TableCell key={i}>{formatNumber(v)}</TableCell>

View File

@@ -6,9 +6,12 @@ import {
getMegaWallsClass,
getMegaWallsDifficultyColor,
getMegaWallsModeName,
getMegaWallsModeStats
getMegaWallsModeStats,
getMegaWallsMostPlayedClass,
getMegaWallsMostPlayedMode
} from "@/lib/hypixel/megawalls/general"
import { NonNullStats } from "@/lib/schema/player"
import { cn } from "@/lib/utils"
export function MegaWallsModesTable({ stats }: { stats: NonNullable<NonNullStats["MegaWalls"]> }) {
return (
@@ -90,8 +93,9 @@ function MegaWallsClassStats({ stats }: { stats: NonNullable<NonNullStats["MegaW
const { id, val } = c
const klass = getMegaWallsClass(id)
const difColor = getMegaWallsDifficultyColor(klass.difficulty)
const isBest = getMegaWallsMostPlayedClass(stats)?.id === id
return (
<TableRow key={i}>
<TableRow key={i} className={cn(isBest && "text-mc-light-purple")}>
<TableCell className={`text-mc-${difColor}`}>{klass.name}</TableCell>
{val.map((v, j) => {
if (j === val.length - 2) {
@@ -111,9 +115,10 @@ function MegaWallsModeStat(
) {
const modeName = getMegaWallsModeName(modeId)
const modeStat = getMegaWallsModeStats(modeId, stats)
const mostPlayed = getMegaWallsMostPlayedMode(stats) === modeId
return (
<TableRow>
<TableRow className={cn(mostPlayed && "text-mc-light-purple")}>
<TableCell>{modeName}</TableCell>
{modeStat.map((s, i) => {
return <TableCell key={i}>{formatNumber(s)}</TableCell>

View File

@@ -1,6 +1,6 @@
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { formatNumber } from "@/lib/formatters"
import { getUHCModeName, getUHCModeStats } from "@/lib/hypixel/uhc/general"
import { getUHCBestMode, getUHCModeName, getUHCModeStats } from "@/lib/hypixel/uhc/general"
import { NonNullStats } from "@/lib/schema/player"
import { cn } from "@/lib/utils"
@@ -49,9 +49,10 @@ function TableStat(
) {
const modeStats = getUHCModeStats(modeId === "teams" ? "" : modeId, stats)
const modeName = getUHCModeName(modeId === "teams" || modeId === "all_modes" ? "" : modeId)
const isBest = getUHCBestMode(stats) === modeId
return (
<TableRow className={cn(modeId === "all_modes" && "font-bold")}>
<TableRow className={cn(modeId === "all_modes" && "font-bold", isBest && "text-mc-light-purple")}>
<TableCell>{modeId === "all_modes" ? "Overall" : modeName}</TableCell>
{modeStats.map((v, i) => {
return (

View File

@@ -1,6 +1,11 @@
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
import { formatNumber } from "@/lib/formatters"
import { getWoolGamesWoolWarsClass, getWoolGamesWoolWarsClassColor, getWoolGamesWoolWarsClassStats } from "@/lib/hypixel/woolgames/general"
import {
getWoolGamesWoolWarsClass,
getWoolGamesWoolWarsClassColor,
getWoolGamesWoolWarsClassStats,
getWoolGamesWoolWarsMostPlayedClass
} from "@/lib/hypixel/woolgames/general"
import { NonNullStats } from "@/lib/schema/player"
import { cn } from "@/lib/utils"
@@ -52,9 +57,10 @@ function StatRow(
const classStats = getWoolGamesWoolWarsClassStats(classId, stats)
const klass = getWoolGamesWoolWarsClass(classId)
const classColor = getWoolGamesWoolWarsClassColor(klass?.difficulty)
const isMostPlayed = getWoolGamesWoolWarsMostPlayedClass(stats)?.id === classId
return (
<TableRow>
<TableRow className={cn(isMostPlayed && "text-mc-light-purple")}>
<TableCell className={cn(classColor && `text-mc-${classColor}`)}>{klass !== null ? klass.name : "Unknown"}</TableCell>
{classStats.map((v, i) => {
return <TableCell key={i}>{formatNumber(v)}</TableCell>