farming-weight
Version:
Tools for calculating farming weight and fortune in Hypixel Skyblock
55 lines (54 loc) • 1.69 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
exports.FarmingAccessory = void 0;
const ACCESSORIES_1 = require('../constants/accessories');
const REFORGES_1 = require('../constants/reforges');
const GEMS_1 = require('../util/gems');
const ITEMSTATS_1 = require('../util/itemstats');
class FarmingAccessory {
item;
info;
constructor(item) {
this.item = item;
const INFO = ACCESSORIES_1.FARMING_ACCESSORIES_INFO[item.skyblockId];
if (!INFO) {
throw new Error(`Unknown lotus gear: ${item.name} (${item.skyblockId})`);
}
this.info = INFO;
if (item.lore) {
this.rarity = (0, ITEMSTATS_1.getRarityFromLore)(item.lore);
}
this.recombobulated = this.item.attributes?.rarity_upgrades === '1';
this.sumFortune();
}
sumFortune() {
this.fortuneBreakdown = {};
let SUM = 0;
// Base fortune
const BASE = this.info.stats?.[REFORGES_1.Stat.FarmingFortune] ?? 0;
if (BASE > 0) {
this.fortuneBreakdown['Base Stats'] = BASE;
SUM += BASE;
}
// Gems
let PERIDOT = (0, GEMS_1.getPeridotFortune)(this.rarity, this.item);
if (PERIDOT > 0) {
PERIDOT = +(PERIDOT / 2).toFixed(2); // Only half the fortune is applied on accessories
this.fortuneBreakdown['Peridot Gems'] = PERIDOT;
SUM += PERIDOT;
}
this.fortune = SUM;
return SUM;
}
static isValid(item) {
return ACCESSORIES_1.FARMING_ACCESSORIES_INFO[item.skyblockId] !== undefined;
}
static fromArray(items) {
return items
.filter((item) => FarmingAccessory.isValid(item))
.map((item) => new FarmingAccessory(item))
.sort((a, b) => b.fortune - a.fortune);
}
}
exports.FarmingAccessory = FarmingAccessory;
//# sourceMappingURL=farmingaccessory.js.map