2020-10-10 03:16:29 +00:00
var tmp = { }
2020-12-04 04:19:14 +00:00
var temp = tmp // Proxy for tmp
2021-01-25 19:44:54 +00:00
var funcs = { }
2020-10-27 21:41:35 +00:00
var NaNalert = false ;
2020-10-07 22:41:03 +00:00
2020-10-10 03:16:29 +00:00
// Tmp will not call these
var activeFunctions = [
"startData" , "onPrestige" , "doReset" , "update" , "automate" ,
2021-05-10 22:18:02 +00:00
"buy" , "buyMax" , "respec" , "onPress" , "onClick" , "onHold" , "masterButtonPress" ,
2021-05-01 02:08:25 +00:00
"sellOne" , "sellAll" , "pay" , "actualCostFunction" , "actualEffectFunction" ,
2021-05-03 02:39:38 +00:00
"effectDescription" , "display" , "fullDisplay" , "effectDisplay" , "rewardDisplay" ,
2021-05-09 22:39:12 +00:00
"tabFormat" , "content" ,
2021-05-10 22:18:02 +00:00
"onComplete" , "onPurchase" , "onEnter" , "onExit" ,
2021-05-12 02:13:14 +00:00
"getUnlocked" , "getStyle" , "getCanClick" , "getTitle" , "getDisplay"
2020-10-10 03:16:29 +00:00
]
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 = [ ]
2020-10-10 03:16:29 +00:00
function setupTemp ( ) {
tmp = { }
2020-10-17 21:04:38 +00:00
tmp . pointGen = { }
tmp . displayThings = [ ]
2021-01-25 00:05:01 +00:00
tmp . scrolled = 0
2021-01-25 19:44:54 +00:00
funcs = { }
2021-01-25 00:05:01 +00:00
2021-01-25 19:44:54 +00:00
setupTempData ( layers , tmp , funcs )
2020-09-24 15:54:41 +00:00
for ( layer in layers ) {
2020-10-10 03:16:29 +00:00
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 = { }
2020-12-17 02:20:00 +00:00
tmp [ layer ] . computedNodeStyle = [ ]
2021-05-01 02:08:25 +00:00
setupBuyables ( layer )
2021-05-07 23:24:32 +00:00
tmp [ layer ] . trueGlowColor = [ ]
2020-10-09 03:13:15 +00:00
}
2021-05-06 19:45:03 +00:00
tmp . other = {
2021-05-11 00:19:29 +00:00
lastPoints : player . points || decimalZero ,
oomps : decimalZero ,
2021-05-06 19:45:03 +00:00
}
2021-05-10 22:27:37 +00:00
updateWidth ( )
2021-05-07 04:16:22 +00:00
2020-12-04 04:19:14 +00:00
temp = tmp
2020-10-07 21:00:02 +00:00
}
2021-01-25 19:44:54 +00:00
function setupTempData ( layerData , tmpData , funcsData ) {
2020-10-10 03:16:29 +00:00
for ( item in layerData ) {
if ( layerData [ item ] == null ) {
tmpData [ item ] = null
2020-09-14 02:41:42 +00:00
}
2020-10-11 18:49:29 +00:00
else if ( layerData [ item ] instanceof Decimal )
tmpData [ item ] = layerData [ item ]
2020-10-10 03:16:29 +00:00
else if ( Array . isArray ( layerData [ item ] ) ) {
tmpData [ item ] = [ ]
2021-01-25 19:44:54 +00:00
funcsData [ item ] = [ ]
setupTempData ( layerData [ item ] , tmpData [ item ] , funcsData [ item ] )
2020-10-03 19:45:47 +00:00
}
2020-10-10 03:16:29 +00:00
else if ( ( ! ! layerData [ item ] ) && ( layerData [ item ] . constructor === Object ) ) {
tmpData [ item ] = { }
2021-01-25 19:44:54 +00:00
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 ( )
2021-01-25 19:44:54 +00:00
funcsData [ item ] = new layerData [ item ] . constructor ( )
2020-12-01 02:58:42 +00:00
}
2020-10-10 03:16:29 +00:00
else if ( isFunction ( layerData [ item ] ) && ! activeFunctions . includes ( item ) ) {
2021-01-25 19:44:54 +00:00
funcsData [ item ] = layerData [ item ]
2021-05-11 00:19:29 +00:00
tmpData [ item ] = decimalOne // The safest thing to put probably?
2020-10-10 03:16:29 +00:00
} else {
tmpData [ item ] = layerData [ item ]
2020-10-07 21:13:16 +00:00
}
2020-10-10 03:16:29 +00:00
}
2020-10-07 21:13:16 +00:00
}
2020-10-10 03:16:29 +00:00
function updateTemp ( ) {
if ( tmp === undefined )
setupTemp ( )
2020-10-07 21:13:16 +00:00
2021-01-25 19:44:54 +00:00
updateTempData ( layers , tmp , funcs )
2020-10-07 21:13:16 +00:00
2020-10-10 03:16:29 +00:00
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 )
2020-10-07 21:13:16 +00:00
}
2020-10-10 03:16:29 +00:00
tmp . pointGen = getPointGen ( )
2020-10-17 21:04:38 +00:00
tmp . displayThings = [ ]
for ( thing in displayThings ) {
let text = displayThings [ thing ]
if ( isFunction ( text ) ) text = text ( )
tmp . displayThings . push ( text )
}
2020-10-07 21:13:16 +00:00
}
2021-01-25 19:44:54 +00:00
function updateTempData ( layerData , tmpData , funcsData ) {
2020-10-11 18:49:29 +00:00
2021-01-25 19:44:54 +00:00
for ( item in funcsData ) {
2020-10-10 03:16:29 +00:00
if ( Array . isArray ( layerData [ item ] ) ) {
2021-05-10 01:39:15 +00:00
if ( item === "tabFormat" || item === "content" ) return // These are only updated when needed
2021-01-25 19:44:54 +00:00
updateTempData ( layerData [ item ] , tmpData [ item ] , funcsData [ item ] )
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-01-25 19:44:54 +00:00
updateTempData ( layerData [ item ] , tmpData [ item ] , funcsData [ item ] )
2020-10-09 03:13:15 +00:00
}
2021-01-21 22:52:09 +00:00
else if ( isFunction ( layerData [ item ] ) && ! isFunction ( tmpData [ item ] ) ) {
2020-10-27 21:41:35 +00:00
let value = layerData [ item ] ( )
if ( value !== value || value === decimalNaN ) {
2020-10-27 23:25:03 +00:00
if ( NaNalert === true || confirm ( "Invalid value found in tmp, named '" + item + "'. Please let the creator of this mod know! Would you like to try to auto-fix the save and keep going?" ) ) {
2020-10-27 21:41:35 +00:00
NaNalert = true
value = ( value !== value ? 0 : decimalZero )
}
else {
clearInterval ( interval ) ;
player . autosave = false ;
NaNalert = true ;
}
}
2021-05-07 13:47:25 +00:00
Vue . set ( tmpData , item , value )
2020-10-10 03:16:29 +00:00
}
}
2020-10-11 01:52:27 +00:00
}
2020-10-13 03:08:19 +00:00
function updateChallengeTemp ( layer )
2020-10-11 01:52:27 +00:00
{
2021-01-25 19:44:54 +00:00
updateTempData ( layers [ layer ] . challenges , tmp [ layer ] . challenges , funcs [ layer ] . challenges )
2020-12-04 04:19:14 +00:00
}
2020-10-11 01:52:27 +00:00
function updateBuyableTemp ( layer )
{
2021-01-25 19:44:54 +00:00
updateTempData ( layers [ layer ] . buyables , tmp [ layer ] . buyables , funcs [ layer ] . buyables )
2020-10-11 20:16:36 +00:00
}
function updateClickableTemp ( layer )
{
2021-01-25 19:44:54 +00:00
updateTempData ( layers [ layer ] . clickables , tmp [ layer ] . clickables , funcs [ layer ] . clickables )
2020-10-12 22:28:12 +00:00
}
2021-05-01 02:08:25 +00:00
function setupBuyables ( layer ) {
for ( id in layers [ layer ] . buyables ) {
if ( ! isNaN ( id ) ) {
let b = layers [ layer ] . buyables [ id ]
b . actualCostFunction = b . cost
b . cost = function ( x ) {
2021-05-09 22:39:12 +00:00
x = ( x === undefined ? player [ this . layer ] . buyables [ this . id ] : x )
2021-05-01 02:08:25 +00:00
return layers [ this . layer ] . buyables [ this . id ] . actualCostFunction ( x )
}
b . actualEffectFunction = b . effect
b . effect = function ( x ) {
2021-05-09 22:39:12 +00:00
x = ( x === undefined ? player [ this . layer ] . buyables [ this . id ] : x )
2021-05-01 02:08:25 +00:00
return layers [ this . layer ] . buyables [ this . id ] . actualEffectFunction ( x )
}
}
}
2020-08-21 19:02:34 +00:00
}