Remove references to purchasing for repeatable

This commit is contained in:
thepaperpilot 2023-02-15 00:22:24 -06:00
parent 2de0905eeb
commit 9fb97f8f51

View file

@ -52,7 +52,6 @@ export interface RepeatableOptions {
small?: Computable<boolean>;
maximize?: Computable<boolean>;
display?: Computable<RepeatableDisplay>;
onPurchase?: VoidFunction;
}
export interface BaseRepeatable {
@ -61,7 +60,6 @@ export interface BaseRepeatable {
maxed: Ref<boolean>;
canClick: ProcessedComputable<boolean>;
onClick: VoidFunction;
purchase: VoidFunction;
type: typeof RepeatableType;
[Component]: GenericComponent;
[GatherProps]: () => Record<string, unknown>;
@ -144,23 +142,21 @@ export function createRepeatable<T extends RepeatableOptions>(
return currClasses;
});
repeatable.canClick = computed(() => requirementsMet(repeatable.requirements));
repeatable.onClick = repeatable.purchase =
repeatable.onClick ??
repeatable.purchase ??
function (this: GenericRepeatable) {
const genericRepeatable = repeatable as GenericRepeatable;
if (!unref(genericRepeatable.canClick)) {
return;
}
payRequirements(
repeatable.requirements,
unref(genericRepeatable.maximize)
? maxRequirementsMet(genericRepeatable.requirements)
: 1
);
genericRepeatable.amount.value = Decimal.add(genericRepeatable.amount.value, 1);
genericRepeatable.onPurchase?.();
};
const onClick = repeatable.onClick;
repeatable.onClick = function (this: GenericRepeatable) {
const genericRepeatable = repeatable as GenericRepeatable;
if (!unref(genericRepeatable.canClick)) {
return;
}
payRequirements(
repeatable.requirements,
unref(genericRepeatable.maximize)
? maxRequirementsMet(genericRepeatable.requirements)
: 1
);
genericRepeatable.amount.value = Decimal.add(genericRepeatable.amount.value, 1);
onClick?.();
};
processComputable(repeatable as T, "display");
const display = repeatable.display;
repeatable.display = jsx(() => {