Add feature decorator system #13
|
@ -23,6 +23,7 @@ import { createLazyProxy } from "util/proxies";
|
||||||
import { coerceComponent, isCoercableComponent } from "util/vue";
|
import { coerceComponent, isCoercableComponent } from "util/vue";
|
||||||
import type { Ref } from "vue";
|
import type { Ref } from "vue";
|
||||||
import { computed, unref } from "vue";
|
import { computed, unref } from "vue";
|
||||||
|
import { Decorator } from "./decorators";
|
||||||
|
|
||||||
export const BuyableType = Symbol("Buyable");
|
export const BuyableType = Symbol("Buyable");
|
||||||
|
|
||||||
|
@ -89,9 +90,13 @@ export type GenericBuyable = Replace<
|
||||||
>;
|
>;
|
||||||
|
|
||||||
export function createBuyable<T extends BuyableOptions>(
|
export function createBuyable<T extends BuyableOptions>(
|
||||||
optionsFunc: OptionsFunc<T, BaseBuyable, GenericBuyable>
|
optionsFunc: OptionsFunc<T, BaseBuyable, GenericBuyable>,
|
||||||
|
...decorators: Decorator<T, BaseBuyable, GenericBuyable>[]
|
||||||
): Buyable<T> {
|
): Buyable<T> {
|
||||||
const amount = persistent<DecimalSource>(0);
|
const amount = persistent<DecimalSource>(0);
|
||||||
|
|
||||||
|
const persistents = decorators.reduce((current, next) => Object.assign(current, next.getPersistents?.()), {});
|
||||||
|
|
||||||
return createLazyProxy(() => {
|
return createLazyProxy(() => {
|
||||||
const buyable = optionsFunc();
|
const buyable = optionsFunc();
|
||||||
|
|
||||||
|
@ -107,8 +112,15 @@ export function createBuyable<T extends BuyableOptions>(
|
||||||
buyable.type = BuyableType;
|
buyable.type = BuyableType;
|
||||||
buyable[Component] = ClickableComponent;
|
buyable[Component] = ClickableComponent;
|
||||||
|
|
||||||
|
for (const decorator of decorators) {
|
||||||
|
decorator.preConstruct?.(buyable);
|
||||||
|
}
|
||||||
|
|
||||||
buyable.amount = amount;
|
buyable.amount = amount;
|
||||||
buyable.amount[DefaultValue] = buyable.initialValue ?? 0;
|
buyable.amount[DefaultValue] = buyable.initialValue ?? 0;
|
||||||
|
|
||||||
|
Object.assign(buyable, persistents);
|
||||||
|
|
||||||
buyable.canAfford = computed(() => {
|
buyable.canAfford = computed(() => {
|
||||||
const genericBuyable = buyable as GenericBuyable;
|
const genericBuyable = buyable as GenericBuyable;
|
||||||
const cost = unref(genericBuyable.cost);
|
const cost = unref(genericBuyable.cost);
|
||||||
|
@ -230,6 +242,7 @@ export function createBuyable<T extends BuyableOptions>(
|
||||||
processComputable(buyable as T, "mark");
|
processComputable(buyable as T, "mark");
|
||||||
processComputable(buyable as T, "small");
|
processComputable(buyable as T, "small");
|
||||||
|
|
||||||
|
const gatheredProps = decorators.reduce((current, next) => Object.assign(current, next.getGatheredProps?.(buyable)), {});
|
||||||
buyable[GatherProps] = function (this: GenericBuyable) {
|
buyable[GatherProps] = function (this: GenericBuyable) {
|
||||||
const { display, visibility, style, classes, onClick, canClick, small, mark, id } =
|
const { display, visibility, style, classes, onClick, canClick, small, mark, id } =
|
||||||
this;
|
this;
|
||||||
|
@ -242,10 +255,15 @@ export function createBuyable<T extends BuyableOptions>(
|
||||||
canClick,
|
canClick,
|
||||||
small,
|
small,
|
||||||
mark,
|
mark,
|
||||||
id
|
id,
|
||||||
|
...gatheredProps
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
for (const decorator of decorators) {
|
||||||
|
decorator.postConstruct?.(buyable);
|
||||||
|
}
|
||||||
|
|
||||||
return buyable as unknown as Buyable<T>;
|
return buyable as unknown as Buyable<T>;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
117
src/features/decorators.ts
Normal file
|
@ -0,0 +1,117 @@
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
import { Replace, OptionsObject } from "./feature";
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
import Decimal, { DecimalSource } from "util/bignum";
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
import { Computable, GetComputableType, processComputable, ProcessedComputable } from "util/computed";
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
import { AchievementOptions, BaseAchievement, GenericAchievement } from "./achievements/achievement";
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
import { BarOptions, BaseBar, GenericBar } from "./bars/bar";
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
import { BaseBuyable, BuyableOptions, GenericBuyable } from "./buyable";
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
import { BaseChallenge, ChallengeOptions, GenericChallenge } from "./challenges/challenge";
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
import { BaseClickable, ClickableOptions, GenericClickable } from "./clickables/clickable";
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
import { BaseMilestone, GenericMilestone, MilestoneOptions } from "./milestones/milestone";
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
import { BaseUpgrade, GenericUpgrade, UpgradeOptions } from "./upgrades/upgrade";
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
import { Persistent, State } from "game/persistence";
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
import { computed, Ref, unref } from "vue";
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
type FeatureOptions = AchievementOptions | BarOptions | BuyableOptions | ChallengeOptions | ClickableOptions | MilestoneOptions | UpgradeOptions;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
type BaseFeature = BaseAchievement | BaseBar | BaseBuyable | BaseChallenge | BaseClickable | BaseMilestone | BaseUpgrade;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
type GenericFeature = GenericAchievement | GenericBar | GenericBuyable | GenericChallenge | GenericClickable | GenericMilestone | GenericUpgrade;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
/*----====----*/
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
export type Decorator<Options extends FeatureOptions, Base extends BaseFeature, Generic extends GenericFeature, S extends State = State> = {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
getPersistents?(): Record<string, Persistent<S>>;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
preConstruct?(feature: OptionsObject<Options,Base,Generic>): void;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
postConstruct?(feature: OptionsObject<Options,Base,Generic>): void;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
getGatheredProps?(feature: OptionsObject<Options,Base,Generic>): Partial<OptionsObject<Options,Base,Generic>>
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
/*----====----*/
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
// #region Effect Decorator
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
export type EffectFeatureOptions = {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
effect: Computable<any>;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
export type EffectFeature<T extends EffectFeatureOptions, U extends BaseFeature> = Replace<
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
T & U,
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
{ effect: GetComputableType<T["effect"]>; }
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
>;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
export type GenericEffectFeature<T extends GenericFeature> = T & Replace<
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
EffectFeature<EffectFeatureOptions, BaseFeature>,
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
{ effect: ProcessedComputable<any>; }
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
>;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
export const effectDecorator: Decorator<FeatureOptions & EffectFeatureOptions, BaseFeature, GenericFeature & BaseFeature> = {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
postConstruct(feature) {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
processComputable(feature, "effect");
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
// #endregion
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
/*----====----*/
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
// #region Bonus Amount Decorator
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
export interface BonusFeatureOptions {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
bonusAmount: Computable<DecimalSource>;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
export type BaseBonusFeature = BaseFeature & {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
totalAmount: Ref<DecimalSource>;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
export type BonusAmountFeature<T extends BonusFeatureOptions, U extends BaseBonusFeature> = Replace<
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
T & U,
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
{
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
bonusAmount: GetComputableType<T["bonusAmount"]>;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
>;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
export type GenericBonusFeature<T extends GenericFeature> = Replace<
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
T & BonusAmountFeature<BonusFeatureOptions, BaseBonusFeature>,
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
{
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
bonusAmount: ProcessedComputable<DecimalSource>;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
totalAmount: ProcessedComputable<DecimalSource>;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
>;
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
export const bonusAmountDecorator: Decorator<FeatureOptions & BonusFeatureOptions, BaseBonusFeature & {amount: ProcessedComputable<DecimalSource>}, GenericFeature & BaseBonusFeature & {amount: ProcessedComputable<DecimalSource>}> = {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
postConstruct(feature) {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
processComputable(feature, "bonusAmount");
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
if (feature.totalAmount === undefined) {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
feature.totalAmount = computed(() => Decimal.add(
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
unref(feature.amount ?? 0),
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
unref(feature.bonusAmount as ProcessedComputable<DecimalSource>)
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
));
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
export const bonusCompletionsDecorator: Decorator<FeatureOptions & BonusFeatureOptions, BaseBonusFeature & {completions: ProcessedComputable<DecimalSource>}, GenericFeature & BaseBonusFeature & {completions: ProcessedComputable<DecimalSource>}> = {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
postConstruct(feature) {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
processComputable(feature, "bonusAmount");
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
if (feature.totalAmount === undefined) {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
feature.totalAmount = computed(() => Decimal.add(
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
unref(feature.completions ?? 0),
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
unref(feature.bonusAmount as ProcessedComputable<DecimalSource>)
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
));
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
export const bonusEarnedDecorator: Decorator<FeatureOptions & BonusFeatureOptions, BaseBonusFeature & {earned: ProcessedComputable<boolean>}, GenericFeature & BaseBonusFeature & {earned: ProcessedComputable<boolean>}> = {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
postConstruct(feature) {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
processComputable(feature, "bonusAmount");
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
if (feature.totalAmount === undefined) {
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
feature.totalAmount = computed(() => unref(feature.earned ?? false)
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
? Decimal.add(unref(feature.bonusAmount as ProcessedComputable<DecimalSource>), 1)
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
: unref(feature.bonusAmount as ProcessedComputable<DecimalSource>)
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
);
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
}
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
// #endregion
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
/*----====----*/
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|||||||
|
|
||||||
I think the specific decorators probably belong in their own files, or in I think the specific decorators probably belong in their own files, or in `common.tsx` if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).
|
|
@ -42,9 +42,9 @@ export type Replace<T, S> = S & Omit<T, keyof S>;
|
||||||
* with "this" bound to what the type will eventually be processed into.
|
* with "this" bound to what the type will eventually be processed into.
|
||||||
* Intended for making lazily evaluated objects.
|
* Intended for making lazily evaluated objects.
|
||||||
*/
|
*/
|
||||||
export type OptionsFunc<T, R = Record<string, unknown>, S = R> = () => T &
|
export type OptionsFunc<T, R = Record<string, unknown>, S = R> = () => OptionsObject<T,R,S>;
|
||||||
Partial<R> &
|
|
||||||
ThisType<T & S>;
|
export type OptionsObject<T, R = Record<string, unknown>, S = R> = T & Partial<R> & ThisType<T & S>;
|
||||||
|
|
||||||
let id = 0;
|
let id = 0;
|
||||||
/**
|
/**
|
||||||
|
|
I think the specific decorators probably belong in their own files, or in
common.tsx
if they're particularly small and useful enough to be included as part of the "base" project (as effects would be, but maybe not the bonusAmounts/completions).