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 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]
}
}