aboutsummaryrefslogtreecommitdiff
path: root/build/cleaners/skyblock
diff options
context:
space:
mode:
Diffstat (limited to 'build/cleaners/skyblock')
-rw-r--r--build/cleaners/skyblock/member.js12
-rw-r--r--build/cleaners/skyblock/profiles.js4
-rw-r--r--build/cleaners/skyblock/slayers.js53
3 files changed, 64 insertions, 5 deletions
diff --git a/build/cleaners/skyblock/member.js b/build/cleaners/skyblock/member.js
index 41092e1..0f2e048 100644
--- a/build/cleaners/skyblock/member.js
+++ b/build/cleaners/skyblock/member.js
@@ -29,12 +29,15 @@ const skills_1 = require("./skills");
const cached = __importStar(require("../../hypixelCached"));
const zones_1 = require("./zones");
const collections_1 = require("./collections");
+const slayers_1 = require("./slayers");
async function cleanSkyBlockProfileMemberResponseBasic(member, included = null) {
+ const player = await cached.fetchPlayer(member.uuid);
return {
uuid: member.uuid,
- username: await cached.usernameFromUser(member.uuid),
+ username: player.username,
last_save: member.last_save,
first_join: member.first_join,
+ rank: player.rank
};
}
exports.cleanSkyBlockProfileMemberResponseBasic = cleanSkyBlockProfileMemberResponseBasic;
@@ -42,11 +45,13 @@ exports.cleanSkyBlockProfileMemberResponseBasic = cleanSkyBlockProfileMemberResp
async function cleanSkyBlockProfileMemberResponse(member, included = null) {
// profiles.members[]
const inventoriesIncluded = included == null || included.includes('inventories');
+ const player = await cached.fetchPlayer(member.uuid);
return {
uuid: member.uuid,
- username: await cached.usernameFromUser(member.uuid),
+ username: player.username,
last_save: member.last_save,
first_join: member.first_join,
+ rank: player.rank,
purse: member.coin_purse,
stats: stats_1.cleanProfileStats(member),
minions: minions_1.cleanMinions(member),
@@ -55,7 +60,8 @@ async function cleanSkyBlockProfileMemberResponse(member, included = null) {
objectives: objectives_1.cleanObjectives(member),
skills: skills_1.cleanSkills(member),
visited_zones: zones_1.cleanVisitedZones(member),
- collections: collections_1.cleanCollections(member)
+ collections: collections_1.cleanCollections(member),
+ slayers: slayers_1.cleanSlayers(member)
};
}
exports.cleanSkyBlockProfileMemberResponse = cleanSkyBlockProfileMemberResponse;
diff --git a/build/cleaners/skyblock/profiles.js b/build/cleaners/skyblock/profiles.js
index b79fc56..1996d55 100644
--- a/build/cleaners/skyblock/profiles.js
+++ b/build/cleaners/skyblock/profiles.js
@@ -4,7 +4,7 @@ exports.cleanSkyblockProfilesResponse = exports.cleanPlayerSkyblockProfiles = vo
const profile_1 = require("./profile");
function cleanPlayerSkyblockProfiles(rawProfiles) {
let profiles = [];
- for (const profile of Object.values(rawProfiles)) {
+ for (const profile of Object.values(rawProfiles !== null && rawProfiles !== void 0 ? rawProfiles : {})) {
profiles.push({
uuid: profile.profile_id,
name: profile.cute_name
@@ -17,7 +17,7 @@ exports.cleanPlayerSkyblockProfiles = cleanPlayerSkyblockProfiles;
/** Convert an array of raw profiles into clean profiles */
async function cleanSkyblockProfilesResponse(data) {
const cleanedProfiles = [];
- for (const profile of data) {
+ for (const profile of data !== null && data !== void 0 ? data : []) {
let cleanedProfile = await profile_1.cleanSkyblockProfileResponseLighter(profile);
cleanedProfiles.push(cleanedProfile);
}
diff --git a/build/cleaners/skyblock/slayers.js b/build/cleaners/skyblock/slayers.js
new file mode 100644
index 0000000..d2b9dbe
--- /dev/null
+++ b/build/cleaners/skyblock/slayers.js
@@ -0,0 +1,53 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+exports.cleanSlayers = void 0;
+const slayerLevels = 4; // number of slayer levels, this might be 5 soon
+const SLAYER_NAMES = {
+ spider: 'tarantula',
+ zombie: 'revenant',
+ wolf: 'sven'
+};
+function cleanSlayers(data) {
+ const slayers = [];
+ const slayersDataRaw = data === null || data === void 0 ? void 0 : data.slayer_bosses;
+ let totalXp = 0;
+ for (const slayerNameRaw in slayersDataRaw) {
+ const slayerDataRaw = slayersDataRaw[slayerNameRaw];
+ // convert name provided by api (spider) to the real name (tarantula)
+ const slayerName = SLAYER_NAMES[slayerDataRaw];
+ const slayerXp = slayerDataRaw.xp;
+ const slayerTiers = [];
+ for (const slayerDataKey in slayerDataRaw) {
+ // if a key starts with boss_kills_tier_ (boss_kills_tier_1), get the last number
+ if (slayerDataKey.startsWith('boss_kills_tier_')) {
+ const slayerTierRaw = parseInt(slayerDataKey.substr('boss_kills_tier_'.length));
+ const slayerTierKills = slayerDataRaw[slayerDataKey];
+ // add 1 since hypixel is using 0 indexed tiers
+ const slayerTier = slayerTierRaw + 1;
+ slayerTiers.push({
+ kills: slayerTierKills,
+ tier: slayerTier
+ });
+ }
+ }
+ // if the slayer tier length is less than the max, add more empty ones
+ while (slayerTiers.length < slayerLevels)
+ slayerTiers.push({
+ tier: slayerTiers.length + 1,
+ kills: 0
+ });
+ const slayer = {
+ name: slayerName,
+ tiers: slayerTiers,
+ xp: slayerXp
+ };
+ slayers.push(slayer);
+ // add the xp from this slayer to the total xp
+ totalXp += slayerXp;
+ }
+ return {
+ xp: totalXp,
+ bosses: slayers
+ };
+}
+exports.cleanSlayers = cleanSlayers;