farming-weight
Version:
Tools for calculating farming weight and fortune in Hypixel Skyblock
77 lines • 2.47 kB
JavaScript
import { Rarity, REFORGES } from '../constants/reforges.js';
import { Stat } from '../constants/stats.js';
import { getItemProgress } from '../upgrades/progress.js';
import { getItemUpgrades, getLastItemUpgradeableTo, getNextItemUpgradeableTo } from '../upgrades/upgrades.js';
import { filterAndSortUpgrades } from '../upgrades/upgradeutils.js';
import { getRarityFromItem, previousRarity } from '../util/itemstats.js';
export class UpgradeableBase {
item;
info;
_type;
get type() {
return this._type;
}
set type(value) {
this._type = value;
}
crop;
options;
recombobulated;
rarity;
reforge;
reforgeStats;
fortune;
items;
constructor(options) {
this.item = options.item;
const info = options.items[options.item.skyblockId];
if (!info) {
throw new Error(`Unknown item: ${options.item.name} (${options.item.skyblockId})`);
}
this.info = info;
this.options = options.options;
this.items = options.items;
this.rarity = getRarityFromItem(this.item, previousRarity(this.info.maxRarity) ?? Rarity.Common);
this.reforge = REFORGES[options.item.attributes?.modifier ?? ''] ?? undefined;
this.reforgeStats = this.reforge?.tiers?.[this.rarity];
this.recombobulated = this.item.attributes?.rarity_upgrades === '1';
this.fortune = 0;
}
getFortune() {
return this.fortune;
}
getStat(stat) {
return stat === Stat.FarmingFortune ? this.getFortune() : 0;
}
getStats() {
const result = {};
for (const key of Object.values(Stat)) {
const val = this.getStat(key);
if (val > 0)
result[key] = val;
}
return result;
}
getCalculatedStats() {
if (!this.info.computedStats)
return {};
return this.info.computedStats(this.options ?? {});
}
getUpgrades(options) {
const upgrades = getItemUpgrades(this, options);
return filterAndSortUpgrades(upgrades, options);
}
getProgress(_stats, _zeroed) {
return [getItemProgress(this)];
}
getItemUpgrade() {
return this.info.upgrade;
}
getNextItemUpgrade() {
return getNextItemUpgradeableTo(this, this.items);
}
getLastItemUpgrade() {
return getLastItemUpgradeableTo(this, this.items);
}
}
//# sourceMappingURL=upgradeablebase.js.map