1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2025-02-26 00:11:41 +00:00
The-Modding-Tree/js/technical/temp.js

178 lines
5.1 KiB
JavaScript
Raw Normal View History

var tmp = {}
2020-12-03 23:19:14 -05:00
var temp = tmp // Proxy for tmp
var funcs = {}
2020-10-27 17:41:35 -04:00
var NaNalert = false;
2020-10-07 18:41:03 -04:00
// Tmp will not call these
var activeFunctions = [
"startData", "onPrestige", "doReset", "update", "automate",
"buy", "buyMax", "respec", "onPress", "onClick", "onHold", "masterButtonPress",
"sellOne", "sellAll", "pay", "actualCostFunction", "actualEffectFunction",
2021-05-02 22:39:38 -04:00
"effectDescription", "display", "fullDisplay", "effectDisplay", "rewardDisplay",
"tabFormat", "content",
2021-06-02 16:45:05 -04:00
"onComplete", "onPurchase", "onEnter", "onExit", "done",
"getUnlocked", "getStyle", "getCanClick", "getTitle", "getDisplay"
]
2020-10-07 16:41:45 -04:00
2020-10-17 00:21:59 -04:00
var noCall = doNotCallTheseFunctionsEveryTick
for (item in noCall) {
activeFunctions.push(noCall[item])
}
2020-11-30 21:58:42 -05:00
// Add the names of classes to traverse
var traversableClasses = []
function setupTemp() {
tmp = {}
tmp.pointGen = {}
2021-06-06 23:51:50 -04:00
tmp.backgroundStyle = {}
tmp.displayThings = []
2021-01-24 19:05:01 -05:00
tmp.scrolled = 0
funcs = {}
2021-01-24 19:05:01 -05:00
setupTempData(layers, tmp, funcs)
for (layer in layers){
tmp[layer].resetGain = {}
tmp[layer].nextAt = {}
tmp[layer].nextAtDisp = {}
tmp[layer].canReset = {}
2020-11-07 23:34:53 -05:00
tmp[layer].notify = {}
tmp[layer].prestigeNotify = {}
tmp[layer].computedNodeStyle = []
setupBuyables(layer)
2021-05-07 19:24:32 -04:00
tmp[layer].trueGlowColor = []
2020-10-08 23:13:15 -04:00
}
tmp.other = {
2021-05-10 20:19:29 -04:00
lastPoints: player.points || decimalZero,
oomps: decimalZero,
2021-05-17 21:51:36 -04:00
screenWidth: 0,
screenHeight: 0,
}
2021-05-10 18:27:37 -04:00
updateWidth()
2020-12-03 23:19:14 -05:00
temp = tmp
}
2021-06-14 01:37:12 -04:00
const boolNames = ["unlocked", "deactivated"]
function setupTempData(layerData, tmpData, funcsData) {
for (item in layerData){
if (layerData[item] == null) {
tmpData[item] = null
2020-09-13 22:41:42 -04:00
}
else if (layerData[item] instanceof Decimal)
tmpData[item] = layerData[item]
else if (Array.isArray(layerData[item])) {
tmpData[item] = []
funcsData[item] = []
setupTempData(layerData[item], tmpData[item], funcsData[item])
2020-10-03 15:45:47 -04:00
}
else if ((!!layerData[item]) && (layerData[item].constructor === Object)) {
tmpData[item] = {}
funcsData[item] = []
setupTempData(layerData[item], tmpData[item], funcsData[item])
2020-10-07 16:41:45 -04:00
}
2020-11-30 21:58:42 -05:00
else if ((!!layerData[item]) && (typeof layerData[item] === "object") && traversableClasses.includes(layerData[item].constructor.name)) {
tmpData[item] = new layerData[item].constructor()
funcsData[item] = new layerData[item].constructor()
2020-11-30 21:58:42 -05:00
}
else if (isFunction(layerData[item]) && !activeFunctions.includes(item)){
funcsData[item] = layerData[item]
2021-06-14 01:37:12 -04:00
if (boolNames.includes(item))
tmpData[item] = false
else
tmpData[item] = decimalOne // The safest thing to put probably?
} else {
tmpData[item] = layerData[item]
}
}
}
2021-06-02 17:39:19 -04:00
function updateTemp() {
if (tmp === undefined)
setupTemp()
updateTempData(layers, tmp, funcs)
for (layer in layers){
tmp[layer].resetGain = getResetGain(layer)
tmp[layer].nextAt = getNextAt(layer)
tmp[layer].nextAtDisp = getNextAt(layer, true)
tmp[layer].canReset = canReset(layer)
2021-05-07 19:24:32 -04:00
tmp[layer].trueGlowColor = tmp[layer].glowColor
2020-11-07 23:34:53 -05:00
tmp[layer].notify = shouldNotify(layer)
tmp[layer].prestigeNotify = prestigeNotify(layer)
2021-06-08 19:39:23 -04:00
if (tmp[layer].passiveGeneration === true) tmp[layer].passiveGeneration = 1 // new Decimal(true) = decimalZero
2021-06-02 17:39:19 -04:00
}
tmp.pointGen = getPointGen()
2021-06-06 23:51:50 -04:00
tmp.backgroundStyle = readData(backgroundStyle)
tmp.displayThings = []
for (thing in displayThings){
let text = displayThings[thing]
if (isFunction(text)) text = text()
tmp.displayThings.push(text)
}
}
2021-06-01 14:56:33 -04:00
function updateTempData(layerData, tmpData, funcsData, useThis) {
for (item in funcsData){
if (Array.isArray(layerData[item])) {
2021-05-19 12:30:02 -04:00
if (item !== "tabFormat" && item !== "content") // These are only updated when needed
2021-06-01 14:56:33 -04:00
updateTempData(layerData[item], tmpData[item], funcsData[item], useThis)
2020-10-03 15:45:47 -04:00
}
2020-11-30 21:58:42 -05:00
else if ((!!layerData[item]) && (layerData[item].constructor === Object) || (typeof layerData[item] === "object") && traversableClasses.includes(layerData[item].constructor.name)){
2021-06-01 14:56:33 -04:00
updateTempData(layerData[item], tmpData[item], funcsData[item], useThis)
2020-10-08 23:13:15 -04:00
}
else if (isFunction(layerData[item]) && !isFunction(tmpData[item])){
2021-06-01 14:56:33 -04:00
let value
if (useThis !== undefined) value = layerData[item].bind(useThis)()
else value = layerData[item]()
2021-05-07 09:47:25 -04:00
Vue.set(tmpData, item, value)
}
}
}
function updateChallengeTemp(layer)
{
updateTempData(layers[layer].challenges, tmp[layer].challenges, funcs[layer].challenges)
2020-12-03 23:19:14 -05:00
}
function updateBuyableTemp(layer)
{
updateTempData(layers[layer].buyables, tmp[layer].buyables, funcs[layer].buyables)
2020-10-11 16:16:36 -04:00
}
function updateClickableTemp(layer)
{
updateTempData(layers[layer].clickables, tmp[layer].clickables, funcs[layer].clickables)
2020-10-12 18:28:12 -04:00
}
function setupBuyables(layer) {
for (id in layers[layer].buyables) {
2021-05-13 01:44:40 -04:00
if (isPlainObject(layers[layer].buyables[id])) {
let b = layers[layer].buyables[id]
b.actualCostFunction = b.cost
b.cost = function(x) {
x = (x === undefined ? player[this.layer].buyables[this.id] : x)
return layers[this.layer].buyables[this.id].actualCostFunction(x)
}
b.actualEffectFunction = b.effect
b.effect = function(x) {
x = (x === undefined ? player[this.layer].buyables[this.id] : x)
return layers[this.layer].buyables[this.id].actualEffectFunction(x)
}
}
}
2021-06-02 17:39:19 -04:00
}
function checkDecimalNaN(x) {
return (x instanceof Decimal) && !x.eq(x)
2020-08-21 15:02:34 -04:00
}