diff --git a/src/features/achievements/achievement.tsx b/src/features/achievements/achievement.tsx index 3a9320e..6a628cb 100644 --- a/src/features/achievements/achievement.tsx +++ b/src/features/achievements/achievement.tsx @@ -160,6 +160,9 @@ export function createAchievement( achievement.earned = earned; achievement.complete = function () { + if (earned.value) { + return; + } earned.value = true; const genericAchievement = achievement as GenericAchievement; genericAchievement.onComplete?.(); diff --git a/src/features/reset.ts b/src/features/reset.ts index 2811ba8..2b31e64 100644 --- a/src/features/reset.ts +++ b/src/features/reset.ts @@ -1,8 +1,9 @@ import type { OptionsFunc, Replace } from "features/feature"; import { getUniqueID } from "features/feature"; import { globalBus } from "game/events"; +import Formula from "game/formulas/formulas"; import type { BaseLayer } from "game/layers"; -import type { NonPersistent, Persistent } from "game/persistence"; +import { NonPersistent, Persistent, SkipPersistence } from "game/persistence"; import { DefaultValue, persistent } from "game/persistence"; import type { Unsubscribe } from "nanoevents"; import Decimal from "util/bignum"; @@ -61,7 +62,15 @@ export function createReset( reset.reset = function () { const handleObject = (obj: unknown) => { - if (obj != null && typeof obj === "object") { + if ( + obj != null && + typeof obj === "object" && + !(obj instanceof Decimal) && + !(obj instanceof Formula) + ) { + if (SkipPersistence in obj && obj[SkipPersistence] === true) { + return; + } if (DefaultValue in obj) { const persistent = obj as NonPersistent; persistent.value = persistent[DefaultValue]; diff --git a/src/game/persistence.ts b/src/game/persistence.ts index 712f989..a61d9cf 100644 --- a/src/game/persistence.ts +++ b/src/game/persistence.ts @@ -9,6 +9,7 @@ import type { Ref, WritableComputedRef } from "vue"; import { computed, isReactive, isRef, ref } from "vue"; import player from "./player"; import state from "./state"; +import Formula from "./formulas/formulas"; /** * A symbol used in {@link Persistent} objects. @@ -325,6 +326,7 @@ globalBus.on("addLayer", (layer: GenericLayer, saveData: Record } } else if ( !(value instanceof Decimal) && + !(value instanceof Formula) && !isRef(value) && // eslint-disable-next-line @typescript-eslint/no-explicit-any !features.includes(value as { type: typeof Symbol })