From 3694e2be1fc266faf7f6c5faf7655d37813ec60a Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 10 Apr 2022 21:22:00 -0500 Subject: [PATCH] Cap independent conversion's actualGain to 1 if buyMax is false --- src/features/conversion.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/features/conversion.ts b/src/features/conversion.ts index af3b652..e21b146 100644 --- a/src/features/conversion.ts +++ b/src/features/conversion.ts @@ -74,7 +74,7 @@ export function createConversion( : conversion.scaling.currentGain(conversion as GenericConversion); gain = Decimal.floor(gain).max(0); - if (!conversion.buyMax) { + if (!unref(conversion.buyMax)) { gain = gain.min(1); } return gain; @@ -211,12 +211,17 @@ export function createIndependentConversion( setDefault(conversion, "buyMax", false); if (conversion.actualGain == null) { - conversion.actualGain = computed(() => - Decimal.sub( + conversion.actualGain = computed(() => { + let gain = Decimal.sub( conversion.scaling.currentGain(conversion as GenericConversion), conversion.gainResource.value - ).max(0) - ); + ).max(0); + + if (!unref(conversion.buyMax)) { + gain = gain.min(1); + } + return gain; + }); } setDefault(conversion, "convert", function () { conversion.gainResource.value = conversion.gainModifier