UNPKG

farming-weight

Version:

Tools for calculating farming weight and fortune in Hypixel Skyblock

56 lines 2.05 kB
import { Stat } from '../constants/stats.js'; import { FARMING_ACCESSORIES_INFO } from '../items/accessories.js'; import { ACCESSORY_FORTUNE_SOURCES } from '../upgrades/sources/accessorysources.js'; import { getSourceProgress } from '../upgrades/upgrades.js'; import { getPeridotFortune } from '../util/gems.js'; import { UpgradeableBase } from './upgradeable.js'; export class FarmingAccessory extends UpgradeableBase { constructor(item, options) { super({ item, options, items: FARMING_ACCESSORIES_INFO }); this.getFortune(); } getProgress(zereod = false) { return getSourceProgress(this, ACCESSORY_FORTUNE_SOURCES, zereod); } getFortune() { this.fortuneBreakdown = {}; let sum = 0; // Base fortune const base = this.info.baseStats?.[Stat.FarmingFortune] ?? 0; if (base > 0) { this.fortuneBreakdown['Base Stats'] = base; sum += base; } // Gems let peridot = 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 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); } static fakeItem(info, options) { const fake = { name: 'Fake Item', skyblockId: info.skyblockId, lore: [], attributes: {}, enchantments: {}, }; if (!FarmingAccessory.isValid(fake)) return undefined; return new FarmingAccessory(fake, options); } } //# sourceMappingURL=farmingaccessory.js.map