mirror of
https://github.com/thepaperpilot/Advent-Incremental.git
synced 2024-11-21 16:13:57 +00:00
Make buyables not spend readonly resources
This commit is contained in:
parent
25322ab9e6
commit
23782e3500
1 changed files with 7 additions and 3 deletions
|
@ -21,7 +21,7 @@ import type {
|
|||
import { processComputable } from "util/computed";
|
||||
import { createLazyProxy } from "util/proxies";
|
||||
import { coerceComponent, isCoercableComponent } from "util/vue";
|
||||
import type { Ref } from "vue";
|
||||
import { isReadonly, Ref } from "vue";
|
||||
import { computed, unref } from "vue";
|
||||
|
||||
export const BuyableType = Symbol("Buyable");
|
||||
|
@ -155,14 +155,18 @@ export function createBuyable<T extends BuyableOptions>(
|
|||
return;
|
||||
}
|
||||
const cost = unref(genericBuyable.cost);
|
||||
if (genericBuyable.cost != null && genericBuyable.resource != null) {
|
||||
if (
|
||||
genericBuyable.cost != null &&
|
||||
genericBuyable.resource != null &&
|
||||
!isReadonly(genericBuyable.resource)
|
||||
) {
|
||||
genericBuyable.resource.value = Decimal.sub(
|
||||
genericBuyable.resource.value,
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
cost!
|
||||
);
|
||||
genericBuyable.amount.value = Decimal.add(genericBuyable.amount.value, 1);
|
||||
}
|
||||
genericBuyable.amount.value = Decimal.add(genericBuyable.amount.value, 1);
|
||||
genericBuyable.onPurchase?.(cost);
|
||||
};
|
||||
processComputable(buyable as T, "display");
|
||||
|
|
Loading…
Reference in a new issue