UNPKG

farming-weight

Version:

Tools for calculating farming weight and fortune in Hypixel Skyblock

181 lines 6.56 kB
export var Stat; (function (Stat) { Stat["Strength"] = "Strength"; Stat["Health"] = "Health"; Stat["Defense"] = "Defense"; Stat["Speed"] = "Speed"; Stat["Intelligence"] = "Intelligence"; Stat["CritChance"] = "Crit Chance"; Stat["CritDamage"] = "Crit Damage"; Stat["AttackSpeed"] = "Attack Speed"; Stat["AbilityDamage"] = "Ability Damage"; Stat["MagicFind"] = "Magic Find"; Stat["PetLuck"] = "Pet Luck"; Stat["TrueDefense"] = "True Defense"; Stat["SeaCreatureChance"] = "Sea Creature Chance"; Stat["Ferocity"] = "Ferocity"; Stat["MiningSpeed"] = "Mining Speed"; Stat["MiningFortune"] = "mining_fortune"; Stat["FarmingFortune"] = "farming_fortune"; Stat["CactusFortune"] = "cactus_fortune"; Stat["CarrotFortune"] = "carrot_fortune"; Stat["CocoaBeanFortune"] = "cocoa_beans_fortune"; Stat["MelonFortune"] = "melon_fortune"; Stat["MushroomFortune"] = "mushroom_fortune"; Stat["NetherWartFortune"] = "nether_wart_fortune"; Stat["PotatoFortune"] = "potato_fortune"; Stat["PumpkinFortune"] = "pumpkin_fortune"; Stat["SugarCaneFortune"] = "sugar_cane_fortune"; Stat["WheatFortune"] = "wheat_fortune"; Stat["SunflowerFortune"] = "sunflower_fortune"; Stat["MoonflowerFortune"] = "moonflower_fortune"; Stat["WildRoseFortune"] = "wild_rose_fortune"; Stat["PestKillFortune"] = "pest_kill_fortune"; Stat["ForagingFortune"] = "foraging_fortune"; Stat["MiningWisdom"] = "Mining Wisdom"; Stat["FarmingWisdom"] = "Farming Wisdom"; Stat["ForagingWisdom"] = "Foraging Wisdom"; Stat["Pristine"] = "Pristine"; Stat["BonusPestChance"] = "Bonus Pest Chance"; Stat["PestCooldownReduction"] = "Pest Cooldown Reduction"; Stat["Overbloom"] = "Overbloom"; Stat["FishingSpeed"] = "Fishing Speed"; })(Stat || (Stat = {})); /** * Mapping of parent stats to their child stats. * For example, FarmingFortune is a parent stat for WheatFortune, CarrotFortune, etc. * This allows for querying a general stat (e.g., FarmingFortune) and getting all specific stats that fall under it. */ export const STAT_GROUPS = { [Stat.FarmingFortune]: new Set([ Stat.CactusFortune, Stat.CarrotFortune, Stat.CocoaBeanFortune, Stat.MelonFortune, Stat.MushroomFortune, Stat.NetherWartFortune, Stat.PotatoFortune, Stat.PumpkinFortune, Stat.SugarCaneFortune, Stat.SunflowerFortune, Stat.MoonflowerFortune, Stat.WildRoseFortune, Stat.WheatFortune, ]), }; /** * Expand a stat query to include child stats from stat groups. * Returns an array containing the original stat plus any grouped child stats. */ export function expandStatQuery(stat) { const children = STAT_GROUPS[stat]; if (children) { return [stat, ...children]; } return [stat]; } /** * Mapping of stats to the list of stats that contribute to them. * This is effectively the reverse of STAT_GROUPS, but pre-calculated for efficient lookup. * * Example: WheatFortune is improved by sources that provide WheatFortune OR FarmingFortune. * So CONTRIBUTORY_STATS[WheatFortune] = [WheatFortune, FarmingFortune]. */ export const CONTRIBUTORY_STATS = {}; // Initialize contributory stats for (const stat of Object.values(Stat)) { const contributors = [stat]; // Check all groups to see if this stat is a child of a group for (const [parent, children] of Object.entries(STAT_GROUPS)) { if (children.has(stat)) { contributors.push(parent); } } if (contributors.length > 1) { CONTRIBUTORY_STATS[stat] = contributors; } } /** * Get all stats that contribute to the target stat. * Returns [targetStat, ...parentStats]. */ export function getContributoryStats(stat) { return CONTRIBUTORY_STATS[stat] ?? [stat]; } export function getStatValue(stat, option) { if (!stat || (stat.exists && option && !stat.exists(option))) return 0; let value = 0; if ('value' in stat) { value += stat.value; } if ('calculated' in stat && option) { value += stat.calculated(option); } return value; } export const CROP_FORTUNE_STATS = new Set([ Stat.CactusFortune, Stat.CarrotFortune, Stat.CocoaBeanFortune, Stat.MelonFortune, Stat.MushroomFortune, Stat.NetherWartFortune, Stat.PotatoFortune, Stat.PumpkinFortune, Stat.SugarCaneFortune, Stat.SunflowerFortune, Stat.MoonflowerFortune, Stat.WildRoseFortune, Stat.WheatFortune, ]); export function statMatchesQuery(statToCheck, queryStat) { if (statToCheck === queryStat) return true; if (STAT_GROUPS[queryStat]?.has(statToCheck)) return true; return false; } export const STAT_NAMES = { [Stat.Strength]: 'Strength', [Stat.Health]: 'Health', [Stat.Defense]: 'Defense', [Stat.Speed]: 'Speed', [Stat.Intelligence]: 'Intelligence', [Stat.CritChance]: 'Crit Chance', [Stat.CritDamage]: 'Crit Damage', [Stat.AttackSpeed]: 'Attack Speed', [Stat.AbilityDamage]: 'Ability Damage', [Stat.MagicFind]: 'Magic Find', [Stat.PetLuck]: 'Pet Luck', [Stat.TrueDefense]: 'True Defense', [Stat.SeaCreatureChance]: 'Sea Creature Chance', [Stat.Ferocity]: 'Ferocity', [Stat.MiningSpeed]: 'Mining Speed', [Stat.MiningFortune]: 'Mining Fortune', [Stat.FarmingFortune]: 'Farming Fortune', [Stat.CactusFortune]: 'Cactus Fortune', [Stat.CarrotFortune]: 'Carrot Fortune', [Stat.CocoaBeanFortune]: 'Cocoa Bean Fortune', [Stat.MelonFortune]: 'Melon Fortune', [Stat.MushroomFortune]: 'Mushroom Fortune', [Stat.NetherWartFortune]: 'Nether Wart Fortune', [Stat.PotatoFortune]: 'Potato Fortune', [Stat.PumpkinFortune]: 'Pumpkin Fortune', [Stat.SugarCaneFortune]: 'Sugar Cane Fortune', [Stat.WheatFortune]: 'Wheat Fortune', [Stat.SunflowerFortune]: 'Sunflower Fortune', [Stat.MoonflowerFortune]: 'Moonflower Fortune', [Stat.WildRoseFortune]: 'Wild Rose Fortune', [Stat.PestKillFortune]: 'Pest Kill Fortune', [Stat.ForagingFortune]: 'Foraging Fortune', [Stat.MiningWisdom]: 'Mining Wisdom', [Stat.FarmingWisdom]: 'Farming Wisdom', [Stat.ForagingWisdom]: 'Foraging Wisdom', [Stat.Pristine]: 'Pristine', [Stat.BonusPestChance]: 'Bonus Pest Chance', [Stat.PestCooldownReduction]: 'Pest Cooldown Reduction', [Stat.Overbloom]: 'Overbloom', [Stat.FishingSpeed]: 'Fishing Speed', }; //# sourceMappingURL=stats.js.map