From b7c7317876b9b4bdee17f8349788d3cdba3ed306 Mon Sep 17 00:00:00 2001 From: Jacorb90 <39597610+Jacorb90@users.noreply.github.com> Date: Mon, 2 Nov 2020 18:44:36 -0500 Subject: [PATCH] Fixed reactivity on reset --- js/game.js | 2 +- js/utils.js | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/js/game.js b/js/game.js index 3507026..a66a8b9 100644 --- a/js/game.js +++ b/js/game.js @@ -109,7 +109,7 @@ function layerDataReset(layer, keep = []) { storedData[keep[thing]] = player[layer][keep[thing]] } - player[layer] = layers[layer].startData(); + layOver(player[layer], layers[layer].startData()); player[layer].upgrades = [] player[layer].milestones = [] player[layer].challenges = getStartChallenges(layer) diff --git a/js/utils.js b/js/utils.js index c44ff02..401cc62 100644 --- a/js/utils.js +++ b/js/utils.js @@ -612,6 +612,13 @@ function goBack() { else showTab(player.lastSafeTab) } +function layOver(obj1, obj2) { + for (let x in obj2) { + if (obj2[x] instanceof Object) layOver(obj1[x], obj2[x]); + else obj1[x] = obj2[x]; + } +} + function notifyLayer(name) { if (player.tab == name || !layerunlocked(name)) return player.notify[name] = 1