mirror of
https://github.com/thepaperpilot/Advent-Incremental.git
synced 2024-11-22 00:21:34 +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 { processComputable } from "util/computed";
|
||||||
import { createLazyProxy } from "util/proxies";
|
import { createLazyProxy } from "util/proxies";
|
||||||
import { coerceComponent, isCoercableComponent } from "util/vue";
|
import { coerceComponent, isCoercableComponent } from "util/vue";
|
||||||
import type { Ref } from "vue";
|
import { isReadonly, Ref } from "vue";
|
||||||
import { computed, unref } from "vue";
|
import { computed, unref } from "vue";
|
||||||
|
|
||||||
export const BuyableType = Symbol("Buyable");
|
export const BuyableType = Symbol("Buyable");
|
||||||
|
@ -155,14 +155,18 @@ export function createBuyable<T extends BuyableOptions>(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const cost = unref(genericBuyable.cost);
|
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 = Decimal.sub(
|
||||||
genericBuyable.resource.value,
|
genericBuyable.resource.value,
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
cost!
|
cost!
|
||||||
);
|
);
|
||||||
genericBuyable.amount.value = Decimal.add(genericBuyable.amount.value, 1);
|
|
||||||
}
|
}
|
||||||
|
genericBuyable.amount.value = Decimal.add(genericBuyable.amount.value, 1);
|
||||||
genericBuyable.onPurchase?.(cost);
|
genericBuyable.onPurchase?.(cost);
|
||||||
};
|
};
|
||||||
processComputable(buyable as T, "display");
|
processComputable(buyable as T, "display");
|
||||||
|
|
Loading…
Reference in a new issue