Updated wool games stats
This commit is contained in:
69
src/lib/hypixel/woolgames/general.ts
Normal file
69
src/lib/hypixel/woolgames/general.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { EASY_XP, ICONS, NORMAL_XP, PRESTIGES } from "@/data/hypixel/woolgames"
|
||||
import { getColorFromCode } from "@/lib/colors"
|
||||
import { floorLevel } from "../general"
|
||||
|
||||
export function getWoolGamesPrestige(level: number) {
|
||||
const floored = floorLevel(Math.floor(level), 100)
|
||||
|
||||
if (level > 1000) {
|
||||
const { name, color, colormap } = PRESTIGES.at(-1)!
|
||||
|
||||
return {
|
||||
name,
|
||||
color,
|
||||
colormap: colormap.split("").map(v => {
|
||||
return getColorFromCode(v)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (floored === 900) {
|
||||
const { name, color, colormap } = PRESTIGES.find(p => p.level === floored)!
|
||||
return {
|
||||
name,
|
||||
color,
|
||||
colormap: colormap.split("").map(v => {
|
||||
return getColorFromCode(v)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const { name, color, colormap } = PRESTIGES.find(p => p.level === floored)!
|
||||
return {
|
||||
name,
|
||||
color,
|
||||
colormap: getColorFromCode(colormap)
|
||||
}
|
||||
}
|
||||
|
||||
export function getWoolGamesPretigeIcon(icon?: string) {
|
||||
return Object.entries(ICONS).find(v => v[0] === icon)?.[1] || ICONS.HEART
|
||||
}
|
||||
|
||||
function getExpReq(level: number) {
|
||||
const progress = level % 100
|
||||
|
||||
if (level === 0) return 0
|
||||
else if (progress < 5) return EASY_XP[progress]
|
||||
else return NORMAL_XP
|
||||
}
|
||||
|
||||
export function getWoolGamesLevel(xp = 0) {
|
||||
let remainingXP = xp
|
||||
let lvl = 1
|
||||
let deltaXP = getExpReq(lvl)
|
||||
while (remainingXP > 0) {
|
||||
deltaXP = getExpReq(lvl)
|
||||
remainingXP -= deltaXP
|
||||
lvl++
|
||||
}
|
||||
return lvl + remainingXP / deltaXP
|
||||
}
|
||||
|
||||
export function getWoolGamesXPForLevel(lvl: number) {
|
||||
let xp = 0
|
||||
for (let i = 0; i < lvl; i++) {
|
||||
xp += getExpReq(i)
|
||||
}
|
||||
return xp
|
||||
}
|
||||
@@ -725,6 +725,10 @@ export const copsAndCrimsStatsSchema = z.looseObject({
|
||||
})
|
||||
|
||||
export const woolGamesStatsSchema = z.looseObject({
|
||||
wool_wars_prestige_icon: z.string().optional(),
|
||||
progression: z.looseObject({
|
||||
experience: z.number().default(0)
|
||||
}).optional(),
|
||||
capture_the_wool: z.looseObject({
|
||||
stats: z.looseObject({
|
||||
kills: z.number().default(0),
|
||||
|
||||
Reference in New Issue
Block a user