From e5da55d26a3a801601a4c8fc80bd86129ea4c9fa Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Fri, 11 Mar 2022 09:16:19 -0600 Subject: [PATCH] Made buyables default to infinite purchase limit --- src/features/buyable.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/features/buyable.tsx b/src/features/buyable.tsx index 1ab8a83..cf49443 100644 --- a/src/features/buyable.tsx +++ b/src/features/buyable.tsx @@ -68,7 +68,7 @@ export type Buyable = Replace< cost: GetComputableType; resource: GetComputableType; canPurchase: GetComputableTypeWithDefault>; - purchaseLimit: GetComputableTypeWithDefault; + purchaseLimit: GetComputableTypeWithDefault; classes: GetComputableType; style: GetComputableType; mark: GetComputableType; @@ -172,6 +172,16 @@ export function createBuyable( const Title = coerceComponent(currDisplay.title || "", "h3"); const Description = coerceComponent(currDisplay.description); 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 ( {currDisplay.title ? ( @@ -182,8 +192,7 @@ export function createBuyable(

- Amount: {formatWhole(genericBuyable.amount.value)} /{" "} - {formatWhole(unref(genericBuyable.purchaseLimit))} + {amountDisplay}
{currDisplay.effectDisplay ? (
@@ -209,7 +218,7 @@ export function createBuyable( processComputable(buyable as T, "cost"); processComputable(buyable as T, "resource"); processComputable(buyable as T, "purchaseLimit"); - setDefault(buyable, "purchaseLimit", 1); + setDefault(buyable, "purchaseLimit", Decimal.dInf); processComputable(buyable as T, "style"); processComputable(buyable as T, "mark"); processComputable(buyable as T, "small");