farming-weight
Version:
Tools for calculating farming weight and fortune in Hypixel Skyblock
33 lines • 1.17 kB
JavaScript
/**
* Single source-of-truth for building an `EffectEnvironment` from a player.
*
* No other call site is allowed to construct an `EffectEnvironment` ad-hoc.
* Field derivations are intentionally simple and tested.
*/
export function buildEffectEnvironment(player, crop) {
return buildEffectEnvironmentFromOptions(player.options, crop);
}
export function buildEffectEnvironmentFromOptions(opts, crop) {
const harvestFeast = opts?.harvestFeast?.active === true;
let inSeason = false;
if (harvestFeast && crop !== undefined) {
const grand = opts?.harvestFeast?.grandFeast === true;
if (grand) {
inSeason = true;
}
else {
const seasonList = opts?.harvestFeast?.inSeasonCrops;
inSeason = Array.isArray(seasonList) ? seasonList.includes(crop) : false;
}
}
const infestedPlot = typeof opts?.infestedPlotProbability === 'number' && opts.infestedPlotProbability > 0;
const selectedCrop = opts?.selectedCrop;
return {
crop,
harvestFeast,
inSeason,
infestedPlot,
selectedCrop,
};
}
//# sourceMappingURL=environment.js.map