From 852d138e0ec52b74c67dbc48e86dad3654fa4108 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 12 May 2023 01:39:06 -0500 Subject: [PATCH] Fix step-wise formulas causing issues with reactivity --- src/game/formulas/formulas.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/game/formulas/formulas.ts b/src/game/formulas/formulas.ts index 466f7a3..5ecdedb 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()) {