UNPKG

farming-weight

Version:

Tools for calculating farming weight and fortune in Hypixel Skyblock

193 lines 5.82 kB
import { Rarity } from './reforges.js'; import { Stat } from './stats.js'; export const GARDEN_CHIP_MAX_LEVEL = 20; export const GARDEN_CHIP_WIKI = 'https://w.elitesb.gg/Garden_Chip'; export const GARDEN_CHIPS = { vermin_vaporizer: { skyblockId: 'VERMIN_VAPORIZER_GARDEN_CHIP', name: 'Vermin Vaporizer Chip', wiki: GARDEN_CHIP_WIKI, statsPerRarity: { [Rarity.Rare]: { [Stat.BonusPestChance]: 3, }, [Rarity.Epic]: { [Stat.BonusPestChance]: 4, }, [Rarity.Legendary]: { [Stat.BonusPestChance]: 5, }, }, }, synthesis: { skyblockId: 'SYNTHESIS_GARDEN_CHIP', name: 'Synthesis Chip', wiki: GARDEN_CHIP_WIKI, }, sowledge: { skyblockId: 'SOWLEDGE_GARDEN_CHIP', name: 'Sowledge Chip', wiki: GARDEN_CHIP_WIKI, statsPerRarity: { [Rarity.Rare]: { [Stat.FarmingWisdom]: 1, }, [Rarity.Epic]: { [Stat.FarmingWisdom]: 1.25, }, [Rarity.Legendary]: { [Stat.FarmingWisdom]: 1.5, }, }, }, mechamind: { skyblockId: 'MECHAMIND_GARDEN_CHIP', name: 'Mechamind Chip', wiki: GARDEN_CHIP_WIKI, }, hypercharge: { skyblockId: 'HYPERCHARGE_GARDEN_CHIP', name: 'Hypercharge Chip', wiki: GARDEN_CHIP_WIKI, tempMultiplierPerLevel: { [Rarity.Rare]: 0.03, [Rarity.Epic]: 0.04, [Rarity.Legendary]: 0.05, }, }, evergreen: { skyblockId: 'EVERGREEN_GARDEN_CHIP', name: 'Evergreen Chip', wiki: GARDEN_CHIP_WIKI, }, cropshot: { skyblockId: 'CROPSHOT_GARDEN_CHIP', name: 'Cropshot Chip', wiki: GARDEN_CHIP_WIKI, statsPerRarity: { [Rarity.Rare]: { [Stat.FarmingFortune]: 3, }, [Rarity.Epic]: { [Stat.FarmingFortune]: 4, }, [Rarity.Legendary]: { [Stat.FarmingFortune]: 5, }, }, }, overdrive: { skyblockId: 'OVERDRIVE_GARDEN_CHIP', name: 'Overdrive Chip', wiki: GARDEN_CHIP_WIKI, }, quickdraw: { skyblockId: 'QUICKDRAW_GARDEN_CHIP', name: 'Quickdraw Chip', wiki: GARDEN_CHIP_WIKI, }, rarefinder: { skyblockId: 'RAREFINDER_GARDEN_CHIP', name: 'Rarefinder Chip', wiki: GARDEN_CHIP_WIKI, statsPerRarity: { [Rarity.Rare]: { [Stat.Overbloom]: 2, }, [Rarity.Epic]: { [Stat.Overbloom]: 2.5, }, [Rarity.Legendary]: { [Stat.Overbloom]: 3, }, }, }, }; const CHIP_ID_LOOKUP = Object.entries(GARDEN_CHIPS).reduce((acc, [chipId, chip]) => { const id = chipId; const canonical = chipId.toLowerCase(); const skyblock = chip.skyblockId.toLowerCase(); const shortFromSkyblock = skyblock.replace(/_garden_chip$/, ''); const aliases = [ canonical, canonical.replace(/_/g, ''), skyblock, skyblock.replace(/_/g, ''), shortFromSkyblock, shortFromSkyblock.replace(/_/g, ''), ]; for (const alias of aliases) { acc[alias] = id; } return acc; }, {}); export function getChipLevel(level) { if (!level || level <= 0) return 0; return Math.min(Math.max(Math.floor(level), 0), GARDEN_CHIP_MAX_LEVEL); } export function getChipRarity(level) { const chipLevel = getChipLevel(level); if (chipLevel > 15) return Rarity.Legendary; if (chipLevel > 10) return Rarity.Epic; return Rarity.Rare; } export function getChipStats(chipId, level) { const chipInfo = GARDEN_CHIPS[chipId]; if (!chipInfo.statsPerRarity) return {}; const rarity = getChipRarity(level); return chipInfo.statsPerRarity[rarity] ?? {}; } /** Returns the per-level multiplier for temporary fortune sources for a chip, based on level-derived rarity. */ export function getChipTempMultiplierPerLevel(chipId, level) { const chipInfo = GARDEN_CHIPS[chipId]; if (!chipInfo.tempMultiplierPerLevel) return 0; const rarity = getChipRarity(level); return chipInfo.tempMultiplierPerLevel[rarity] ?? 0; } /** * Normalizes chip identifiers to the canonical GardenChipId format. * Accepts canonical IDs, full SkyBlock IDs, and short names. */ export function normalizeChipId(id) { const normalized = id .trim() .toLowerCase() .replace(/[\s-]+/g, '_'); return CHIP_ID_LOOKUP[normalized] ?? CHIP_ID_LOOKUP[normalized.replace(/_/g, '')]; } export function normalizeChipLevels(chips) { if (!chips) return undefined; const normalized = {}; for (const [id, level] of Object.entries(chips)) { const chipId = normalizeChipId(id); if (!chipId || level === undefined || level === null) continue; normalized[chipId] = level; } return normalized; } export function getChipInputLevel(chips, chipId) { if (!chips) return 0; const direct = chips[chipId]; if (direct !== undefined && direct !== null) return direct; const legacyId = GARDEN_CHIPS[chipId].skyblockId; const legacy = chips[legacyId]; if (legacy !== undefined && legacy !== null) return legacy; for (const [id, level] of Object.entries(chips)) { if (level === undefined || level === null) continue; if (normalizeChipId(id) === chipId) return level; } return 0; } //# sourceMappingURL=chips.js.map