diff --git a/src/game/formulas/formulas.ts b/src/game/formulas/formulas.ts index 76d8ff9..144dc0d 100644 --- a/src/game/formulas/formulas.ts +++ b/src/game/formulas/formulas.ts @@ -229,15 +229,16 @@ export abstract class InternalFormula, formulaModifier: (value: InvertibleIntegralFormula) => GenericFormula ) { - const lhsRef = ref(0); - const formula = formulaModifier(Formula.variable(lhsRef)); + const formula = formulaModifier(Formula.variable(0)); const processedStart = convertComputable(start); function evalStep(lhs: DecimalSource) { if (Decimal.lt(lhs, unref(processedStart))) { return lhs; } - lhsRef.value = Decimal.sub(lhs, unref(processedStart)); - return Decimal.add(formula.evaluate(), unref(processedStart)); + return Decimal.add( + formula.evaluate(Decimal.sub(lhs, unref(processedStart))), + unref(processedStart) + ); } function invertStep(value: DecimalSource, lhs: FormulaSource) { if (hasVariable(lhs) && formula.isInvertible()) {