Change bonus mixin
This commit is contained in:
parent
b1cbbc4f00
commit
07718f6c48
3 changed files with 16 additions and 30 deletions
|
@ -108,7 +108,7 @@ export function createClickable<T extends ClickableOptions>(optionsFunc?: () =>
|
|||
onHold.call(clickable);
|
||||
}
|
||||
}
|
||||
} satisfies Clickable & { onClick: T["onClick"] };
|
||||
} satisfies Clickable;
|
||||
|
||||
return clickable;
|
||||
});
|
||||
|
|
15
src/mixins/bonusAmount.ts
Normal file
15
src/mixins/bonusAmount.ts
Normal file
|
@ -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<DecimalSource>,
|
||||
bonusAmount: MaybeRefOrGetter<DecimalSource>
|
||||
) {
|
||||
const processedBonusAmount = processGetter(bonusAmount);
|
||||
return {
|
||||
bonusAmount: processedBonusAmount,
|
||||
totalAmount: computed(() => Decimal.add(unref(baseAmount), unref(processedBonusAmount)))
|
||||
};
|
||||
}
|
|
@ -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<DecimalSource> },
|
||||
bonusAmount: MaybeRefOrGetter<DecimalSource>
|
||||
) {
|
||||
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<DecimalSource> },
|
||||
bonusCompletions: MaybeRefOrGetter<DecimalSource>
|
||||
) {
|
||||
const processedBonusCompletions = processGetter(bonusCompletions);
|
||||
return {
|
||||
bonusCompletions,
|
||||
totalCompletions: computed(() =>
|
||||
Decimal.add(unref(feature.completions), unref(processedBonusCompletions))
|
||||
)
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue