Fixed bug
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { MULTIPLIER, RANKMULTIPLIER } from "@/data/hypixel/general"
|
||||
import { Player } from "@/lib/schema/player"
|
||||
import z from "zod"
|
||||
|
||||
type ReturnType = {
|
||||
level: true
|
||||
@@ -66,12 +67,23 @@ export function getCoinMultiplier(level: number, rank?: string, specialRank?: st
|
||||
}
|
||||
}
|
||||
|
||||
export function getTotalCoins(stats: Record<string, Record<"coins", number | undefined>> | undefined) {
|
||||
const coinsSchema = z.record(
|
||||
z.string(),
|
||||
z.object({
|
||||
coins: z.number().optional()
|
||||
})
|
||||
)
|
||||
|
||||
export function getTotalCoins(stats: Player["player"]["stats"]) {
|
||||
if (!stats) {
|
||||
return 0
|
||||
}
|
||||
|
||||
return Object.values(stats).reduce((total, stat) => total + (stat.coins || 0), 0)
|
||||
const { data } = coinsSchema.safeParse(stats)
|
||||
|
||||
if (!data) return 0
|
||||
|
||||
return Object.values(data).reduce((total, stat) => total + (stat.coins || 0), 0)
|
||||
}
|
||||
|
||||
export function getTotalQuests(quests: Player["player"]["quests"]) {
|
||||
|
||||
Reference in New Issue
Block a user