From 914f932e0aa29f61ff9b4a9b2037b4631d9401db Mon Sep 17 00:00:00 2001 From: Acamaeda Date: Sat, 26 Sep 2020 23:53:03 -0400 Subject: [PATCH] Checks for missing non-layer player variables --- js/game.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/js/game.js b/js/game.js index 3115409..7a8a19b 100644 --- a/js/game.js +++ b/js/game.js @@ -4,8 +4,8 @@ var needCanvasUpdate = true; var NaNalert = false; var gameEnded = false; -function getStartPlayer() { - playerdata = { +function startPlayerBase() { + return { tab: "tree", time: Date.now(), autosave: true, @@ -20,6 +20,10 @@ function getStartPlayer() { hasNaN: false, points: new Decimal(10), } +} + +function getStartPlayer() { + playerdata = startPlayerBase() for (layer in layers){ playerdata[layer] = layers[layer].startData() } @@ -37,12 +41,17 @@ function save() { } function fixSave() { + defaultData = startPlayerBase() + for (datum in defaultData){ + if (player[datum] == undefined){ + player[datum] = defaultData[datum] + } + } for (layer in layers) { defaultData = layers[layer].startData() for (datum in defaultData){ if (player[layer][datum] == undefined){ - console.log(datum) player[layer][datum] = defaultData[datum] } }