From 1f48622314beb0e0d8011c948520db44e5b8ae18 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 09:59:45 -0600 Subject: [PATCH] Cache decimals used for trackOOMPS --- src/features/resources/resource.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/features/resources/resource.ts b/src/features/resources/resource.ts index 61e0dff..8f44c31 100644 --- a/src/features/resources/resource.ts +++ b/src/features/resources/resource.ts @@ -42,6 +42,8 @@ export function trackTotal(resource: Resource): Ref { return total; } +const tetra8 = new Decimal("10^^8"); +const e100 = new Decimal("1e100"); export function trackOOMPS( resource: Resource, pointGain?: ComputedRef @@ -52,7 +54,7 @@ export function trackOOMPS( globalBus.on("update", diff => { oompsMag.value = 0; - if (Decimal.lte(resource.value, 1e100)) { + if (Decimal.lte(resource.value, e100)) { lastPoints.value = resource.value; return; } @@ -61,7 +63,7 @@ export function trackOOMPS( let prev = lastPoints.value; lastPoints.value = curr; if (Decimal.gt(curr, prev)) { - if (Decimal.gte(curr, "10^^8")) { + if (Decimal.gte(curr, tetra8)) { curr = Decimal.slog(curr, 1e10); prev = Decimal.slog(prev, 1e10); oomps.value = curr.sub(prev).div(diff);