aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <27899617+mat-1@users.noreply.github.com>2021-03-01 20:42:40 -0600
committermat <27899617+mat-1@users.noreply.github.com>2021-03-01 20:42:40 -0600
commit36167af958d472b936d5c575662ef37cbd6f8448 (patch)
tree6186ed577c182636210149922a93cfaf539a53d7
parent7a486de4e902faa3bad201e83434e008cb3714b7 (diff)
downloadskyblock-api-36167af958d472b936d5c575662ef37cbd6f8448.tar.gz
skyblock-api-36167af958d472b936d5c575662ef37cbd6f8448.tar.bz2
skyblock-api-36167af958d472b936d5c575662ef37cbd6f8448.zip
fix members not being added to reverse leaderboards
-rw-r--r--build/database.js9
-rw-r--r--src/database.ts9
2 files changed, 10 insertions, 8 deletions
diff --git a/build/database.js b/build/database.js
index 08bbb22..c3f2518 100644
--- a/build/database.js
+++ b/build/database.js
@@ -194,10 +194,11 @@ async function getMemberLeaderboardRequirement(name) {
async function getApplicableAttributes(member) {
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;
}
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
}