Updated bedears stats
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
const numberFormatter = new Intl.NumberFormat(undefined, {
|
||||
maximumFractionDigits: 2,
|
||||
minimumFractionDigits: 0,
|
||||
});
|
||||
minimumFractionDigits: 0
|
||||
})
|
||||
|
||||
const dateFormatter = new Intl.DateTimeFormat(undefined, {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
});
|
||||
year: "numeric",
|
||||
month: "2-digit",
|
||||
day: "2-digit",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
hour12: false
|
||||
})
|
||||
|
||||
export function formatNumber(num: number): string {
|
||||
return numberFormatter.format(num);
|
||||
return numberFormatter.format(num)
|
||||
}
|
||||
export function formatDate(timestamp: number): string {
|
||||
return dateFormatter.format(new Date(timestamp));
|
||||
}
|
||||
return dateFormatter.format(new Date(timestamp))
|
||||
}
|
||||
|
||||
@@ -17,4 +17,5 @@ export async function getPlayer(uuid: string) {
|
||||
if (!success) return null
|
||||
|
||||
return data.player
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { PRESTIGE_ICONS } from "@/data/hypixel/bedwars"
|
||||
import { PRESTIGE_ICONS, PRESTIGES } from "@/data/hypixel/bedwars"
|
||||
import { floorLevel } from "./formatters"
|
||||
|
||||
export function getBedwarsStar(level: number) {
|
||||
if (level < 1100) {
|
||||
@@ -15,3 +16,23 @@ export function getBedwarsStar(level: number) {
|
||||
|
||||
return PRESTIGE_ICONS[3].symbol
|
||||
}
|
||||
|
||||
export function getTextColor(level: number) {
|
||||
const floored = floorLevel(level, 100)
|
||||
|
||||
if (level > 5000) {
|
||||
return PRESTIGES[PRESTIGES.length - 1].color
|
||||
}
|
||||
|
||||
return PRESTIGES.find(l => l.level === floored)!.color
|
||||
}
|
||||
|
||||
export function getPrestigeName(level: number) {
|
||||
const floored = floorLevel(level, 100)
|
||||
|
||||
if (level > 5000) {
|
||||
return PRESTIGES[PRESTIGES.length - 1].name
|
||||
}
|
||||
|
||||
return PRESTIGES.find(p => p.level === floored)!.name
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ const XP_PER_PRESTIGE = 96 * 5000 + EASY_LEVELS_XP
|
||||
const LEVELS_PER_PRESTIGE = 100
|
||||
const HIGHEST_PRESTIGE = 10
|
||||
|
||||
export function getBWLevel(level: number) {
|
||||
function getBWLevel(level: number) {
|
||||
if (level > HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE) {
|
||||
return level - HIGHEST_PRESTIGE * LEVELS_PER_PRESTIGE
|
||||
}
|
||||
@@ -15,7 +15,7 @@ export function getBWLevel(level: number) {
|
||||
return level % LEVELS_PER_PRESTIGE
|
||||
}
|
||||
|
||||
export function getBWExpForLevel(level: number) {
|
||||
function getBWExpForLevel(level: number) {
|
||||
if (level === 0) return 0
|
||||
|
||||
const respectedLevel = getBWLevel(level)
|
||||
@@ -53,3 +53,17 @@ export function getBWLevelForExp(exp: number) {
|
||||
}
|
||||
return level + Math.floor(expWithoutPrestiges / 5000)
|
||||
}
|
||||
|
||||
export function getTotalExpForLevel(level: number): number {
|
||||
if (level === 0) return 0
|
||||
|
||||
const prestiges = Math.floor(level / LEVELS_PER_PRESTIGE)
|
||||
let totalExp = prestiges * XP_PER_PRESTIGE
|
||||
const remainingLevels = level % LEVELS_PER_PRESTIGE
|
||||
|
||||
for (let i = 1; i <= remainingLevels; i += 1) {
|
||||
totalExp += getBWExpForLevel(i)
|
||||
}
|
||||
|
||||
return totalExp
|
||||
}
|
||||
|
||||
7
src/lib/hypixel/general.ts
Normal file
7
src/lib/hypixel/general.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export function getProgress(min: number, mid: number, max: number) {
|
||||
if (max === min) return 100
|
||||
const diff = max - min
|
||||
const progress = mid - min
|
||||
|
||||
return progress / diff * 100
|
||||
}
|
||||
@@ -2,18 +2,18 @@ import z from "zod"
|
||||
|
||||
export const playerSchema = z.looseObject({
|
||||
player: z.looseObject({
|
||||
displayname: z.string(),
|
||||
uuid: z.string(),
|
||||
newPackageRank: z.literal("VIP").or(z.literal("VIP_PLUS").or(z.literal("MVP")).or(z.literal("MVP_PLUS"))).optional(),
|
||||
displayname: z.string().optional(),
|
||||
uuid: z.string().optional(),
|
||||
newPackageRank: z.string().optional(),
|
||||
monthlyPackageRank: z.string().optional(),
|
||||
rankPlusColor: z.string().optional(),
|
||||
monthlyRankColor: z.literal("GOLD").or(z.literal("AQUA")).optional(),
|
||||
networkExp: z.number(),
|
||||
karma: z.number(),
|
||||
achievementPoints: z.number().optional(),
|
||||
monthlyRankColor: z.string().optional(),
|
||||
networkExp: z.number().default(0),
|
||||
karma: z.number().default(0),
|
||||
achievementPoints: z.number().default(0),
|
||||
stats: z.looseObject({
|
||||
Bedwars: z.looseObject({
|
||||
Experience: z.number(),
|
||||
Experience: z.number().default(0),
|
||||
winstreak: z.number().optional(),
|
||||
kills_bedwars: z.number().default(0),
|
||||
deaths_bedwars: z.number().default(0),
|
||||
@@ -33,11 +33,11 @@ export const playerSchema = z.looseObject({
|
||||
time: z.number()
|
||||
}).optional()
|
||||
).optional()
|
||||
})
|
||||
),
|
||||
}).optional()
|
||||
).optional(),
|
||||
challenges: z.looseObject({
|
||||
all_time: z.record(z.string(), z.number())
|
||||
}),
|
||||
}).optional(),
|
||||
lastClaimedReward: z.number().optional(),
|
||||
rewardHighScore: z.number().optional(),
|
||||
rewardStreak: z.number().optional(),
|
||||
@@ -55,8 +55,8 @@ export const playerSchema = z.looseObject({
|
||||
HYPIXEL: z.string().optional(),
|
||||
TWITTER: z.string().optional(),
|
||||
YOUTUBE: z.string().optional()
|
||||
})
|
||||
})
|
||||
}).optional()
|
||||
}).optional()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { clsx, type ClassValue } from "clsx"
|
||||
import { type ClassValue, clsx } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user