Add utility for getting requirement that's met when a conversion can convert

This commit is contained in:
thepaperpilot 2023-05-15 21:16:28 -05:00
parent d7a2049ca2
commit d3a74da5ab

View file

@ -292,3 +292,20 @@ export function setupPassiveGeneration(
} }
}); });
} }
/**
* Creates requirement that is met when the conversion hits a specified gain amount
* @param conversion The conversion to check the gain amount of
* @param minGainAmount The minimum gain amount that must be met for the requirement to be met
*/
export function createCanConvertRequirement(
conversion: GenericConversion,
minGainAmount: Computable<DecimalSource> = 1,
display?: CoercableComponent
) {
const computedMinGainAmount = convertComputable(minGainAmount);
return createBooleanRequirement(
() => Decimal.gte(unref(conversion.actualGain), unref(computedMinGainAmount)),
display
);
}