Updated stats
This commit is contained in:
@@ -6,9 +6,16 @@ export function getGuildMember(guild: Guild["guild"], uuid: string) {
|
||||
|
||||
export function getGuildRankTag(guild: Guild["guild"], uuid: string) {
|
||||
const member = getGuildMember(guild, uuid)
|
||||
return member?.rank === "Guild Master"
|
||||
? "[GM]"
|
||||
: `[${guild.ranks.find(r => r.name === member?.rank)?.tag}]`
|
||||
|
||||
if (member?.rank === "Guild Master") return "[GM]"
|
||||
|
||||
const rank = guild.ranks.find(r => r.name === member?.rank)?.tag
|
||||
|
||||
if (rank == null) {
|
||||
return ""
|
||||
} else {
|
||||
return `[${rank}]`
|
||||
}
|
||||
}
|
||||
|
||||
export function getMemberGEXP(guild: Guild["guild"], uuid: string, days: number = 0) {
|
||||
|
||||
@@ -15,7 +15,11 @@ export function getCoinMultiplier(level: number) {
|
||||
return MULTIPLIER[0].value
|
||||
}
|
||||
|
||||
export function getTotalCoins(stats: Record<string, Record<"coins", number | undefined>>) {
|
||||
export function getTotalCoins(stats: Record<string, Record<"coins", number | undefined>> | undefined) {
|
||||
if (!stats) {
|
||||
return 0
|
||||
}
|
||||
|
||||
return Object.values(stats).reduce((total, stat) => total + (stat.coins || 0), 0)
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export const playerSchema = z.looseObject({
|
||||
stats: z.looseObject({
|
||||
Bedwars: bedwarsStatsSchema.optional(),
|
||||
SkyWars: skywarsStatsSchema.optional()
|
||||
}),
|
||||
}).optional(),
|
||||
quests: z.record(
|
||||
z.string(),
|
||||
z.looseObject({
|
||||
@@ -47,8 +47,10 @@ export const playerSchema = z.looseObject({
|
||||
TWITTER: z.string().optional(),
|
||||
YOUTUBE: z.string().optional()
|
||||
}).optional()
|
||||
}).optional()
|
||||
}).optional(),
|
||||
rank: z.string().optional()
|
||||
})
|
||||
})
|
||||
|
||||
export type Player = z.infer<typeof playerSchema>
|
||||
export type NonNullStats = NonNullable<Player["player"]["stats"]>
|
||||
|
||||
Reference in New Issue
Block a user