UNPKG

farming-weight

Version:

Tools for calculating farming weight and fortune in Hypixel Skyblock

177 lines 5.43 kB
import { Crop } from '../constants/crops.js'; import { RARITY_COLORS } from '../constants/reforges.js'; import { SpecialCrop } from '../constants/specialcrops.js'; import { ComposterUpgrade } from '../features/composter/composter.js'; export function getCropDisplayName(crop) { return (crop ? cropDisplayNames[crop] : null) ?? 'Unknown Crop'; } export function getSpecialCropDisplayName(crop) { return specialCropToName[crop] ?? 'Unknown Special Crop'; } export function getComposterUpgradeDisplayName(upgrade) { return upgradeTypeToName[upgrade] ?? 'Unknown Upgrade'; } export function getCropFromName(name) { const fromDisplay = displayNamesToCrop[name]; if (fromDisplay) return fromDisplay; const fromShort = shortNamesToCrop[name]; if (fromShort) return fromShort; const fromFull = fullNamesToCrop[name.toLowerCase().replace(/ /g, '')]; if (fromFull) return fromFull; return getCropFromItemId(name); } export function getCropFromItemId(itemId) { return cropItemIds[itemId]; } export function getCropFromContestKey(contestKey) { const split = contestKey.split(':'); if (!split.length) return undefined; const crop = split.at(-1); if (!crop) return undefined; if (crop === '3') return Crop.CocoaBeans; return cropItemIds[crop]; } export function getItemIdFromCrop(crop) { return itemIdsToCrop[crop]; } export function getRarityColor(rarity) { return RARITY_COLORS[rarity]; } const cropDisplayNames = { [Crop.Cactus]: 'Cactus', [Crop.Carrot]: 'Carrot', [Crop.CocoaBeans]: 'Cocoa Beans', [Crop.Melon]: 'Melon', [Crop.Mushroom]: 'Mushroom', [Crop.NetherWart]: 'Nether Wart', [Crop.Potato]: 'Potato', [Crop.Pumpkin]: 'Pumpkin', [Crop.SugarCane]: 'Sugar Cane', [Crop.Wheat]: 'Wheat', [Crop.Seeds]: 'Seeds', [Crop.Sunflower]: 'Sunflower', [Crop.Moonflower]: 'Moonflower', [Crop.WildRose]: 'Wild Rose', }; const displayNamesToCrop = { Cactus: Crop.Cactus, Carrot: Crop.Carrot, 'Cocoa Beans': Crop.CocoaBeans, Melon: Crop.Melon, Mushroom: Crop.Mushroom, 'Nether Wart': Crop.NetherWart, Potato: Crop.Potato, Pumpkin: Crop.Pumpkin, 'Sugar Cane': Crop.SugarCane, Wheat: Crop.Wheat, Seeds: Crop.Seeds, Sunflower: Crop.Sunflower, Moonflower: Crop.Moonflower, 'Wild Rose': Crop.WildRose, }; const shortNamesToCrop = { cactus: Crop.Cactus, carrot: Crop.Carrot, cocoa: Crop.CocoaBeans, melon: Crop.Melon, mushroom: Crop.Mushroom, wart: Crop.NetherWart, potato: Crop.Potato, pumpkin: Crop.Pumpkin, cane: Crop.SugarCane, wheat: Crop.Wheat, seeds: Crop.Seeds, sunflower: Crop.Sunflower, moonflower: Crop.Moonflower, wildrose: Crop.WildRose, }; const fullNamesToCrop = { cactus: Crop.Cactus, carrot: Crop.Carrot, cocoabeans: Crop.CocoaBeans, cocoabean: Crop.CocoaBeans, melon: Crop.Melon, mushroom: Crop.Mushroom, netherwart: Crop.NetherWart, netherwarts: Crop.NetherWart, potato: Crop.Potato, pumpkin: Crop.Pumpkin, sugarcane: Crop.SugarCane, wheat: Crop.Wheat, seeds: Crop.Seeds, sunflower: Crop.Sunflower, moonflower: Crop.Moonflower, wildrose: Crop.WildRose, }; export const cropToFullName = { [Crop.Cactus]: 'cactus', [Crop.Carrot]: 'carrot', [Crop.CocoaBeans]: 'cocoabeans', [Crop.Melon]: 'melon', [Crop.Mushroom]: 'mushroom', [Crop.NetherWart]: 'netherwart', [Crop.Potato]: 'potato', [Crop.Pumpkin]: 'pumpkin', [Crop.SugarCane]: 'sugarcane', [Crop.Wheat]: 'wheat', [Crop.Seeds]: 'seeds', [Crop.Sunflower]: 'sunflower', [Crop.Moonflower]: 'moonflower', [Crop.WildRose]: 'wildrose', }; const cropItemIds = { CACTUS: Crop.Cactus, CARROT_ITEM: Crop.Carrot, 'INK_SACK:3': Crop.CocoaBeans, MELON: Crop.Melon, BROWN_MUSHROOM: Crop.Mushroom, RED_MUSHROOM: Crop.Mushroom, MUSHROOM_COLLECTION: Crop.Mushroom, NETHER_STALK: Crop.NetherWart, POTATO_ITEM: Crop.Potato, PUMPKIN: Crop.Pumpkin, SUGAR_CANE: Crop.SugarCane, WHEAT: Crop.Wheat, SEEDS: Crop.Seeds, DOUBLE_PLANT: Crop.Sunflower, MOONFLOWER: Crop.Moonflower, WILD_ROSE: Crop.WildRose, }; const itemIdsToCrop = { [Crop.Cactus]: 'CACTUS', [Crop.Carrot]: 'CARROT_ITEM', [Crop.CocoaBeans]: 'INK_SACK:3', [Crop.Melon]: 'MELON', [Crop.Mushroom]: 'BROWN_MUSHROOM', [Crop.NetherWart]: 'NETHER_STALK', [Crop.Potato]: 'POTATO_ITEM', [Crop.Pumpkin]: 'PUMPKIN', [Crop.SugarCane]: 'SUGAR_CANE', [Crop.Wheat]: 'WHEAT', [Crop.Seeds]: 'SEEDS', [Crop.Sunflower]: 'DOUBLE_PLANT', [Crop.Moonflower]: 'MOONFLOWER', [Crop.WildRose]: 'WILD_ROSE', }; const specialCropToName = { [SpecialCrop.Cropie]: 'Cropie', [SpecialCrop.Squash]: 'Squash', [SpecialCrop.Fermento]: 'Fermento', [SpecialCrop.CondensedFermento]: 'Condensed Fermento', [SpecialCrop.Helianthus]: 'Helianthus', [SpecialCrop.CondensedHelianthus]: 'Condensed Helianthus', }; const upgradeTypeToName = { [ComposterUpgrade.Speed]: 'Composter Speed', [ComposterUpgrade.MultiDrop]: 'Multi Drop', [ComposterUpgrade.FuelCap]: 'Fuel Cap', [ComposterUpgrade.OrganicMatterCap]: 'Organic Matter Cap', [ComposterUpgrade.CostReduction]: 'Cost Reduction', }; //# sourceMappingURL=names.js.map