1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-24 09:21:46 +00:00

Checks for missing non-layer player variables

This commit is contained in:
Acamaeda 2020-09-26 23:53:03 -04:00
parent 63060535e2
commit 914f932e0a

View file

@ -4,8 +4,8 @@ var needCanvasUpdate = true;
var NaNalert = false; var NaNalert = false;
var gameEnded = false; var gameEnded = false;
function getStartPlayer() { function startPlayerBase() {
playerdata = { return {
tab: "tree", tab: "tree",
time: Date.now(), time: Date.now(),
autosave: true, autosave: true,
@ -20,6 +20,10 @@ function getStartPlayer() {
hasNaN: false, hasNaN: false,
points: new Decimal(10), points: new Decimal(10),
} }
}
function getStartPlayer() {
playerdata = startPlayerBase()
for (layer in layers){ for (layer in layers){
playerdata[layer] = layers[layer].startData() playerdata[layer] = layers[layer].startData()
} }
@ -37,12 +41,17 @@ function save() {
} }
function fixSave() { function fixSave() {
defaultData = startPlayerBase()
for (datum in defaultData){
if (player[datum] == undefined){
player[datum] = defaultData[datum]
}
}
for (layer in layers) { for (layer in layers) {
defaultData = layers[layer].startData() defaultData = layers[layer].startData()
for (datum in defaultData){ for (datum in defaultData){
if (player[layer][datum] == undefined){ if (player[layer][datum] == undefined){
console.log(datum)
player[layer][datum] = defaultData[datum] player[layer][datum] = defaultData[datum]
} }
} }