Made buyables default to infinite purchase limit

This commit is contained in:
thepaperpilot 2022-03-11 09:16:19 -06:00
parent d8edac1c9a
commit e5da55d26a

View file

@ -68,7 +68,7 @@ export type Buyable<T extends BuyableOptions> = Replace<
cost: GetComputableType<T["cost"]>; cost: GetComputableType<T["cost"]>;
resource: GetComputableType<T["resource"]>; resource: GetComputableType<T["resource"]>;
canPurchase: GetComputableTypeWithDefault<T["canPurchase"], Ref<boolean>>; canPurchase: GetComputableTypeWithDefault<T["canPurchase"], Ref<boolean>>;
purchaseLimit: GetComputableTypeWithDefault<T["purchaseLimit"], 1>; purchaseLimit: GetComputableTypeWithDefault<T["purchaseLimit"], Decimal>;
classes: GetComputableType<T["classes"]>; classes: GetComputableType<T["classes"]>;
style: GetComputableType<T["style"]>; style: GetComputableType<T["style"]>;
mark: GetComputableType<T["mark"]>; mark: GetComputableType<T["mark"]>;
@ -172,6 +172,16 @@ export function createBuyable<T extends BuyableOptions>(
const Title = coerceComponent(currDisplay.title || "", "h3"); const Title = coerceComponent(currDisplay.title || "", "h3");
const Description = coerceComponent(currDisplay.description); const Description = coerceComponent(currDisplay.description);
const EffectDisplay = coerceComponent(currDisplay.effectDisplay || ""); const EffectDisplay = coerceComponent(currDisplay.effectDisplay || "");
const amountDisplay =
unref(genericBuyable.purchaseLimit) === Decimal.dInf ? (
<>Amount: {formatWhole(genericBuyable.amount.value)}</>
) : (
<>
Amount: {formatWhole(genericBuyable.amount.value)} /{" "}
{formatWhole(unref(genericBuyable.purchaseLimit))}
</>
);
return ( return (
<span> <span>
{currDisplay.title ? ( {currDisplay.title ? (
@ -182,8 +192,7 @@ export function createBuyable<T extends BuyableOptions>(
<Description /> <Description />
<div> <div>
<br /> <br />
Amount: {formatWhole(genericBuyable.amount.value)} /{" "} {amountDisplay}
{formatWhole(unref(genericBuyable.purchaseLimit))}
</div> </div>
{currDisplay.effectDisplay ? ( {currDisplay.effectDisplay ? (
<div> <div>
@ -209,7 +218,7 @@ export function createBuyable<T extends BuyableOptions>(
processComputable(buyable as T, "cost"); processComputable(buyable as T, "cost");
processComputable(buyable as T, "resource"); processComputable(buyable as T, "resource");
processComputable(buyable as T, "purchaseLimit"); processComputable(buyable as T, "purchaseLimit");
setDefault(buyable, "purchaseLimit", 1); setDefault(buyable, "purchaseLimit", Decimal.dInf);
processComputable(buyable as T, "style"); processComputable(buyable as T, "style");
processComputable(buyable as T, "mark"); processComputable(buyable as T, "mark");
processComputable(buyable as T, "small"); processComputable(buyable as T, "small");