Updated sidebar to be ok like fr
This commit is contained in:
@@ -1,18 +1,69 @@
|
||||
import { MULTIPLIER } from "@/data/hypixel/general"
|
||||
import { MULTIPLIER, RANKMULTIPLIER } from "@/data/hypixel/general"
|
||||
import { Player } from "@/lib/schema/player"
|
||||
|
||||
export function getCoinMultiplier(level: number) {
|
||||
type ReturnType = {
|
||||
level: true
|
||||
value: number
|
||||
} | {
|
||||
level: false
|
||||
value: number
|
||||
name: string
|
||||
}
|
||||
|
||||
export function getCoinMultiplier(level: number, rank?: string, specialRank?: string, eulaCoins?: boolean): ReturnType {
|
||||
if (level > MULTIPLIER[MULTIPLIER.length - 1].level) {
|
||||
return MULTIPLIER[MULTIPLIER.length - 1].value
|
||||
return {
|
||||
value: MULTIPLIER.at(-1)!.value,
|
||||
level: true
|
||||
} as const
|
||||
}
|
||||
|
||||
for (let i = MULTIPLIER.length - 1; i >= 0; i--) {
|
||||
if (level >= MULTIPLIER[i].level) {
|
||||
return MULTIPLIER[i].value
|
||||
function getLevelMultiplier() {
|
||||
for (let i = MULTIPLIER.length - 1; i >= 0; i--) {
|
||||
if (level >= MULTIPLIER[i].level) {
|
||||
return {
|
||||
value: MULTIPLIER.at(i)!.value,
|
||||
level: true
|
||||
} as const
|
||||
}
|
||||
}
|
||||
return {
|
||||
value: MULTIPLIER.at(0)!.value,
|
||||
level: true
|
||||
} as const
|
||||
}
|
||||
|
||||
function getSpecialMultiplier() {
|
||||
if (specialRank === "YOUTUBER") return RANKMULTIPLIER.YOUTUBER
|
||||
if (!eulaCoins) return null
|
||||
switch (rank) {
|
||||
case "VIP":
|
||||
return RANKMULTIPLIER.VIP
|
||||
case "VIP_PLUS":
|
||||
return RANKMULTIPLIER.VIP_PLUS
|
||||
case "MVP":
|
||||
return RANKMULTIPLIER.MVP
|
||||
case "MVP_PLUS":
|
||||
return RANKMULTIPLIER.MVP_PLUS
|
||||
default:
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return MULTIPLIER[0].value
|
||||
const specialMulti = getSpecialMultiplier()
|
||||
const levelMulti = getLevelMultiplier()
|
||||
|
||||
if (!specialMulti) {
|
||||
return levelMulti
|
||||
}
|
||||
|
||||
const max = Math.max(specialMulti.value, levelMulti.value)
|
||||
|
||||
if (max === specialMulti.value) {
|
||||
return { ...specialMulti, level: false }
|
||||
} else {
|
||||
return levelMulti
|
||||
}
|
||||
}
|
||||
|
||||
export function getTotalCoins(stats: Record<string, Record<"coins", number | undefined>> | undefined) {
|
||||
|
||||
@@ -48,7 +48,8 @@ export const playerSchema = z.looseObject({
|
||||
YOUTUBE: z.string().optional()
|
||||
}).optional()
|
||||
}).optional(),
|
||||
rank: z.string().optional()
|
||||
rank: z.string().optional(),
|
||||
eulaCoins: z.boolean().optional()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user