diff options
author | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-13 20:11:53 -0600 |
---|---|---|
committer | mat <27899617+mat-1@users.noreply.github.com> | 2021-02-13 20:11:53 -0600 |
commit | cd707234194b41df933a3a287b5fbec3657063d5 (patch) | |
tree | 22115a93afcba5b268fbeb9d69b7e1fa8ed95fa6 /build/cleaners | |
parent | 9b2856303374521b315759500cf594ec7f22d293 (diff) | |
download | skyblock-api-cd707234194b41df933a3a287b5fbec3657063d5.tar.gz skyblock-api-cd707234194b41df933a3a287b5fbec3657063d5.tar.bz2 skyblock-api-cd707234194b41df933a3a287b5fbec3657063d5.zip |
add objectives and skills
Diffstat (limited to 'build/cleaners')
-rw-r--r-- | build/cleaners/skyblock/bank.js | 5 | ||||
-rw-r--r-- | build/cleaners/skyblock/member.js | 21 | ||||
-rw-r--r-- | build/cleaners/skyblock/objectives.js | 16 | ||||
-rw-r--r-- | build/cleaners/skyblock/profile.js | 2 | ||||
-rw-r--r-- | build/cleaners/skyblock/skills.js | 18 | ||||
-rw-r--r-- | build/cleaners/skyblock/stats.js | 9 |
6 files changed, 59 insertions, 12 deletions
diff --git a/build/cleaners/skyblock/bank.js b/build/cleaners/skyblock/bank.js index a3db577..9836685 100644 --- a/build/cleaners/skyblock/bank.js +++ b/build/cleaners/skyblock/bank.js @@ -2,11 +2,12 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.cleanBank = void 0; function cleanBank(data) { - var _a, _b, _c, _d; + var _a, _b; return { balance: (_b = (_a = data === null || data === void 0 ? void 0 : data.banking) === null || _a === void 0 ? void 0 : _a.balance) !== null && _b !== void 0 ? _b : 0, // TODO: make transactions good - history: (_d = (_c = data === null || data === void 0 ? void 0 : data.banking) === null || _c === void 0 ? void 0 : _c.transactions) !== null && _d !== void 0 ? _d : [] + // history: data?.banking?.transactions ?? [] + history: [] }; } exports.cleanBank = cleanBank; diff --git a/build/cleaners/skyblock/member.js b/build/cleaners/skyblock/member.js index 4cd0425..9d10a5e 100644 --- a/build/cleaners/skyblock/member.js +++ b/build/cleaners/skyblock/member.js @@ -19,27 +19,36 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.cleanSkyBlockProfileMemberResponse = void 0; +exports.cleanSkyBlockProfileMemberResponse = exports.cleanSkyBlockProfileMemberResponseBasic = void 0; const cached = __importStar(require("../../hypixelCached")); const fairysouls_1 = require("./fairysouls"); const inventory_1 = require("./inventory"); const minions_1 = require("./minions"); +const objectives_1 = require("./objectives"); const stats_1 = require("./stats"); +async function cleanSkyBlockProfileMemberResponseBasic(member, included = null) { + return { + uuid: member.uuid, + username: await cached.usernameFromUser(member.uuid), + last_save: member.last_save, + first_join: member.first_join, + }; +} +exports.cleanSkyBlockProfileMemberResponseBasic = cleanSkyBlockProfileMemberResponseBasic; /** Cleans up a member (from skyblock/profile) */ async function cleanSkyBlockProfileMemberResponse(member, included = null) { // profiles.members[] - const statsIncluded = included == null || included.includes('stats'); const inventoriesIncluded = included == null || included.includes('inventories'); return { uuid: member.uuid, username: await cached.usernameFromUser(member.uuid), last_save: member.last_save, first_join: member.first_join, - // last_death: ??? idk how this is formatted, - stats: statsIncluded ? stats_1.cleanProfileStats(member === null || member === void 0 ? void 0 : member.stats) : undefined, - minions: statsIncluded ? minions_1.cleanMinions(member) : undefined, - fairy_souls: statsIncluded ? fairysouls_1.cleanFairySouls(member) : undefined, + stats: stats_1.cleanProfileStats(member), + minions: minions_1.cleanMinions(member), + fairy_souls: fairysouls_1.cleanFairySouls(member), inventories: inventoriesIncluded ? await inventory_1.cleanInventories(member) : undefined, + objectives: objectives_1.cleanObjectives(member), }; } exports.cleanSkyBlockProfileMemberResponse = cleanSkyBlockProfileMemberResponse; diff --git a/build/cleaners/skyblock/objectives.js b/build/cleaners/skyblock/objectives.js new file mode 100644 index 0000000..d45307c --- /dev/null +++ b/build/cleaners/skyblock/objectives.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.cleanObjectives = void 0; +function cleanObjectives(data) { + const rawObjectives = (data === null || data === void 0 ? void 0 : data.objectives) || {}; + const objectives = []; + for (const rawObjectiveName in rawObjectives) { + const rawObjectiveValue = rawObjectives[rawObjectiveName]; + objectives.push({ + name: rawObjectiveName, + completed: rawObjectiveValue.status === 'COMPLETE', + }); + } + return objectives; +} +exports.cleanObjectives = cleanObjectives; diff --git a/build/cleaners/skyblock/profile.js b/build/cleaners/skyblock/profile.js index 7ef57ef..2b18ff8 100644 --- a/build/cleaners/skyblock/profile.js +++ b/build/cleaners/skyblock/profile.js @@ -12,7 +12,7 @@ async function cleanSkyblockProfileResponseLighter(data) { const memberRaw = data.members[memberUUID]; memberRaw.uuid = memberUUID; // we pass an empty array to make it not check stats - promises.push(member_1.cleanSkyBlockProfileMemberResponse(memberRaw, [])); + promises.push(member_1.cleanSkyBlockProfileMemberResponseBasic(memberRaw)); } const cleanedMembers = await Promise.all(promises); return { diff --git a/build/cleaners/skyblock/skills.js b/build/cleaners/skyblock/skills.js new file mode 100644 index 0000000..4ec5ec2 --- /dev/null +++ b/build/cleaners/skyblock/skills.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.cleanSkills = void 0; +function cleanSkills(data) { + const skills = []; + for (const item in data) { + if (item.startsWith('experience_skill_')) { + const skillName = item.substr('experience_skill_'.length); + const skillValue = data[item]; + skills.push({ + name: skillName, + xp: skillValue + }); + } + } + return skills; +} +exports.cleanSkills = cleanSkills; diff --git a/build/cleaners/skyblock/stats.js b/build/cleaners/skyblock/stats.js index aa026db..80686c1 100644 --- a/build/cleaners/skyblock/stats.js +++ b/build/cleaners/skyblock/stats.js @@ -52,14 +52,17 @@ function categorizeStat(statNameRaw) { name: statNameRaw }; } -function cleanProfileStats(statsRaw) { +function cleanProfileStats(data) { + var _a; // TODO: add type for statsRaw (probably in hypixelApi.ts since its coming from there) const stats = {}; - for (let statNameRaw in statsRaw) { + const rawStats = (_a = data === null || data === void 0 ? void 0 : data.stats) !== null && _a !== void 0 ? _a : {}; + for (const statNameRaw in rawStats) { + const statValue = rawStats[statNameRaw]; let { category: statCategory, name: statName } = categorizeStat(statNameRaw); if (!stats[statCategory]) stats[statCategory] = {}; - stats[statCategory][statName || 'total'] = statsRaw[statNameRaw]; + stats[statCategory][statName || 'total'] = statValue; } return stats; } |