1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-25 18:00:10 +00:00
The-Modding-Tree/js/temp.js

141 lines
3.6 KiB
JavaScript
Raw Normal View History

var tmp = {}
2020-10-07 22:41:03 +00:00
// Tmp will not call these
var activeFunctions = [
"startData", "onPrestige", "doReset", "update", "automate",
2020-10-11 20:16:36 +00:00
"buy", "buyMax", "respec", "onComplete", "onPurchase", "onPress", "onClick", "masterButtonPress"
]
2020-10-07 20:41:45 +00:00
function setupTemp() {
tmp = {}
setupTempData(layers, tmp)
2020-09-10 02:44:25 +00:00
for (layer in layers){
tmp[layer].resetGain = {}
tmp[layer].nextAt = {}
tmp[layer].nextAtDisp = {}
tmp[layer].notify = {}
tmp[layer].canReset = {}
tmp[layer].prestigeButtonText = {}
2020-10-12 22:28:12 +00:00
setupBarStyles(layer)
2020-10-09 03:13:15 +00:00
}
}
function setupTempData(layerData, tmpData) {
tmp.pointGen = {}
for (item in layerData){
if (layerData[item] == null) {
tmpData[item] = null
2020-09-14 02:41:42 +00:00
}
else if (layerData[item] instanceof Decimal)
tmpData[item] = layerData[item]
else if (Array.isArray(layerData[item])) {
tmpData[item] = []
setupTempData(layerData[item], tmpData[item])
2020-10-03 19:45:47 +00:00
}
else if ((!!layerData[item]) && (layerData[item].constructor === Object)) {
tmpData[item] = {}
setupTempData(layerData[item], tmpData[item])
2020-10-07 20:41:45 +00:00
}
else if (isFunction(layerData[item]) && !activeFunctions.includes(item)){
tmpData[item] = new Decimal(1) // The safest thing to put probably?
} else {
tmpData[item] = layerData[item]
}
}
}
function updateTemp() {
if (tmp === undefined)
setupTemp()
updateTempData(layers, tmp)
for (layer in layers){
tmp[layer].resetGain = getResetGain(layer)
tmp[layer].nextAt = getNextAt(layer)
tmp[layer].nextAtDisp = getNextAt(layer, true)
tmp[layer].notify = shouldNotify(layer)
tmp[layer].canReset = canReset(layer)
tmp[layer].prestigeButtonText = prestigeButtonText(layer)
2020-10-12 22:28:12 +00:00
constructBarStyles(layer)
}
tmp.pointGen = getPointGen()
}
function updateTempData(layerData, tmpData) {
for (item in layerData){
if (Array.isArray(layerData[item])) {
updateTempData(layerData[item], tmpData[item])
2020-10-03 19:45:47 +00:00
}
else if ((!!layerData[item]) && (layerData[item].constructor === Object)) {
updateTempData(layerData[item], tmpData[item])
2020-10-09 03:13:15 +00:00
}
else if (isFunction(layerData[item]) && !activeFunctions.includes(item)){
Vue.set(tmpData, item, layerData[item]())
}
}
}
function updateChallTemp(layer)
{
updateTempData(layers[layer].challs, tmp[layer].challs)
}
function updateBuyableTemp(layer)
{
updateTempData(layers[layer].buyables, tmp[layer].buyables)
2020-10-11 20:16:36 +00:00
}
function updateClickableTemp(layer)
{
updateTempData(layers[layer].clickables, tmp[layer].clickables)
2020-10-12 22:28:12 +00:00
}
var DIR_MARGINS = ["margin-bottom", "margin-top", "margin-right", "margin-left"]
function constructBarStyles(layer){
if (layers[layer].bars === undefined)
return
for (id in layers[layer].bars){
if (id !== "layer") {
let bar = tmp[layer].bars[id]
if (bar.progress instanceof Decimal)
bar.progress = bar.progress.toNumber()
bar.dims = {'width': bar.width + "px", 'height': bar.height + "px"}
let dir = bar.direction
bar.fillDims = {'width': bar.width + "px", 'height': bar.height + "px"}
if (dir !== undefined)
{
bar.fillDims[DIR_MARGINS[dir]] = "0px"
if (dir == UP || dir == DOWN)
{
bar.fillDims.height = bar.height * Math.min(bar.progress, 1) + "px"
if (dir == UP) bar.fillDims['margin-top'] = bar.height * (1 - Math.min(bar.progress, 1)) + "px"
}
else
{
bar.fillDims.width = bar.width * Math.min(bar.progress, 1) + "px"
if (dir == LEFT) bar.fillDims['margin-left'] = bar.width * (1 - Math.min(bar.progress, 1)) + "px"
}
}
}
}
}
function setupBarStyles(layer){
if (layers[layer].bars === undefined)
return
for (id in layers[layer].bars){
let bar = tmp[layer].bars[id]
bar.dims = {}
let dir = bar.direction
bar.fillDims = {}
}
2020-08-21 19:02:34 +00:00
}