Added first

This commit is contained in:
2025-09-05 19:31:06 +02:00
parent 306ad1f146
commit 5bf00d513a
7 changed files with 238 additions and 2 deletions

View File

@@ -0,0 +1,22 @@
import { LEVELCOLORS, PRESTIGECOLORS } from "@/data/hypixel/pit"
import { NonNullStats } from "@/lib/schema/player"
export function getLevelColor(level: number) {
for (const lvl of LEVELCOLORS.slice().reverse()) {
if (lvl.level <= level) return lvl.color
}
return LEVELCOLORS.at(0)!.color
}
export function getPrestigeColor(prestige: number) {
for (const pres of PRESTIGECOLORS.slice().reverse()) {
if (pres.prestige <= prestige) return pres.color
}
return PRESTIGECOLORS.at(0)!.color
}
export function getPrestige(stats: NonNullable<NonNullStats["Pit"]>) {
return stats.profile.prestiges.length
}

View File

@@ -0,0 +1,27 @@
import { LEVEL_REQUIREMENTS, PRESTIGE_MULTIPLIERS } from "@/data/hypixel/pit"
export function getPitLevel(xp: number, prestige: number) {
let xps = xp
if (prestige > 0) {
xps = xps - PRESTIGE_MULTIPLIERS[prestige - 1]["SumXp"]
}
const multiplier = PRESTIGE_MULTIPLIERS[prestige]["Multiplier"]
let level = 0
while (xps > 0 && level < 120) {
const levelXp = LEVEL_REQUIREMENTS[Math.floor(level / 10)] * multiplier
if (xps >= levelXp * 10) {
xps -= levelXp * 10
level += 10
} else {
const gain = Math.floor(xps / levelXp)
level += gain
xps -= gain * levelXp
xps = 0
}
}
return level
}

View File

@@ -1,5 +1,13 @@
import z from "zod"
import { bedwarsStatsSchema, buildBattleStatsSchema, duelsStatsSchema, murderMysteryStatsSchema, skywarsStatsSchema, uhcSchema } from "./stats"
import {
bedwarsStatsSchema,
buildBattleStatsSchema,
duelsStatsSchema,
murderMysteryStatsSchema,
pitStats,
skywarsStatsSchema,
uhcSchema
} from "./stats"
export const playerSchema = z.looseObject({
player: z.looseObject({
@@ -19,7 +27,8 @@ export const playerSchema = z.looseObject({
Duels: duelsStatsSchema.optional(),
MurderMystery: murderMysteryStatsSchema.optional(),
BuildBattle: buildBattleStatsSchema.optional(),
UHC: uhcSchema.optional()
UHC: uhcSchema.optional(),
Pit: pitStats.optional()
}).optional(),
quests: z.record(
z.string(),

View File

@@ -445,3 +445,22 @@ export const uhcSchema = z.looseObject({
ultimates_crafted_solo: z.number().default(0),
...uhcModesStats()
})
export const pitStats = z.looseObject({
pit_stats_ptl: z.looseObject({
kills: z.number().default(0),
deaths: z.number().default(0)
}),
profile: z.looseObject({
prestiges: z.array(z.looseObject({
index: z.number(),
xp_on_prestige: z.number(),
timestamp: z.number()
})),
xp: z.number().default(0)
})
}).transform(({ profile, pit_stats_ptl, ...rest }) => ({
profile,
...pit_stats_ptl,
...rest
}))