diff --git a/src/features/resources/resource.ts b/src/features/resources/resource.ts index 5cc9cdd..019a3d7 100644 --- a/src/features/resources/resource.ts +++ b/src/features/resources/resource.ts @@ -3,8 +3,9 @@ import type { State } from "game/persistence"; import { persistent } from "game/persistence"; import type { DecimalSource } from "util/bignum"; import Decimal, { format, formatWhole } from "util/bignum"; +import type { ProcessedComputable } from "util/computed"; import type { ComputedRef, Ref } from "vue"; -import { computed, isRef, ref, watch } from "vue"; +import { computed, isRef, ref, unref, watch } from "vue"; export interface Resource extends Ref { displayName: string; @@ -114,3 +115,10 @@ export function displayResource(resource: Resource, overrideAmount?: DecimalSour } return format(amount, resource.precision, resource.small); } + +export function unwrapResource(resource: ProcessedComputable): Resource { + if ("displayName" in resource) { + return resource; + } + return unref(resource); +}