From 46306ee0e7ee50cea8a18e8fb97ad7f77fbcfd7e Mon Sep 17 00:00:00 2001 From: ducdat0507 <62660527+ducdat0507@users.noreply.github.com> Date: Fri, 19 May 2023 17:12:53 +0700 Subject: [PATCH] Fix repeatables buying more than intended when `cumulativeCost` is `false` --- src/game/formulas/formulas.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/game/formulas/formulas.ts b/src/game/formulas/formulas.ts index d9a6bed..ee0405d 100644 --- a/src/game/formulas/formulas.ts +++ b/src/game/formulas/formulas.ts @@ -1453,7 +1453,9 @@ export function calculateMaxAffordable( formula.invertIntegral(Decimal.add(resource.value, formula.evaluateIntegral())) ).sub(unref(formula.innermostVariable) ?? 0); } else { - affordable = Decimal.floor(formula.invert(resource.value)); + affordable = Decimal.floor( + formula.invert(resource.value) + ).add(1).sub(unref(formula.innermostVariable) ?? 0); } } affordable = Decimal.clampMax(affordable, maxBulkAmount); -- 2.45.2