From 5bdb5ceed1373c65b88df0b609de432ad56744a2 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sun, 15 Dec 2024 19:39:11 -0600 Subject: [PATCH] Change bonus mixin --- src/features/clickables/clickable.tsx | 2 +- src/mixins/bonusAmount.ts | 15 ++++++++++++++ src/mixins/bonusDecorator.ts | 29 --------------------------- 3 files changed, 16 insertions(+), 30 deletions(-) create mode 100644 src/mixins/bonusAmount.ts delete mode 100644 src/mixins/bonusDecorator.ts diff --git a/src/features/clickables/clickable.tsx b/src/features/clickables/clickable.tsx index 12e9022..1268f46 100644 --- a/src/features/clickables/clickable.tsx +++ b/src/features/clickables/clickable.tsx @@ -108,7 +108,7 @@ export function createClickable(optionsFunc?: () => onHold.call(clickable); } } - } satisfies Clickable & { onClick: T["onClick"] }; + } satisfies Clickable; return clickable; }); diff --git a/src/mixins/bonusAmount.ts b/src/mixins/bonusAmount.ts new file mode 100644 index 0000000..5ed7c7d --- /dev/null +++ b/src/mixins/bonusAmount.ts @@ -0,0 +1,15 @@ +import Decimal, { DecimalSource } from "util/bignum"; +import { processGetter } from "util/computed"; +import { MaybeRefOrGetter, Ref, computed, unref } from "vue"; + +/** Allows the addition of "bonus levels" to a feature, with an accompanying "total amount". */ +export function bonusAmountMixin( + baseAmount: Ref, + bonusAmount: MaybeRefOrGetter +) { + const processedBonusAmount = processGetter(bonusAmount); + return { + bonusAmount: processedBonusAmount, + totalAmount: computed(() => Decimal.add(unref(baseAmount), unref(processedBonusAmount))) + }; +} diff --git a/src/mixins/bonusDecorator.ts b/src/mixins/bonusDecorator.ts deleted file mode 100644 index b08954e..0000000 --- a/src/mixins/bonusDecorator.ts +++ /dev/null @@ -1,29 +0,0 @@ -import Decimal, { DecimalSource } from "util/bignum"; -import { processGetter } from "util/computed"; -import { MaybeRefOrGetter, Ref, computed, unref } from "vue"; - -/** Allows the addition of "bonus levels" to a feature, with an accompanying "total amount". */ -export function bonusAmountMixin( - feature: { amount: Ref }, - bonusAmount: MaybeRefOrGetter -) { - const processedBonusAmount = processGetter(bonusAmount); - return { - bonusAmount, - totalAmount: computed(() => Decimal.add(unref(feature.amount), unref(processedBonusAmount))) - }; -} - -/** Allows the addition of "bonus completions" to a feature, with an accompanying "total completions". */ -export function bonusCompletionsMixin( - feature: { completions: Ref }, - bonusCompletions: MaybeRefOrGetter -) { - const processedBonusCompletions = processGetter(bonusCompletions); - return { - bonusCompletions, - totalCompletions: computed(() => - Decimal.add(unref(feature.completions), unref(processedBonusCompletions)) - ) - }; -}