1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-22 08:31:33 +00:00
The-Modding-Tree/js/technical/temp.js

179 lines
5.1 KiB
JavaScript
Raw Normal View History

var tmp = {}
2020-12-04 04:19:14 +00:00
var temp = tmp // Proxy for tmp
var funcs = {}
2020-10-27 21:41:35 +00:00
var NaNalert = false;
2020-10-07 22:41:03 +00: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-03 02:39:38 +00:00
"effectDescription", "display", "fullDisplay", "effectDisplay", "rewardDisplay",
"tabFormat", "content",
2021-06-02 20:45:05 +00:00
"onComplete", "onPurchase", "onEnter", "onExit", "done",
"getUnlocked", "getStyle", "getCanClick", "getTitle", "getDisplay"
]
2020-10-07 20:41:45 +00:00
2020-10-17 04:21:59 +00:00
var noCall = doNotCallTheseFunctionsEveryTick
for (item in noCall) {
activeFunctions.push(noCall[item])
}
2020-12-01 02:58:42 +00:00
// Add the names of classes to traverse
var traversableClasses = []
function setupTemp() {
tmp = {}
tmp.pointGen = {}
2021-06-07 03:51:50 +00:00
tmp.backgroundStyle = {}
tmp.displayThings = []
2021-01-25 00:05:01 +00:00
tmp.scrolled = 0
2021-06-17 17:40:55 +00:00
tmp.gameEnded = false
funcs = {}
2021-01-25 00:05:01 +00:00
setupTempData(layers, tmp, funcs)
for (layer in layers){
tmp[layer].resetGain = {}
tmp[layer].nextAt = {}
tmp[layer].nextAtDisp = {}
tmp[layer].canReset = {}
2020-11-08 04:34:53 +00:00
tmp[layer].notify = {}
tmp[layer].prestigeNotify = {}
tmp[layer].computedNodeStyle = []
setupBuyables(layer)
2021-05-07 23:24:32 +00:00
tmp[layer].trueGlowColor = []
2020-10-09 03:13:15 +00:00
}
tmp.other = {
2021-05-11 00:19:29 +00:00
lastPoints: player.points || decimalZero,
oomps: decimalZero,
2021-05-18 01:51:36 +00:00
screenWidth: 0,
screenHeight: 0,
}
2021-05-10 22:27:37 +00:00
updateWidth()
2020-12-04 04:19:14 +00:00
temp = tmp
}
2021-06-14 05:37:12 +00:00
const boolNames = ["unlocked", "deactivated"]
function setupTempData(layerData, tmpData, funcsData) {
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] = []
funcsData[item] = []
setupTempData(layerData[item], tmpData[item], funcsData[item])
2020-10-03 19:45:47 +00:00
}
else if ((!!layerData[item]) && (layerData[item].constructor === Object)) {
tmpData[item] = {}
funcsData[item] = []
setupTempData(layerData[item], tmpData[item], funcsData[item])
2020-10-07 20:41:45 +00:00
}
2020-12-01 02:58:42 +00: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-12-01 02:58:42 +00:00
}
else if (isFunction(layerData[item]) && !activeFunctions.includes(item)){
funcsData[item] = layerData[item]
2021-06-14 05:37:12 +00: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 21:39:19 +00: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 23:24:32 +00:00
tmp[layer].trueGlowColor = tmp[layer].glowColor
2020-11-08 04:34:53 +00:00
tmp[layer].notify = shouldNotify(layer)
tmp[layer].prestigeNotify = prestigeNotify(layer)
2021-06-08 23:39:23 +00:00
if (tmp[layer].passiveGeneration === true) tmp[layer].passiveGeneration = 1 // new Decimal(true) = decimalZero
2021-06-02 21:39:19 +00:00
}
tmp.pointGen = getPointGen()
2021-06-07 03:51:50 +00: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 18:56:33 +00:00
function updateTempData(layerData, tmpData, funcsData, useThis) {
for (item in funcsData){
if (Array.isArray(layerData[item])) {
2021-05-19 16:30:02 +00:00
if (item !== "tabFormat" && item !== "content") // These are only updated when needed
2021-06-01 18:56:33 +00:00
updateTempData(layerData[item], tmpData[item], funcsData[item], useThis)
2020-10-03 19:45:47 +00:00
}
2020-12-01 02:58:42 +00:00
else if ((!!layerData[item]) && (layerData[item].constructor === Object) || (typeof layerData[item] === "object") && traversableClasses.includes(layerData[item].constructor.name)){
2021-06-01 18:56:33 +00:00
updateTempData(layerData[item], tmpData[item], funcsData[item], useThis)
2020-10-09 03:13:15 +00:00
}
else if (isFunction(layerData[item]) && !isFunction(tmpData[item])){
2021-06-01 18:56:33 +00:00
let value
if (useThis !== undefined) value = layerData[item].bind(useThis)()
else value = layerData[item]()
2021-05-07 13:47:25 +00:00
Vue.set(tmpData, item, value)
}
}
}
function updateChallengeTemp(layer)
{
updateTempData(layers[layer].challenges, tmp[layer].challenges, funcs[layer].challenges)
2020-12-04 04:19:14 +00:00
}
function updateBuyableTemp(layer)
{
updateTempData(layers[layer].buyables, tmp[layer].buyables, funcs[layer].buyables)
2020-10-11 20:16:36 +00:00
}
function updateClickableTemp(layer)
{
updateTempData(layers[layer].clickables, tmp[layer].clickables, funcs[layer].clickables)
2020-10-12 22:28:12 +00:00
}
function setupBuyables(layer) {
for (id in layers[layer].buyables) {
2021-05-13 05:44:40 +00: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 21:39:19 +00:00
}
function checkDecimalNaN(x) {
return (x instanceof Decimal) && !x.eq(x)
2020-08-21 19:02:34 +00:00
}