farming-weight
Version:
Tools for calculating farming weight and fortune in Hypixel Skyblock
181 lines • 6.56 kB
JavaScript
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 = {
[]: 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 = {
[]: 'Strength',
[]: 'Health',
[]: 'Defense',
[]: 'Speed',
[]: 'Intelligence',
[]: 'Crit Chance',
[]: 'Crit Damage',
[]: 'Attack Speed',
[]: 'Ability Damage',
[]: 'Magic Find',
[]: 'Pet Luck',
[]: 'True Defense',
[]: 'Sea Creature Chance',
[]: 'Ferocity',
[]: 'Mining Speed',
[]: 'Mining Fortune',
[]: 'Farming Fortune',
[]: 'Cactus Fortune',
[]: 'Carrot Fortune',
[]: 'Cocoa Bean Fortune',
[]: 'Melon Fortune',
[]: 'Mushroom Fortune',
[]: 'Nether Wart Fortune',
[]: 'Potato Fortune',
[]: 'Pumpkin Fortune',
[]: 'Sugar Cane Fortune',
[]: 'Wheat Fortune',
[]: 'Sunflower Fortune',
[]: 'Moonflower Fortune',
[]: 'Wild Rose Fortune',
[]: 'Pest Kill Fortune',
[]: 'Foraging Fortune',
[]: 'Mining Wisdom',
[]: 'Farming Wisdom',
[]: 'Foraging Wisdom',
[]: 'Pristine',
[]: 'Bonus Pest Chance',
[]: 'Pest Cooldown Reduction',
[]: 'Overbloom',
[]: 'Fishing Speed',
};
//# sourceMappingURL=stats.js.map