The current value of the currency.
The upgrade object to calculate.
Optional
start: DecimalSourceThe starting level of the upgrade. Defaults the current level of the upgrade.
The ending level or quantity to reach for the upgrade. If not provided, it will buy the maximum amount of upgrades possible (using target = Infinity).
Optional
mode: MeanModeThe mode/mean method to use. See MeanMode
Optional
iterations: numberThe amount of iterations to perform. Defaults to 15
.
ie Endless: Flag to exclude the sum calculation and only perform binary search. (DEPRECATED, use el
in the upgrade object instead)
[amount, cost] - Returns the amount of upgrades you can buy and the cost of the upgrades. If you can't afford any, it returns [Decimal.dZero, Decimal.dZero].
Calculates the cost and how many upgrades you can buy Uses inverseFunctionApprox to calculate the maximum affordable quantity. The priority is:
target === 1
>costBulk
>el
. For sum upgrades, this function has a max time complexity of O(n^2) where n is the number of iterations. For el upgrades, this function has a max time complexity of O(n) where n is the number of iterations.