aboutsummaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/cleaners/skyblock/member.js2
-rw-r--r--build/cleaners/skyblock/skills.js54
-rw-r--r--build/constants.js10
3 files changed, 60 insertions, 6 deletions
diff --git a/build/cleaners/skyblock/member.js b/build/cleaners/skyblock/member.js
index a9a419a..8e72be8 100644
--- a/build/cleaners/skyblock/member.js
+++ b/build/cleaners/skyblock/member.js
@@ -68,7 +68,7 @@ async function cleanSkyBlockProfileMemberResponse(member, included = null) {
fairy_souls: fairySouls,
inventories: inventoriesIncluded ? await inventory_1.cleanInventories(member) : undefined,
objectives: objectives_1.cleanObjectives(member),
- skills: skills_1.cleanSkills(member),
+ skills: await skills_1.cleanSkills(member),
visited_zones: zones_1.cleanVisitedZones(member),
collections: collections_1.cleanCollections(member),
slayers: slayers_1.cleanSlayers(member)
diff --git a/build/cleaners/skyblock/skills.js b/build/cleaners/skyblock/skills.js
index 4ec5ec2..a761ec8 100644
--- a/build/cleaners/skyblock/skills.js
+++ b/build/cleaners/skyblock/skills.js
@@ -1,15 +1,61 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
-exports.cleanSkills = void 0;
-function cleanSkills(data) {
+exports.cleanSkills = exports.levelForSkillXp = void 0;
+const constants_1 = require("../../constants");
+// the highest level you can have in each skill
+// numbers taken from https://hypixel-skyblock.fandom.com/wiki/Skills
+// maybe these should be moved to skyblock-constants?
+const skillsMaxLevel = {
+ farming: 60,
+ mining: 60,
+ combat: 60,
+ foraging: 50,
+ fishing: 50,
+ enchanting: 60,
+ alchemy: 50,
+ taming: 50,
+ dungeoneering: 50,
+ carpentry: 50,
+ runecrafting: 25,
+ social: 25
+};
+// for skills that aren't in maxSkills, default to this
+const skillsDefaultMaxLevel = 50;
+/**
+ * Get the skill level for the amount of total xp
+ * @param xp The xp we're finding the level for
+ * @param easierLevel Whether it should use the alternate leveling xp table (used for cosmetic skills and dungeoneering)
+ */
+async function levelForSkillXp(xp, maxLevel) {
+ const xpTable = maxLevel <= 25 ? await constants_1.fetchSkillXpEasier() : await constants_1.fetchSkillXp();
+ const skillLevel = [...xpTable].reverse().findIndex(levelXp => xp >= levelXp);
+ return skillLevel === -1 ? 0 : xpTable.length - skillLevel;
+}
+exports.levelForSkillXp = levelForSkillXp;
+async function cleanSkills(data) {
+ var _a;
const skills = [];
for (const item in data) {
if (item.startsWith('experience_skill_')) {
const skillName = item.substr('experience_skill_'.length);
- const skillValue = data[item];
+ // the amount of total xp you have in this skill
+ const skillXp = data[item];
+ const skillMaxLevel = (_a = skillsMaxLevel[skillName]) !== null && _a !== void 0 ? _a : skillsDefaultMaxLevel;
+ const xpTable = skillMaxLevel <= 25 ? await constants_1.fetchSkillXpEasier() : await constants_1.fetchSkillXp();
+ // the level you're at for this skill
+ const skillLevel = await levelForSkillXp(skillXp, skillMaxLevel);
+ // the total xp required for the previous level
+ const previousLevelXp = skillLevel >= 1 ? xpTable[skillLevel - 1] : 0;
+ // the extra xp left over
+ const skillLevelXp = skillXp - previousLevelXp;
+ // the amount of extra xp required for this level
+ const skillLevelXpRequired = xpTable[skillLevel] - previousLevelXp;
skills.push({
name: skillName,
- xp: skillValue
+ xp: skillXp,
+ level: skillLevel,
+ levelXp: skillLevelXp,
+ levelXpRequired: skillLevelXpRequired
});
}
}
diff --git a/build/constants.js b/build/constants.js
index c620a32..22327c5 100644
--- a/build/constants.js
+++ b/build/constants.js
@@ -25,7 +25,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
-exports.setConstantValues = exports.fetchConstantValues = exports.addMinions = exports.fetchMinions = exports.addSlayers = exports.fetchSlayers = exports.addZones = exports.fetchZones = exports.addSkills = exports.fetchSkills = exports.addCollections = exports.fetchCollections = exports.addStats = exports.fetchStats = exports.addJSONConstants = exports.fetchJSONConstant = void 0;
+exports.setConstantValues = exports.fetchConstantValues = exports.addMinions = exports.fetchSkillXpEasier = exports.fetchSkillXp = exports.fetchMinions = exports.addSlayers = exports.fetchSlayers = exports.addZones = exports.fetchZones = exports.addSkills = exports.fetchSkills = exports.addCollections = exports.fetchCollections = exports.addStats = exports.fetchStats = exports.addJSONConstants = exports.fetchJSONConstant = void 0;
// we have to do this so we can mock the function from the tests properly
const constants = __importStar(require("./constants"));
const node_cache_1 = __importDefault(require("node-cache"));
@@ -223,6 +223,14 @@ async function fetchMinions() {
return await constants.fetchJSONConstant('minions.json');
}
exports.fetchMinions = fetchMinions;
+async function fetchSkillXp() {
+ return await constants.fetchJSONConstant('manual/skill_xp.json');
+}
+exports.fetchSkillXp = fetchSkillXp;
+async function fetchSkillXpEasier() {
+ return await constants.fetchJSONConstant('manual/skill_xp_easier.json');
+}
+exports.fetchSkillXpEasier = fetchSkillXpEasier;
/** Add skills to skyblock-constants. This has caching so it's fine to call many times */
async function addMinions(addingMinions) {
await constants.addJSONConstants('minions.json', addingMinions, 'minion');