aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/cleaners/skyblock/stats.js2
-rw-r--r--build/database.js63
-rw-r--r--build/hypixelCached.js2
3 files changed, 47 insertions, 20 deletions
diff --git a/build/cleaners/skyblock/stats.js b/build/cleaners/skyblock/stats.js
index 4ca671b..1f72201 100644
--- a/build/cleaners/skyblock/stats.js
+++ b/build/cleaners/skyblock/stats.js
@@ -61,7 +61,7 @@ exports.statUnits = {
time: ['_best_time', '_best_time_2'],
date: ['first_join'],
coins: ['purse'],
- leaderboards: ['leaderboards_count']
+ leaderboards: ['leaderboards_count', 'top_1_leaderboards_count']
};
function getStatUnit(name) {
for (const [unitName, statMatchers] of Object.entries(exports.statUnits)) {
diff --git a/build/database.js b/build/database.js
index 6edb29b..be001ff 100644
--- a/build/database.js
+++ b/build/database.js
@@ -63,7 +63,8 @@ let accountsCollection;
const leaderboardInfos = {
highest_crit_damage: 'This leaderboard is capped at the integer limit because Hypixel, look at the <a href="/leaderboard/highest_critical_damage">highest critical damage leaderboard</a> instead.',
highest_critical_damage: 'uhhhhh yeah idk either',
- leaderboards_count: 'This leaderboard counts how many leaderboards people are in the top 100 for.',
+ leaderboards_count: 'This leaderboard counts how many leaderboards players are in the top 100 for.',
+ top_1_leaderboards_count: 'This leaderboard counts how many leaderboards players are #1 for.',
};
async function connect() {
if (!process.env.db_uri)
@@ -183,7 +184,8 @@ async function fetchAllMemberLeaderboardAttributes() {
'first_join',
'purse',
'visited_zones',
- 'leaderboards_count'
+ 'leaderboards_count',
+ 'top_1_leaderboards_count'
];
}
exports.fetchAllMemberLeaderboardAttributes = fetchAllMemberLeaderboardAttributes;
@@ -369,6 +371,7 @@ async function fetchMemberLeaderboardSpots(player, profile) {
}
exports.fetchMemberLeaderboardSpots = fetchMemberLeaderboardSpots;
async function getLeaderboardRequirement(name, leaderboardType) {
+ var _a, _b;
let leaderboard;
if (leaderboardType === 'member')
leaderboard = await fetchMemberLeaderboardRaw(name);
@@ -376,47 +379,71 @@ async function getLeaderboardRequirement(name, leaderboardType) {
leaderboard = await fetchProfileLeaderboardRaw(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].value;
+ return {
+ top_100: leaderboard[leaderboardMax - 1].value,
+ top_1: leaderboard[1].value
+ };
+ else if (leaderboard.length >= 1)
+ return {
+ top_100: null,
+ top_1: (_b = (_a = leaderboard[1]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : null
+ };
else
- return null;
+ return {
+ top_100: null,
+ top_1: null
+ };
}
/** Get the attributes for the member, but only ones that would put them on the top 100 for leaderboards */
async function getApplicableMemberLeaderboardAttributes(member) {
const leaderboardAttributes = getMemberLeaderboardAttributes(member);
const applicableAttributes = {};
+ const applicableTop1Attributes = {};
for (const [leaderboard, attributeValue] of Object.entries(leaderboardAttributes)) {
const requirement = await getLeaderboardRequirement(leaderboard, 'member');
const leaderboardReversed = isLeaderboardReversed(leaderboard);
- if ((requirement === null)
- || (leaderboardReversed ? attributeValue < requirement : attributeValue > requirement)) {
+ if ((requirement.top_100 === null)
+ || (leaderboardReversed ? attributeValue < requirement.top_100 : attributeValue > requirement.top_100)) {
applicableAttributes[leaderboard] = attributeValue;
}
+ if ((requirement.top_1 === null)
+ || (leaderboardReversed ? attributeValue < requirement.top_1 : attributeValue > requirement.top_1)) {
+ applicableTop1Attributes[leaderboard] = attributeValue;
+ }
}
- let leaderboardsCount = Object.keys(applicableAttributes).length;
+ // add the "leaderboards count" attribute
+ const leaderboardsCount = Object.keys(applicableAttributes).length;
const leaderboardsCountRequirement = await getLeaderboardRequirement('leaderboards_count', 'member');
- if ((leaderboardsCountRequirement === null)
- || (leaderboardsCount > leaderboardsCountRequirement)) {
+ if ((leaderboardsCountRequirement.top_100 === null)
+ || (leaderboardsCount > leaderboardsCountRequirement.top_100))
applicableAttributes['leaderboards_count'] = leaderboardsCount;
- }
+ // add the "first leaderboards count" attribute
+ const top1LeaderboardsCount = Object.keys(applicableTop1Attributes).length;
+ const top1LeaderboardsCountRequirement = await getLeaderboardRequirement('top_1_leaderboards_count', 'member');
+ if ((top1LeaderboardsCountRequirement.top_100 === null)
+ || (top1LeaderboardsCount > top1LeaderboardsCountRequirement.top_100))
+ applicableAttributes['top_1_leaderboards_count'] = top1LeaderboardsCount;
+ console.log('top_1_leaderboards_count', applicableTop1Attributes, top1LeaderboardsCount, 'requirement', top1LeaderboardsCountRequirement);
return applicableAttributes;
}
/** Get the attributes for the profile, but only ones that would put them on the top 100 for leaderboards */
async function getApplicableProfileLeaderboardAttributes(profile) {
const leaderboardAttributes = getProfileLeaderboardAttributes(profile);
const applicableAttributes = {};
+ const applicableTop1Attributes = {};
for (const [leaderboard, attributeValue] of Object.entries(leaderboardAttributes)) {
const requirement = await getLeaderboardRequirement(leaderboard, 'profile');
const leaderboardReversed = isLeaderboardReversed(leaderboard);
- if ((requirement === null)
- || (leaderboardReversed ? attributeValue < requirement : attributeValue > requirement)) {
+ if ((requirement.top_100 === null)
+ || (leaderboardReversed ? attributeValue < requirement.top_100 : attributeValue > requirement.top_100
+ && attributeValue !== 0)) {
applicableAttributes[leaderboard] = attributeValue;
}
- }
- let leaderboardsCount = Object.keys(applicableAttributes).length;
- const leaderboardsCountRequirement = await getLeaderboardRequirement('leaderboards_count', 'member');
- if (leaderboardsCountRequirement === null
- || leaderboardsCount > leaderboardsCountRequirement) {
- applicableAttributes['leaderboards_count'] = leaderboardsCount;
+ if ((requirement.top_1 === null)
+ || (leaderboardReversed ? attributeValue < requirement.top_1 : attributeValue > requirement.top_1
+ && attributeValue !== 0)) {
+ applicableTop1Attributes[leaderboard] = attributeValue;
+ }
}
return applicableAttributes;
}
diff --git a/build/hypixelCached.js b/build/hypixelCached.js
index 4b048e8..b03361f 100644
--- a/build/hypixelCached.js
+++ b/build/hypixelCached.js
@@ -190,7 +190,7 @@ async function fetchBasicPlayer(user) {
return exports.basicPlayerCache.get(playerUuid);
const player = await fetchPlayer(playerUuid);
if (!player) {
- console.debug('no player? this should never happen', user, playerUuid);
+ console.debug('no player? this should never happen, perhaps the uuid is invalid or the player hasn\'t played hypixel', playerUuid);
return null;
}
delete player.profiles;