From 753ce5f8dec5e349bbcba51b378e3407e6ede449 Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Tue, 29 Nov 2022 08:12:46 -0600 Subject: [PATCH] Add initialValue to Buyables --- src/features/buyable.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/features/buyable.tsx b/src/features/buyable.tsx index c2f9972..1b8723c 100644 --- a/src/features/buyable.tsx +++ b/src/features/buyable.tsx @@ -2,7 +2,7 @@ import ClickableComponent from "features/clickables/Clickable.vue"; import type { CoercableComponent, OptionsFunc, Replace, StyleValue } from "features/feature"; import { Component, GatherProps, getUniqueID, jsx, setDefault, Visibility } from "features/feature"; import type { Resource } from "features/resources/resource"; -import type { Persistent } from "game/persistence"; +import { DefaultValue, Persistent } from "game/persistence"; import { persistent } from "game/persistence"; import type { DecimalSource } from "util/bignum"; import Decimal, { format, formatWhole } from "util/bignum"; @@ -35,6 +35,7 @@ export interface BuyableOptions { resource?: Resource; canPurchase?: Computable; purchaseLimit?: Computable; + initialValue?: DecimalSource; classes?: Computable>; style?: Computable; mark?: Computable; @@ -101,6 +102,7 @@ export function createBuyable( buyable[Component] = ClickableComponent; buyable.amount = amount; + buyable.amount[DefaultValue] = buyable.initialValue ?? 0; buyable.canAfford = computed(() => { const genericBuyable = buyable as GenericBuyable; const cost = unref(genericBuyable.cost);