aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/database.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/database.ts b/src/database.ts
index cfa95ac..9e81f5b 100644
--- a/src/database.ts
+++ b/src/database.ts
@@ -224,6 +224,7 @@ export async function fetchMemberLeaderboardSpots(player: string, profile: strin
async function getMemberLeaderboardRequirement(name: string): Promise<number> {
const leaderboard = await fetchMemberLeaderboardRaw(name)
+
// if there's more than 100 items, return the 100th. if there's less, return null
if (leaderboard.length >= leaderboardMax)
return leaderboard[leaderboardMax - 1].stats[name]
@@ -238,8 +239,12 @@ async function getApplicableAttributes(member: CleanMember): Promise<StringNumbe
for (const [ leaderboard, attributeValue ] of Object.entries(leaderboardAttributes)) {
const requirement = await getMemberLeaderboardRequirement(leaderboard)
const leaderboardReversed = isLeaderboardReversed(leaderboard)
- if (!requirement || leaderboardReversed ? attributeValue < requirement : attributeValue > requirement)
+ if (
+ (requirement === null)
+ || (leaderboardReversed ? attributeValue < requirement : attributeValue > requirement)
+ ) {
applicableAttributes[leaderboard] = attributeValue
+ }
}
return applicableAttributes
}