diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-03-01 20:42:40 -0600 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-03-01 20:42:40 -0600 |
commit | 36167af958d472b936d5c575662ef37cbd6f8448 (patch) | |
tree | 6186ed577c182636210149922a93cfaf539a53d7 /src/database.ts | |
parent | 7a486de4e902faa3bad201e83434e008cb3714b7 (diff) | |
download | skyblock-api-36167af958d472b936d5c575662ef37cbd6f8448.tar.gz skyblock-api-36167af958d472b936d5c575662ef37cbd6f8448.tar.bz2 skyblock-api-36167af958d472b936d5c575662ef37cbd6f8448.zip |
fix members not being added to reverse leaderboards
Diffstat (limited to 'src/database.ts')
-rw-r--r-- | src/database.ts | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/database.ts b/src/database.ts index 0ed8c7c..4e8b9c2 100644 --- a/src/database.ts +++ b/src/database.ts @@ -213,10 +213,11 @@ async function getMemberLeaderboardRequirement(name: string): Promise<number> { async function getApplicableAttributes(member): Promise<{ [key: string]: number }> { const leaderboardAttributes = getMemberLeaderboardAttributes(member) const applicableAttributes = {} - for (const [ attributeName, attributeValue ] of Object.entries(leaderboardAttributes)) { - const requirement = await getMemberLeaderboardRequirement(attributeName) - if (!requirement || attributeValue > requirement) - applicableAttributes[attributeName] = attributeValue + for (const [ leaderboard, attributeValue ] of Object.entries(leaderboardAttributes)) { + const requirement = await getMemberLeaderboardRequirement(leaderboard) + const leaderboardReversed = isLeaderboardReversed(leaderboard) + if (!requirement || leaderboardReversed ? attributeValue < requirement : attributeValue > requirement) + applicableAttributes[leaderboard] = attributeValue } return applicableAttributes } |