diff options
Diffstat (limited to 'build/cleaners/skyblock/minions.js')
-rw-r--r-- | build/cleaners/skyblock/minions.js | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/build/cleaners/skyblock/minions.js b/build/cleaners/skyblock/minions.js index 0543e92..fae3c96 100644 --- a/build/cleaners/skyblock/minions.js +++ b/build/cleaners/skyblock/minions.js @@ -1,15 +1,36 @@ "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.countUniqueMinions = exports.combineMinionArrays = exports.cleanMinions = void 0; const hypixel_1 = require("../../hypixel"); +const constants = __importStar(require("../../constants")); /** * Clean the minions provided by Hypixel * @param minionsRaw The minion data provided by the Hypixel API */ -function cleanMinions(data) { +async function cleanMinions(member) { var _a; const minions = []; - for (const minionRaw of (_a = data === null || data === void 0 ? void 0 : data.crafted_generators) !== null && _a !== void 0 ? _a : []) { + const processedMinionNames = new Set(); + for (const minionRaw of (_a = member === null || member === void 0 ? void 0 : member.crafted_generators) !== null && _a !== void 0 ? _a : []) { // do some regex magic to get the minion name and level // examples of potential minion names: CLAY_11, PIG_1, MAGMA_CUBE_4 const minionName = minionRaw.split(/_\d/)[0].toLowerCase(); @@ -28,8 +49,25 @@ function cleanMinions(data) { matchingMinion.levels.push(false); // set the minion at that level to true matchingMinion.levels[minionLevel - 1] = true; + processedMinionNames.add(minionName); } - return minions; + const allMinionNames = new Set(await constants.fetchMinions()); + for (const minionName of processedMinionNames) { + if (!allMinionNames.has(minionName)) { + constants.addMinions(Array.from(processedMinionNames)); + break; + } + } + for (const minionName of allMinionNames) { + if (!processedMinionNames.has(minionName)) { + processedMinionNames.add(minionName); + minions.push({ + name: minionName, + levels: new Array(hypixel_1.maxMinion).fill(false) + }); + } + } + return minions.sort((a, b) => a.name > b.name ? 1 : (a.name < b.name ? -1 : 0)); } exports.cleanMinions = cleanMinions; /** |