aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
}