From 8284baa1a086b42b89029703cd1ec9d10f3506cf 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 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()) {