Updated bestmodes
This commit is contained in:
@@ -1,11 +1,12 @@
|
|||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
||||||
import { formatNumber, formatSecondsToTime } from "@/lib/formatters"
|
import { formatNumber, formatSecondsToTime } from "@/lib/formatters"
|
||||||
import { getAllBlitzKitStats, getBlitzKitLevel, getBlitzKitName, getBlitzMostPlayedKit } from "@/lib/hypixel/blitz/general"
|
import { getAllBlitzKitStats, getBlitzBestMode, getBlitzKitLevel, getBlitzKitName, getBlitzMostPlayedKit } from "@/lib/hypixel/blitz/general"
|
||||||
import { romanize } from "@/lib/hypixel/general"
|
import { romanize } from "@/lib/hypixel/general"
|
||||||
import { NonNullStats } from "@/lib/schema/player"
|
import { NonNullStats } from "@/lib/schema/player"
|
||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
export function BlitzModeStatsTable({ stats }: { stats: NonNullable<NonNullStats["Blitz"]> }) {
|
export function BlitzModeStatsTable({ stats }: { stats: NonNullable<NonNullStats["Blitz"]> }) {
|
||||||
|
const best = getBlitzBestMode(stats)
|
||||||
return (
|
return (
|
||||||
<Table>
|
<Table>
|
||||||
<TableHeader>
|
<TableHeader>
|
||||||
@@ -16,12 +17,12 @@ export function BlitzModeStatsTable({ stats }: { stats: NonNullable<NonNullStats
|
|||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
<TableRow>
|
<TableRow className={cn(best === "solo_normal" && "text-mc-light-purple")}>
|
||||||
<TableCell>Solo Normal</TableCell>
|
<TableCell>Solo Normal</TableCell>
|
||||||
<TableCell>{formatNumber(stats.kills_solo_normal)}</TableCell>
|
<TableCell>{formatNumber(stats.kills_solo_normal)}</TableCell>
|
||||||
<TableCell>{formatNumber(stats.wins_solo_normal)}</TableCell>
|
<TableCell>{formatNumber(stats.wins_solo_normal)}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
<TableRow>
|
<TableRow className={cn(best === "teams_normal" && "text-mc-light-purple")}>
|
||||||
<TableCell>Teams Normal</TableCell>
|
<TableCell>Teams Normal</TableCell>
|
||||||
<TableCell>{formatNumber(stats.kills_teams_normal)}</TableCell>
|
<TableCell>{formatNumber(stats.kills_teams_normal)}</TableCell>
|
||||||
<TableCell>{formatNumber(stats.wins_teams_normal)}</TableCell>
|
<TableCell>{formatNumber(stats.wins_teams_normal)}</TableCell>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
|
||||||
import { MODES } from "@/data/hypixel/build-battle"
|
import { MODES } from "@/data/hypixel/build-battle"
|
||||||
import { formatNumber } from "@/lib/formatters"
|
import { formatNumber } from "@/lib/formatters"
|
||||||
import { getBuildBattleModeName as getBuildBattleMode } from "@/lib/hypixel/build-battle/general"
|
import { getBuildBattleBestMode, getBuildBattleModeName as getBuildBattleMode } from "@/lib/hypixel/build-battle/general"
|
||||||
import { NonNullStats } from "@/lib/schema/player"
|
import { NonNullStats } from "@/lib/schema/player"
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
export default function BuildBattleStatsTable({ stats }: { stats: NonNullable<NonNullStats["BuildBattle"]> }) {
|
export default function BuildBattleStatsTable({ stats }: { stats: NonNullable<NonNullStats["BuildBattle"]> }) {
|
||||||
return (
|
return (
|
||||||
@@ -37,8 +38,10 @@ function TableStat({ modeId, stats }: { modeId: typeof MODES[number]["id"], stat
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isBest = getBuildBattleBestMode(stats) === modeId
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow>
|
<TableRow className={cn(isBest && "text-mc-light-purple")}>
|
||||||
<TableCell>{mode.name}</TableCell>
|
<TableCell>{mode.name}</TableCell>
|
||||||
<TableCell>{formatNumber(stats[`wins_${modeId}`])}</TableCell>
|
<TableCell>{formatNumber(stats[`wins_${modeId}`])}</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ export function getArcadeMostPlayedPixelPartyMode(stats: NonNullable<NonNullStat
|
|||||||
{ games: stats.games_played_hyper, modeId: "hyper" as const }
|
{ games: stats.games_played_hyper, modeId: "hyper" as const }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if (played[0].games === 0 && played[1].games === 0) return null
|
||||||
|
|
||||||
const mostPlayed = played.reduce((max, current) => current.games > max.games ? current : max)
|
const mostPlayed = played.reduce((max, current) => current.games > max.games ? current : max)
|
||||||
|
|
||||||
return mostPlayed.modeId
|
return mostPlayed.modeId
|
||||||
|
|||||||
@@ -163,6 +163,8 @@ export function getBestMode(stats: NonNullable<NonNullStats["Bedwars"]>): "solo"
|
|||||||
|
|
||||||
const max = Math.max(solo, doubles, threes, fours)
|
const max = Math.max(solo, doubles, threes, fours)
|
||||||
|
|
||||||
|
if (max === 0) return null
|
||||||
|
|
||||||
switch (max) {
|
switch (max) {
|
||||||
case solo:
|
case solo:
|
||||||
return "solo"
|
return "solo"
|
||||||
|
|||||||
@@ -2,6 +2,16 @@ import { KITEXP, KITS } from "@/data/hypixel/blitz"
|
|||||||
import { NonNullStats } from "@/lib/schema/player"
|
import { NonNullStats } from "@/lib/schema/player"
|
||||||
import { devide } from "../general"
|
import { devide } from "../general"
|
||||||
|
|
||||||
|
export function getBlitzBestMode(stats: NonNullable<NonNullStats["Blitz"]>) {
|
||||||
|
if (stats.wins_solo_normal === 0 && stats.wins_teams_normal === 0) return null
|
||||||
|
|
||||||
|
if (stats.wins_solo_normal > stats.wins_teams_normal) {
|
||||||
|
return "solo_normal"
|
||||||
|
} else {
|
||||||
|
return "teams_normal"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function getBlitzKitLevel(kitId: typeof KITS[number]["id"], stats: NonNullable<NonNullStats["Blitz"]>) {
|
export function getBlitzKitLevel(kitId: typeof KITS[number]["id"], stats: NonNullable<NonNullStats["Blitz"]>) {
|
||||||
let level = stats[kitId]
|
let level = stats[kitId]
|
||||||
if (level === -1) {
|
if (level === -1) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { MODES, STARS } from "@/data/hypixel/build-battle"
|
import { MODES, STARS } from "@/data/hypixel/build-battle"
|
||||||
|
import { NonNullStats } from "@/lib/schema/player"
|
||||||
|
|
||||||
export function getBuildBattleRank(score: number) {
|
export function getBuildBattleRank(score: number) {
|
||||||
for (let i = STARS.length - 1; i >= 0; i--) {
|
for (let i = STARS.length - 1; i >= 0; i--) {
|
||||||
@@ -18,3 +19,21 @@ export function getBuildBattleRankNext(score: number) {
|
|||||||
export function getBuildBattleModeName(id: typeof MODES[number]["id"]) {
|
export function getBuildBattleModeName(id: typeof MODES[number]["id"]) {
|
||||||
return MODES.find(m => m.id === id)!
|
return MODES.find(m => m.id === id)!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getBuildBattleBestMode(stats: NonNullable<NonNullStats["BuildBattle"]>): typeof MODES[number]["id"] | null {
|
||||||
|
let bestMode: typeof MODES[number]["id"] | null = null
|
||||||
|
let maxWins = 0
|
||||||
|
|
||||||
|
for (const mode of MODES) {
|
||||||
|
if (mode.id === "") continue
|
||||||
|
|
||||||
|
const wins = stats[`wins_${mode.id}` as keyof typeof stats] as number
|
||||||
|
if (wins > maxWins) {
|
||||||
|
maxWins = wins
|
||||||
|
bestMode = mode.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bestMode
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ export function getCopsAndCrimsBestMode(stats: NonNullable<NonNullStats["CopsAnd
|
|||||||
wins: mode.id === "" ? stats["game_wins"] : stats[`game_wins_${mode.id}`] || 0
|
wins: mode.id === "" ? stats["game_wins"] : stats[`game_wins_${mode.id}`] || 0
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
if (modeWins.map(m => m.wins).reduce((a, b) => a + b) === 0) return null
|
||||||
|
|
||||||
const best = modeWins.reduce((best, current) => current.wins > best.wins ? current : best).mode
|
const best = modeWins.reduce((best, current) => current.wins > best.wins ? current : best).mode
|
||||||
|
|
||||||
return best === "" ? "regular" : best
|
return best === "" ? "regular" : best
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ export function getMegaWallsMostPlayedMode(stats: NonNullable<NonNullStats["Mega
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if (modes.map(m => m.games).reduce((a, b) => a + b) === 0) return null
|
||||||
|
|
||||||
const mostPlayed = modes.reduce((max, current) => current.games > max.games ? current : max)
|
const mostPlayed = modes.reduce((max, current) => current.games > max.games ? current : max)
|
||||||
|
|
||||||
return mostPlayed.id
|
return mostPlayed.id
|
||||||
|
|||||||
@@ -80,6 +80,8 @@ export function getBestSkywarsMode(stats: NonNullable<NonNullStats["SkyWars"]>):
|
|||||||
|
|
||||||
const max = Math.max(normal, insane, teams_normal, teams_insane, mega, mega_doubles, ranked)
|
const max = Math.max(normal, insane, teams_normal, teams_insane, mega, mega_doubles, ranked)
|
||||||
|
|
||||||
|
if (max === 0) return null
|
||||||
|
|
||||||
switch (max) {
|
switch (max) {
|
||||||
case normal:
|
case normal:
|
||||||
return "normal"
|
return "normal"
|
||||||
|
|||||||
Reference in New Issue
Block a user