Added first table row

This commit is contained in:
2025-09-02 00:07:36 +02:00
parent c2a22471b6
commit f18c2dee3b
4 changed files with 250 additions and 251 deletions

View File

@@ -1,16 +1,23 @@
import { DIVISIONS, MODES } from "@/data/hypixel/duels"
import { formatNumber } from "@/lib/formatters"
import { NonNullStats } from "@/lib/schema/player"
import { devide } from "../general"
type DuelType = "all_modes"
export type Div = {
name: typeof DIVISIONS[number]["name"]
level: number
color: typeof DIVISIONS[number]["color"]
}
export function getDivision(duelType: DuelType, stats: NonNullable<NonNullStats["Duels"]>) {
export function getModeTitle(id: typeof MODES[number]["id"]) {
const div = MODES.find(d => d.id === id)
return div!.name
}
export function getAllDivisions(stats: NonNullable<NonNullStats["Duels"]>) {
for (const div of DIVISIONS.slice().reverse()) {
const index = `${duelType}_${div.id}_title_prestige` as const
const index = `all_modes_${div.id}_title_prestige` as const
const val = stats[index]
if (val > 0) {
return {
@@ -36,3 +43,46 @@ export function getMostPlayed(stats: NonNullable<NonNullStats["Duels"]>) {
}
return mostPlayed
}
type Mode = typeof MODES[number]["id"]
// export function getBestMode(stats: NonNullable<NonNullStats["Duels"]>) {
// const { wins_bedwars: solo } = getBedwarsModeStats("solo", stats, true)
// const { wins_bedwars: doubles } = getBedwarsModeStats("doubles", stats, true)
// const { wins_bedwars: threes } = getBedwarsModeStats("3s", stats, true)
// const { wins_bedwars: fours } = getBedwarsModeStats("4s", stats, true)
//
// const max = Math.max(solo, doubles, threes, fours)
//
// switch (max) {
// case solo:
// return "solo"
// case doubles:
// return "doubles"
// case threes:
// return "3s"
// case fours:
// return "4s"
// default:
// return null
// }
// }
export function getDuelsModeStats(mode: Mode, stats: NonNullable<NonNullStats["Duels"]>) {
return duelsModeStats(mode, stats)
}
function duelsModeStats(index: typeof MODES[number]["id"], stats: NonNullable<NonNullStats["Duels"]>) {
return [
stats[`${index}_kills`],
stats[`${index}_deaths`],
formatNumber(devide(stats[`${index}_kills`], stats[`${index}_deaths`])),
stats[`${index}_wins`],
stats[`${index}_losses`],
formatNumber(devide(stats[`${index}_wins`], stats[`${index}_losses`])),
stats[`current_winstreak_mode_${index}`] ?? -1,
stats[`best_winstreak_mode_${index}`] ?? -1,
formatNumber(devide(stats[`${index}_melee_hits`], stats[`${index}_melee_swings`])),
formatNumber(devide(stats[`${index}_bow_hits`], stats[`${index}_bow_shots`]))
]
}