From f67e18b4bf5484bf9ccf1d0db6f88a8dc7d5d327 Mon Sep 17 00:00:00 2001 From: Harley White Date: Mon, 7 Jun 2021 17:54:29 -0400 Subject: [PATCH] SheNaNigans --- changelog.md | 1 + js/game.js | 2 +- js/utils/save.js | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 859097c..2122d2d 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ - Tree branches can have custom line widths. - If an upgrade has both canAfford and cost, it checks both. (So you can use canAfford for other things) - Releasing a held buyable/clickable with onHold doesn't click it again. +- Fixed hard resetting while NaN'ed and exporting NaN saves for debugging. - Attempt to fix buttons sometimes not updating. - Improvements to theme code, partially by Cubedey. diff --git a/js/game.js b/js/game.js index 7ad2765..73bcc12 100644 --- a/js/game.js +++ b/js/game.js @@ -396,7 +396,7 @@ function hardReset(resetOptions) { if (!confirm("Are you sure you want to do this? You will lose all your progress!")) return player = null if(resetOptions) options = null - save(); + save(true); window.location.reload(); } diff --git a/js/utils/save.js b/js/utils/save.js index 6d5b32d..845f503 100644 --- a/js/utils/save.js +++ b/js/utils/save.js @@ -1,7 +1,7 @@ // ************ Save stuff ************ -function save() { +function save(force) { NaNcheck(player) - if (NaNalert) return + if (NaNalert && !force) return localStorage.setItem(modInfo.id, btoa(unescape(encodeURIComponent(JSON.stringify(player))))); localStorage.setItem(modInfo.id+"_options", btoa(unescape(encodeURIComponent(JSON.stringify(options))))); @@ -257,7 +257,7 @@ function NaNcheck(data) { } } function exportSave() { - if (NaNalert) return + //if (NaNalert) return let str = btoa(JSON.stringify(player)); const el = document.createElement("textarea"); @@ -279,6 +279,7 @@ function importSave(imported = undefined, forced = false) { player.versionType = modInfo.id; fixSave(); versionCheck(); + NaNcheck(save) save(); window.location.reload(); } catch (e) {