Added first skywars stats
This commit is contained in:
@@ -12,7 +12,11 @@ export async function getPlayer(uuid: string) {
|
||||
|
||||
if (!res.ok) return null
|
||||
|
||||
const { success, data } = playerSchema.safeParse(await res.json())
|
||||
const { success, data, error } = playerSchema.safeParse(await res.json())
|
||||
|
||||
if (error) {
|
||||
console.log(error)
|
||||
}
|
||||
|
||||
if (!success) return null
|
||||
|
||||
|
||||
13
src/lib/hypixel/skyWarsLevel.ts
Normal file
13
src/lib/hypixel/skyWarsLevel.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export function getSkywarsLevel(xp: number) {
|
||||
const xps = [0, 20, 70, 150, 250, 500, 1000, 2000, 3500, 6000, 10000, 15000]
|
||||
if (xp >= 15000) {
|
||||
return (xp - 15000) / 10000 + 12
|
||||
}
|
||||
for (let i = 0; i < xps.length; i += 1) {
|
||||
if (xp < xps[i]) {
|
||||
return i + (xp - xps[i - 1]) / (xps[i] - xps[i - 1])
|
||||
}
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
30
src/lib/hypixel/skywars.ts
Normal file
30
src/lib/hypixel/skywars.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { ICONS, PRESTIGES } from "@/data/hypixel/skywars"
|
||||
import { floorLevel } from "./formatters"
|
||||
|
||||
export function getTextColor(level: number) {
|
||||
const floored = floorLevel(level, 5)
|
||||
|
||||
if (level > 150) {
|
||||
return {
|
||||
text: PRESTIGES.at(-1)?.color ?? "gray",
|
||||
brackets: PRESTIGES.at(-1)?.b_color ?? "gray"
|
||||
}
|
||||
}
|
||||
|
||||
const pres = PRESTIGES.find(p => p.level === floored)
|
||||
|
||||
return {
|
||||
text: pres?.color ?? "gray",
|
||||
brackets: pres?.b_color ?? "gray"
|
||||
}
|
||||
}
|
||||
|
||||
export function getSkyWarsIcon(icon?: string) {
|
||||
if (!icon) {
|
||||
return ICONS.default
|
||||
}
|
||||
|
||||
const icons = ICONS as Record<string, string>
|
||||
|
||||
return icons[icon] ?? ICONS.default
|
||||
}
|
||||
Reference in New Issue
Block a user