UNPKG

farming-weight

Version:

Tools for calculating farming weight and fortune in Hypixel Skyblock

156 lines (155 loc) 5.43 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); exports.GetCropInfo = exports.GetNPCProfit = exports.CalculateDetailedDrops = exports.CalculateExpectedDrops = exports.CalculateDetailedAverageDrops = exports.CalculateAverageDrops = void 0; const CROPS_1 = require('./constants/crops'); const MELON_1 = require('./crops/melon'); const PUMPKIN_1 = require('./crops/pumpkin'); const SPECIAL_1 = require('./crops/special'); const CROPS = [ CROPS_1.Crop.Cactus, CROPS_1.Crop.Carrot, CROPS_1.Crop.CocoaBeans, CROPS_1.Crop.Melon, CROPS_1.Crop.Mushroom, CROPS_1.Crop.NetherWart, CROPS_1.Crop.Potato, CROPS_1.Crop.Pumpkin, CROPS_1.Crop.SugarCane, CROPS_1.Crop.Wheat, CROPS_1.Crop.Seeds, ]; function calculateAverageDrops(options) { const RESULT = {}; for (const CROP of CROPS) { RESULT[CROP] = calculateExpectedDrops({ crop: CROP, ...options, }); } return RESULT; } exports.CalculateAverageDrops = calculateAverageDrops; function calculateDetailedAverageDrops(options) { const RESULT = {}; for (const CROP of CROPS) { RESULT[CROP] = calculateDetailedDrops({ crop: CROP, ...options, }); } const WHEAT = RESULT[CROPS_1.Crop.Wheat]; const SEEDS = RESULT[CROPS_1.Crop.Seeds]; WHEAT.otherCollection['Seeds'] = SEEDS.collection; WHEAT.coinSources['Seeds'] = SEEDS.collection * CROPS_1.CROP_INFO[CROPS_1.Crop.Seeds].npc; if (options.bountiful) { WHEAT.coinSources['Bountiful (Seeds)'] = SEEDS.coinSources['Bountiful'] ?? 0; } WHEAT.npcCoins = Object.values(WHEAT.coinSources).reduce((a, b) => a + b, 0); return RESULT; } exports.CalculateDetailedAverageDrops = calculateDetailedAverageDrops; function calculateExpectedDrops(options) { const { farmingFortune, blocksBroken, crop } = options; const FORTUNE = farmingFortune ?? CROPS_1.MAX_CROP_FORTUNE[crop] ?? 0; if (FORTUNE <= 0 || blocksBroken < 0) return 0; const { drops } = getCropInfo(crop); if (!drops) return 0; const BASE_DROPS = blocksBroken * drops * (FORTUNE * 0.01); switch (crop) { case CROPS_1.Crop.Cactus: case CROPS_1.Crop.Wheat: case CROPS_1.Crop.Mushroom: case CROPS_1.Crop.SugarCane: return Math.round(BASE_DROPS); case CROPS_1.Crop.Carrot: case CROPS_1.Crop.CocoaBeans: case CROPS_1.Crop.NetherWart: case CROPS_1.Crop.Potato: case CROPS_1.Crop.Seeds: return Math.round(BASE_DROPS - blocksBroken); // Replenish takes away one drop per block broken case CROPS_1.Crop.Pumpkin: return Math.round(BASE_DROPS + (0, PUMPKIN_1.CalculatePumpkinPerkBonus)(blocksBroken)); case CROPS_1.Crop.Melon: return Math.round(BASE_DROPS + (0, MELON_1.CalculateMelonPerkBonus)(blocksBroken)); default: return 0; } } exports.CalculateExpectedDrops = calculateExpectedDrops; function calculateDetailedDrops(options) { const RESULT = { collection: 0, npcCoins: 0, fortune: 0, coinSources: {}, otherCollection: {}, }; const { farmingFortune, blocksBroken, crop, bountiful } = options; let FORTUNE = farmingFortune ?? CROPS_1.MAX_CROP_FORTUNE[crop] ?? 0; if (FORTUNE <= 0 || blocksBroken < 0) return RESULT; if (!bountiful && !farmingFortune) { FORTUNE += 5; } RESULT.fortune = FORTUNE; const { drops, npc, breaks = 1, replenish = false } = getCropInfo(crop); if (!drops) return RESULT; const BASE_DROPS = blocksBroken * drops * (FORTUNE * 0.01); // Coin sources if (bountiful) { RESULT.coinSources['Bountiful'] = Math.round(BASE_DROPS * 0.2); } if (options.mooshroom) { RESULT.coinSources['Mooshroom'] = Math.round( blocksBroken * breaks * CROPS_1.CROP_INFO[CROPS_1.Crop.Mushroom].npc ); RESULT.otherCollection['Mushroom'] = Math.round(blocksBroken * breaks); } const SPECIAL_CROPS = (0, SPECIAL_1.CalculateAverageSpecialCrops)(blocksBroken, crop, 4); RESULT.otherCollection[SPECIAL_CROPS.type] = Math.round(SPECIAL_CROPS.amount); RESULT.coinSources[SPECIAL_CROPS.type] = Math.round(SPECIAL_CROPS.npc); let EXTRA_DROPS = 0; switch (crop) { case CROPS_1.Crop.Pumpkin: EXTRA_DROPS = Math.round((0, PUMPKIN_1.CalculatePumpkinPerkBonus)(blocksBroken)); RESULT.coinSources['Dicer RNG'] = Math.round(EXTRA_DROPS * npc); RESULT.collection = Math.round(BASE_DROPS + EXTRA_DROPS); RESULT.coinSources['Collection'] = Math.round(BASE_DROPS * npc); break; case CROPS_1.Crop.Melon: EXTRA_DROPS = Math.round((0, MELON_1.CalculateMelonPerkBonus)(blocksBroken)); RESULT.coinSources['Dicer RNG'] = Math.round(EXTRA_DROPS * npc); RESULT.collection = Math.round(BASE_DROPS + EXTRA_DROPS); RESULT.coinSources['Collection'] = Math.round(BASE_DROPS * npc); break; default: if (replenish) { // Replenish takes away one drop per block broken RESULT.coinSources['Collection'] = Math.round((BASE_DROPS - blocksBroken * breaks) * npc); RESULT.collection = Math.round(BASE_DROPS - blocksBroken * breaks); break; } RESULT.coinSources['Collection'] = Math.round(BASE_DROPS * npc); RESULT.collection = Math.round(BASE_DROPS); break; } RESULT.npcCoins = Object.values(RESULT.coinSources).reduce((a, b) => a + b, 0); return RESULT; } exports.CalculateDetailedDrops = calculateDetailedDrops; function getNpcProfit(crop, amount) { const { npc } = getCropInfo(crop); if (!npc) return 0; return npc * amount; } exports.GetNPCProfit = getNpcProfit; function getCropInfo(crop) { return CROPS_1.CROP_INFO[crop] ?? {}; } exports.GetCropInfo = getCropInfo; //# sourceMappingURL=ratecalc.js.map