2020-10-03 19:45:47 +00:00
|
|
|
var layers = {}
|
|
|
|
|
|
|
|
function layerShown(layer){
|
|
|
|
return layers[layer].layerShown();
|
|
|
|
}
|
|
|
|
|
|
|
|
var LAYERS = Object.keys(layers);
|
|
|
|
|
|
|
|
var hotkeys = {};
|
|
|
|
|
2020-10-21 17:03:39 +00:00
|
|
|
var maxRow = 0;
|
|
|
|
|
2020-10-03 19:45:47 +00:00
|
|
|
function updateHotkeys()
|
|
|
|
{
|
|
|
|
hotkeys = {};
|
|
|
|
for (layer in layers){
|
|
|
|
hk = layers[layer].hotkeys
|
|
|
|
if (hk){
|
|
|
|
for (id in hk){
|
|
|
|
hotkeys[hk[id].key] = hk[id]
|
|
|
|
hotkeys[hk[id].key].layer = layer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var ROW_LAYERS = {}
|
2020-10-11 03:26:26 +00:00
|
|
|
var TREE_LAYERS = {}
|
2020-10-14 23:34:15 +00:00
|
|
|
var OTHER_LAYERS = {}
|
2020-10-03 19:45:47 +00:00
|
|
|
|
|
|
|
function updateLayers(){
|
|
|
|
LAYERS = Object.keys(layers);
|
|
|
|
ROW_LAYERS = {}
|
2020-10-11 03:26:26 +00:00
|
|
|
TREE_LAYERS = {}
|
2020-10-15 20:55:11 +00:00
|
|
|
OTHER_LAYERS = {}
|
2020-10-03 19:45:47 +00:00
|
|
|
for (layer in layers){
|
|
|
|
layers[layer].layer = layer
|
|
|
|
if (layers[layer].upgrades){
|
|
|
|
for (thing in layers[layer].upgrades){
|
|
|
|
if (!isNaN(thing)){
|
|
|
|
layers[layer].upgrades[thing].id = thing
|
|
|
|
layers[layer].upgrades[thing].layer = layer
|
2020-10-13 03:08:19 +00:00
|
|
|
if (layers[layer].upgrades[thing].unlocked === undefined)
|
|
|
|
layers[layer].upgrades[thing].unlocked = true
|
2020-10-03 19:45:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (layers[layer].milestones){
|
|
|
|
for (thing in layers[layer].milestones){
|
|
|
|
if (!isNaN(thing)){
|
|
|
|
layers[layer].milestones[thing].id = thing
|
|
|
|
layers[layer].milestones[thing].layer = layer
|
2020-10-13 03:08:19 +00:00
|
|
|
if (layers[layer].milestones[thing].unlocked === undefined)
|
|
|
|
layers[layer].milestones[thing].unlocked = true
|
2020-10-03 19:45:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-15 01:43:16 +00:00
|
|
|
if (layers[layer].achievements){
|
|
|
|
for (thing in layers[layer].achievements){
|
|
|
|
if (!isNaN(thing)){
|
|
|
|
layers[layer].achievements[thing].id = thing
|
|
|
|
layers[layer].achievements[thing].layer = layer
|
|
|
|
if (layers[layer].achievements[thing].unlocked === undefined)
|
|
|
|
layers[layer].achievements[thing].unlocked = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-13 03:08:19 +00:00
|
|
|
if (layers[layer].challenges){
|
|
|
|
for (thing in layers[layer].challenges){
|
2020-10-03 19:45:47 +00:00
|
|
|
if (!isNaN(thing)){
|
2020-10-13 03:08:19 +00:00
|
|
|
layers[layer].challenges[thing].id = thing
|
|
|
|
layers[layer].challenges[thing].layer = layer
|
|
|
|
if (layers[layer].challenges[thing].unlocked === undefined)
|
|
|
|
layers[layer].challenges[thing].unlocked = true
|
|
|
|
if (layers[layer].challenges[thing].completionLimit === undefined)
|
|
|
|
layers[layer].challenges[thing].completionLimit = 1
|
2020-10-11 20:42:32 +00:00
|
|
|
|
2020-10-03 19:45:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (layers[layer].buyables){
|
|
|
|
layers[layer].buyables.layer = layer
|
|
|
|
for (thing in layers[layer].buyables){
|
|
|
|
if (!isNaN(thing)){
|
|
|
|
layers[layer].buyables[thing].id = thing
|
|
|
|
layers[layer].buyables[thing].layer = layer
|
2020-10-13 03:08:19 +00:00
|
|
|
if (layers[layer].buyables[thing].unlocked === undefined)
|
|
|
|
layers[layer].buyables[thing].unlocked = true
|
2020-10-03 19:45:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-11 20:16:36 +00:00
|
|
|
if (layers[layer].clickables){
|
|
|
|
layers[layer].clickables.layer = layer
|
|
|
|
for (thing in layers[layer].clickables){
|
|
|
|
if (!isNaN(thing)){
|
|
|
|
layers[layer].clickables[thing].id = thing
|
|
|
|
layers[layer].clickables[thing].layer = layer
|
2020-10-13 03:08:19 +00:00
|
|
|
if (layers[layer].clickables[thing].unlocked === undefined)
|
|
|
|
layers[layer].clickables[thing].unlocked = true
|
2020-10-11 20:16:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-12 22:28:12 +00:00
|
|
|
if (layers[layer].bars){
|
|
|
|
layers[layer].bars.layer = layer
|
|
|
|
for (thing in layers[layer].bars){
|
2020-10-13 03:28:02 +00:00
|
|
|
layers[layer].bars[thing].id = thing
|
|
|
|
layers[layer].bars[thing].layer = layer
|
|
|
|
if (layers[layer].bars[thing].unlocked === undefined)
|
|
|
|
layers[layer].bars[thing].unlocked = true
|
2020-10-25 22:21:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (layers[layer].infoboxes){
|
|
|
|
for (thing in layers[layer].infoboxes){
|
|
|
|
layers[layer].infoboxes[thing].id = thing
|
|
|
|
layers[layer].infoboxes[thing].layer = layer
|
|
|
|
if (layers[layer].infoboxes[thing].unlocked === undefined)
|
|
|
|
layers[layer].infoboxes[thing].unlocked = true
|
2020-10-12 22:28:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-07 20:41:45 +00:00
|
|
|
if(!layers[layer].componentStyles) layers[layer].componentStyles = {}
|
2020-10-11 03:26:26 +00:00
|
|
|
if(layers[layer].symbol === undefined) layers[layer].symbol = layer.charAt(0).toUpperCase() + layer.slice(1)
|
2020-10-21 20:14:42 +00:00
|
|
|
if(layers[layer].unlockOrder === undefined) layers[layer].unlockOrder = []
|
|
|
|
if(layers[layer].gainMult === undefined) layers[layer].gainMult = new Decimal(1)
|
|
|
|
if(layers[layer].gainExp === undefined) layers[layer].gainExp = new Decimal(1)
|
2020-10-26 02:25:42 +00:00
|
|
|
if(layers[layer].type === undefined) layers[layer].type = "none"
|
2020-10-26 03:00:32 +00:00
|
|
|
if(layers[layer].base === undefined || layers[layer].base <= 1) layers[layer].base = 2
|
2020-10-07 20:41:45 +00:00
|
|
|
|
2020-10-21 17:03:39 +00:00
|
|
|
let row = layers[layer].row
|
2020-10-03 19:45:47 +00:00
|
|
|
if(!ROW_LAYERS[row]) ROW_LAYERS[row] = {}
|
2020-10-14 23:34:15 +00:00
|
|
|
if(!TREE_LAYERS[row] && !isNaN(row)) TREE_LAYERS[row] = []
|
|
|
|
if(!OTHER_LAYERS[row] && isNaN(row)) OTHER_LAYERS[row] = []
|
|
|
|
|
2020-10-03 19:45:47 +00:00
|
|
|
ROW_LAYERS[row][layer]=layer;
|
2020-10-11 03:26:26 +00:00
|
|
|
let position = (layers[layer].position !== undefined ? layers[layer].position : layer)
|
2020-10-14 23:34:15 +00:00
|
|
|
|
|
|
|
if (!isNaN(row)) TREE_LAYERS[row].push({layer: layer, position: position})
|
|
|
|
else OTHER_LAYERS[row].push({layer: layer, position: position})
|
2020-10-21 17:03:39 +00:00
|
|
|
|
|
|
|
if (maxRow < layers[layer].row) maxRow = layers[layer].row
|
2020-10-11 03:26:26 +00:00
|
|
|
|
|
|
|
}
|
2020-10-15 20:55:11 +00:00
|
|
|
for (row in OTHER_LAYERS) {
|
|
|
|
OTHER_LAYERS[row].sort((a, b) => (a.position > b.position) ? 1 : -1)
|
|
|
|
}
|
2020-10-11 03:26:26 +00:00
|
|
|
for (row in TREE_LAYERS) {
|
|
|
|
TREE_LAYERS[row].sort((a, b) => (a.position > b.position) ? 1 : -1)
|
2020-10-03 19:45:47 +00:00
|
|
|
}
|
|
|
|
updateHotkeys()
|
|
|
|
}
|
|
|
|
|
|
|
|
function addLayer(layerName, layerData){ // Call this to add layers from a different file!
|
|
|
|
layers[layerName] = layerData
|
|
|
|
}
|
|
|
|
|
|
|
|
// If data is a function, return the result of calling it. Otherwise, return the data.
|
|
|
|
function readData(data, args=null){
|
|
|
|
if (!!(data && data.constructor && data.call && data.apply))
|
|
|
|
return data(args);
|
|
|
|
else
|
|
|
|
return data;
|
2020-10-09 03:13:15 +00:00
|
|
|
}
|
|
|
|
|
2020-10-11 03:26:26 +00:00
|
|
|
function someLayerUnlocked(row){
|
|
|
|
for (layer in ROW_LAYERS[row])
|
2020-10-13 03:08:19 +00:00
|
|
|
if (player[layer].unlocked)
|
2020-10-11 03:26:26 +00:00
|
|
|
return true
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-10-12 22:28:12 +00:00
|
|
|
|
2020-10-09 03:13:15 +00:00
|
|
|
// This isn't worth making a .ts file over
|
2020-10-12 22:28:12 +00:00
|
|
|
const UP = 0
|
|
|
|
const DOWN = 1
|
|
|
|
const LEFT = 2
|
|
|
|
const RIGHT = 3
|