Profectus / game/formulas/formulas / calculateMaxAffordable
Function: calculateMaxAffordable() ​
calculateMaxAffordable(
formula
,resource
,cumulativeCost
,directSum
?,maxBulkAmount
?):ComputedRef
<default
|0
>
Utility for calculating the maximum amount of purchases possible with a given formula and resource. If cumulativeCost is changed to false, the calculation will be much faster with higher numbers.
Parameters ​
formula ​
The formula to use for calculating buy max from
resource ​
The resource used when purchasing (is only read from)
cumulativeCost ​
MaybeRefOrGetter
<boolean
> = true
Whether or not to count spent resources on each purchase or not. If true, costs will be approximated for performance, skewing towards fewer purchases
directSum? ​
MaybeRefOrGetter
<number
>
How many of the most expensive purchases should be manually summed for better accuracy. If unspecified uses 10 when spending resources and 0 when not
maxBulkAmount? ​
MaybeRefOrGetter
<DecimalSource
> = Decimal.dInf
Cap on how many can be purchased at once. If equal to 1 or lte to directSum then the formula does not need to be invertible. Defaults to Infinity.
Returns ​
ComputedRef
<default
| 0
>