diff --git a/js/game.js b/js/game.js index f4e5bfe..db1e1e3 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 d5efaf6..6173f08 100644 --- a/js/utils.js +++ b/js/utils.js @@ -622,6 +622,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