From f5a25b2c2d74c594c347ddf0f89a225f378b7a0e Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Wed, 28 Dec 2022 09:03:51 -0600 Subject: [PATCH] Fix NaN detection Also removes the proxy around player and cleaned up types --- src/components/NaNScreen.vue | 53 ++++++++++--------- src/components/SavesManager.vue | 13 +++-- src/data/projEntry.tsx | 6 +-- src/game/persistence.ts | 67 +++++++++++++++++------ src/game/player.ts | 94 +++------------------------------ src/game/state.ts | 6 ++- src/util/computed.ts | 16 +++--- src/util/proxies.ts | 16 +++++- src/util/save.ts | 17 +++--- 9 files changed, 130 insertions(+), 158 deletions(-) diff --git a/src/components/NaNScreen.vue b/src/components/NaNScreen.vue index 76a7b75..511d1b6 100644 --- a/src/components/NaNScreen.vue +++ b/src/components/NaNScreen.vue @@ -14,9 +14,12 @@
- + discord - {{ discordName }} + {{ discordName || "The Paper Pilot Community" }}

@@ -50,49 +53,51 @@ import state from "game/state"; import type { DecimalSource } from "util/bignum"; import Decimal, { format } from "util/bignum"; import type { ComponentPublicInstance } from "vue"; -import { computed, ref, toRef } from "vue"; +import { computed, ref, toRef, watch } from "vue"; import Toggle from "./fields/Toggle.vue"; import SavesManager from "./SavesManager.vue"; const { discordName, discordLink } = projInfo; -const autosave = toRef(player, "autosave"); +const autosave = ref(true); +const isPaused = ref(true); const hasNaN = toRef(state, "hasNaN"); const savesManager = ref | null>(null); -const path = computed(() => state.NaNPath?.join(".")); -const property = computed(() => state.NaNPath?.slice(-1)[0]); -const previous = computed(() => { - if (state.NaNReceiver && property.value != null) { - return state.NaNReceiver[property.value] as DecimalSource; - } - return null; -}); -const isPaused = computed({ - get() { - return player.devSpeed === 0; - }, - set(value: boolean) { - player.devSpeed = value ? null : 0; +watch(hasNaN, hasNaN => { + if (hasNaN) { + autosave.value = player.autosave; + isPaused.value = player.devSpeed === 0; + } else { + player.autosave = autosave.value; + player.devSpeed = isPaused.value ? 0 : null; } }); +const path = computed(() => state.NaNPath?.join(".")); +const previous = computed(() => { + if (state.NaNPersistent != null) { + return state.NaNPersistent.value; + } + return null; +}); + function setZero() { - if (state.NaNReceiver && property.value != null) { - state.NaNReceiver[property.value] = new Decimal(0); + if (state.NaNPersistent != null) { + state.NaNPersistent.value = new Decimal(0); state.hasNaN = false; } } function setOne() { - if (state.NaNReceiver && property.value != null) { - state.NaNReceiver[property.value] = new Decimal(1); + if (state.NaNPersistent) { + state.NaNPersistent.value = new Decimal(1); state.hasNaN = false; } } function ignore() { - if (state.NaNReceiver && property.value != null) { - state.NaNReceiver[property.value] = new Decimal(NaN); + if (state.NaNPersistent) { + state.NaNPersistent.value = new Decimal(NaN); state.hasNaN = false; } } diff --git a/src/components/SavesManager.vue b/src/components/SavesManager.vue index 37b4d5b..91edd40 100644 --- a/src/components/SavesManager.vue +++ b/src/components/SavesManager.vue @@ -59,11 +59,10 @@