diff options
Diffstat (limited to 'build/cleaners/skyblock/minions.js')
-rw-r--r-- | build/cleaners/skyblock/minions.js | 42 |
1 files changed, 8 insertions, 34 deletions
diff --git a/build/cleaners/skyblock/minions.js b/build/cleaners/skyblock/minions.js index d2bfc41..5c0bd9a 100644 --- a/build/cleaners/skyblock/minions.js +++ b/build/cleaners/skyblock/minions.js @@ -1,36 +1,13 @@ -"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")); +import { maxMinion } from '../../hypixel.js'; +import * as constants from '../../constants.js'; /** * Clean the minions provided by Hypixel * @param minionsRaw The minion data provided by the Hypixel API */ -async function cleanMinions(member) { - var _a; +export async function cleanMinions(member) { const minions = []; const processedMinionNames = new Set(); - for (const minionRaw of (_a = member === null || member === void 0 ? void 0 : member.crafted_generators) !== null && _a !== void 0 ? _a : []) { + for (const minionRaw of member?.crafted_generators ?? []) { // 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(); @@ -40,7 +17,7 @@ async function cleanMinions(member) { // if the minion doesnt already exist in the minions array, then create it matchingMinion = { name: minionName, - levels: new Array(hypixel_1.maxMinion).fill(false) + levels: new Array(maxMinion).fill(false) }; minions.push(matchingMinion); } @@ -63,18 +40,17 @@ async function cleanMinions(member) { processedMinionNames.add(minionName); minions.push({ name: minionName, - levels: new Array(hypixel_1.maxMinion).fill(false) + levels: new Array(maxMinion).fill(false) }); } } return minions.sort((a, b) => a.name > b.name ? 1 : (a.name < b.name ? -1 : 0)); } -exports.cleanMinions = cleanMinions; /** * Combine multiple arrays of minions into one, useful when getting the minions for members * @param minions An array of arrays of minions */ -function combineMinionArrays(minions) { +export function combineMinionArrays(minions) { const resultMinions = []; for (const memberMinions of minions) { for (const minion of memberMinions) { @@ -99,8 +75,7 @@ function combineMinionArrays(minions) { } return resultMinions; } -exports.combineMinionArrays = combineMinionArrays; -function countUniqueMinions(minions) { +export function countUniqueMinions(minions) { let uniqueMinions = 0; for (const minion of minions) { // find the number of times `true` is in the list and add it to uniqueMinions @@ -108,4 +83,3 @@ function countUniqueMinions(minions) { } return uniqueMinions; } -exports.countUniqueMinions = countUniqueMinions; |