Updated stats

This commit is contained in:
2025-08-23 21:29:49 +02:00
parent 96df2a6c45
commit f876ad15fa
10 changed files with 122 additions and 45 deletions

View File

@@ -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) {

View File

@@ -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)
}