From 6268caea20f53b81670fb936f747299372311c9b Mon Sep 17 00:00:00 2001 From: Acamaeda Date: Fri, 9 Oct 2020 23:16:29 -0400 Subject: [PATCH] Automated temp and changed basically everything in the process --- changelog.md | 3 + docs/buyables.md | 4 +- docs/challenges.md | 2 +- docs/layer-features.md | 4 - docs/subtabs-and-microtabs.md | 2 +- docs/upgrades.md | 2 +- index.html | 31 ++- js/game.js | 68 +++--- js/layers.js | 29 ++- js/saves.js | 3 - js/temp.js | 377 ++++++---------------------------- js/utils.js | 19 +- js/v.js | 114 +++++----- 13 files changed, 206 insertions(+), 452 deletions(-) delete mode 100644 js/saves.js diff --git a/changelog.md b/changelog.md index 3399259..6751291 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,9 @@ #The Modding Tree changelog: + +effectDisplay in Challenges and Upgrades no longer takes an argument + ##v1.3.5 - Completely automated convertToDecimal, now you never have to worry about it again. - Branches can be defined without a color id. But they can also use hex values for color ids! diff --git a/docs/buyables.md b/docs/buyables.md index 69b2ccb..6986d34 100644 --- a/docs/buyables.md +++ b/docs/buyables.md @@ -29,9 +29,9 @@ Features: - title: **optional**, displayed at the top in a larger font It can also be a function that returns updating text. -- cost(x): cost for buying xth buyable, can be an object if there are multiple currencies +- cost(): cost for buying xth buyable, can be an object if there are multiple currencies -- effect(x): **optional**, A function that calculates and returns the current values of bonuses +- effect(): **optional**, A function that calculates and returns the current values of bonuses for having x of this buyable. Can return a value or an object containing multiple values. - display(): A function returning everything that should be displayed on the rebuyable after the title, likely diff --git a/docs/challenges.md b/docs/challenges.md index f8f1a23..0cb98c5 100644 --- a/docs/challenges.md +++ b/docs/challenges.md @@ -35,7 +35,7 @@ Individual Challenges can have these features: - effect(): **optional**, A function that calculates and returns the current values of any bonuses from the reward. Can return a value or an object containing multiple values. Can use basic HTML. -- effectDisplay(effects): **optional**, A function that returns a display of the current effects of the reward with +- effectDisplay(): **optional**, A function that returns a display of the current effects of the reward with formatting. Default behavior is to just display the a number appropriately formatted. - goal: A Decimal for the cost of the upgrade. By default, the goal is in basic Points. diff --git a/docs/layer-features.md b/docs/layer-features.md index c688179..7299b7b 100644 --- a/docs/layer-features.md +++ b/docs/layer-features.md @@ -138,10 +138,6 @@ Key: - automate(): **optional**, this function is called every game tick, after production. Use it to activate any autobuyers or auto-resets or similar on this layer, if appropriate. -- updateTemp(): **optional**, this function is called every game tick. use it to update anything in the "tmp" object. - You don't really need it. tmp is used as a way to store calculated values so it doesn't repeat - calculations. - - resetsNothing(): **optional**, returns true if this layer shouldn't trigger any resets when you prestige. - incr_order: **optional**, an array of layer ids. When this layer is unlocked for the first time, the "order" value diff --git a/docs/subtabs-and-microtabs.md b/docs/subtabs-and-microtabs.md index 091bda7..2302c3a 100644 --- a/docs/subtabs-and-microtabs.md +++ b/docs/subtabs-and-microtabs.md @@ -44,7 +44,7 @@ Normal subtabs and microtab subtabs both use the same features: - content: The tab layout code for the subtab, in [the tab layout format](custom-tab-layouts.md) -- style(: **Optional**, A function returning a CSS object, which affects the CSS when in that subtab. +- style(): **Optional**, A function returning a CSS object, which affects the CSS when in that subtab. - buttonStyle(): **Optional**, A function returning a CSS object, which affects the appearance of the button for that subtab. diff --git a/docs/upgrades.md b/docs/upgrades.md index b908a89..d43d871 100644 --- a/docs/upgrades.md +++ b/docs/upgrades.md @@ -34,7 +34,7 @@ Individual upgrades can have these features: - effect(): **optional**, A function that calculates and returns the current values of any bonuses from the upgrade. Can return a value or an object containing multiple values. -- effectDisplay(effects): **optional**, A function that returns a display of the current effects of the upgrade with +- effectDisplay(): **optional**, A function that returns a display of the current effects of the upgrade with formatting. Default behavior is to just display the a number appropriately formatted. Can use basic HTML. - cost: A Decimal for the cost of the upgrade. By default, upgrades cost the main prestige currency for the layer. diff --git a/index.html b/index.html index 0d98709..50a9cc9 100644 --- a/index.html +++ b/index.html @@ -15,7 +15,6 @@ - @@ -172,33 +171,33 @@
-
+



- - -
You have {{formatWhole(tmp.layerAmt[layer])}} {{layers[layer].baseResource}}
+ + +
You have {{formatWhole(tmp[layer].baseAmt)}} {{tmp[layer].baseResource}}


- Your best {{layers[layer].resource}} is {{formatWhole(player[layer].best)}}
- You have made a total of {{formatWhole(player[layer].total)}} {{layers[layer].resource}}
- + Your best {{tmp[layer].resource}} is {{formatWhole(player[layer].best)}}
+ You have made a total of {{formatWhole(player[layer].total)}} {{tmp[layer].resource}}
+
- +
- - - + + +

- +
-
+
- +
- +
diff --git a/js/game.js b/js/game.js index d6d1225..a0a5e9c 100644 --- a/js/game.js +++ b/js/game.js @@ -1,5 +1,4 @@ var player; -var tmp = {}; var needCanvasUpdate = true; var NaNalert = false; var gameEnded = false; @@ -39,14 +38,14 @@ function getResetGain(layer, useType = null) { let type = useType if (!useType) type = layers[layer].type - if (tmp.gainExp[layer].eq(0)) return new Decimal(0) + if (tmp[layer].gainExp.eq(0)) return new Decimal(0) if (type=="static") { - if ((!layers[layer].canBuyMax()) || tmp.layerAmt[layer].lt(tmp.layerReqs[layer])) return new Decimal(1) - let gain = tmp.layerAmt[layer].div(tmp.layerReqs[layer]).div(tmp.gainMults[layer]).max(1).log(layers[layer].base).times(tmp.gainExp[layer]).pow(Decimal.pow(layers[layer].exponent, -1)) + if ((!layers[layer].canBuyMax()) || tmp[layer].baseAmount.lt(tmp[layer].requires)) return new Decimal(1) + let gain = tmp[layer].baseAmount.div(tmp[layer].requires).div(tmp[layer].gainMult).max(1).log(layers[layer].base).times(tmp[layer].gainExp).pow(Decimal.pow(layers[layer].exponent, -1)) return gain.floor().sub(player[layer].points).add(1).max(1); } else if (type=="normal"){ - if (tmp.layerAmt[layer].lt(tmp.layerReqs[layer])) return new Decimal(0) - let gain = tmp.layerAmt[layer].div(tmp.layerReqs[layer]).pow(layers[layer].exponent).times(tmp.gainMults[layer]).pow(tmp.gainExp[layer]) + if (tmp[layer].baseAmount.lt(tmp[layer].requires)) return new Decimal(0) + let gain = tmp[layer].baseAmount.div(tmp[layer].requires).pow(layers[layer].exponent).times(tmp[layer].gainMult).pow(tmp[layer].gainExp) if (gain.gte("e1e7")) gain = gain.sqrt().times("e5e6") return gain.floor().max(0); } else if (type=="custom"){ @@ -60,19 +59,19 @@ function getNextAt(layer, canMax=false, useType = null) { let type = useType if (!useType) type = layers[layer].type - if (tmp.gainExp[layer].eq(0)) return new Decimal(1/0) + if (tmp[layer].gainExp.eq(0)) return new Decimal(1/0) if (type=="static") { if (!layers[layer].canBuyMax()) canMax = false - let amt = player[layer].points.plus((canMax&&tmp.layerAmt[layer].gte(tmp.nextAt[layer]))?tmp.resetGain[layer]:0) - let extraCost = Decimal.pow(layers[layer].base, amt.pow(layers[layer].exponent).div(tmp.gainExp[layer])).times(tmp.gainMults[layer]) - let cost = extraCost.times(tmp.layerReqs[layer]).max(tmp.layerReqs[layer]) + let amt = player[layer].points.plus((canMax&&tmp[layer].baseAmount.gte(tmp[layer].nextAt))?tmp[layer].resetGain:0) + let extraCost = Decimal.pow(layers[layer].base, amt.pow(layers[layer].exponent).div(tmp[layer].gainExp)).times(tmp[layer].gainMult) + let cost = extraCost.times(tmp[layer].requires).max(tmp[layer].requires) if (layers[layer].resCeil) cost = cost.ceil() return cost; } else if (type=="normal"){ - let next = tmp.resetGain[layer].add(1) + let next = tmp[layer].resetGain.add(1) if (next.gte("e1e7")) next = next.div("e5e6").pow(2) - next = next.root(tmp.gainExp[layer]).div(tmp.gainMults[layer]).root(layers[layer].exponent).times(tmp.layerReqs[layer]).max(tmp.layerReqs[layer]) + next = next.root(tmp[layer].gainExp.div(tmp[layer].gainMult).root(layers[layer].exponent).times(tmp[layer].requires).max(tmp[layer].requires)) if (layers[layer].resCeil) next = next.ceil() return next; } else if (type=="custom"){ @@ -85,7 +84,7 @@ function getNextAt(layer, canMax=false, useType = null) { function shouldNotify(layer){ for (id in layers[layer].upgrades){ if (!isNaN(id)){ - if (canAffordUpg(layer, id) && !hasUpg(layer, id) && tmp.upgrades[layer][id].unl){ + if (canAffordUpg(layer, id) && !hasUpg(layer, id) && tmp[layer].upgrades[id].unl){ return true } } @@ -98,6 +97,16 @@ function shouldNotify(layer){ return false } +function canReset(layer) +{ + if(tmp[layer].type == "normal") + return tmp[layer].baseAmount.gte(tmp[layer].requires) + else if(tmp[layer].type== "static") + return tmp[layer].baseAmount.gte(tmp[layer].nextAt) + else + return layers[layer].canReset() +} + function rowReset(row, layer) { for (lr in ROW_LAYERS[row]){ if(layers[lr].doReset) { @@ -150,7 +159,7 @@ function addPoints(layer, gain) { } function generatePoints(layer, diff) { - addPoints(layer, tmp.resetGain[layer].times(diff)) + addPoints(layer, tmp[layer].resetGain.times(diff)) } var prevOnReset @@ -158,14 +167,14 @@ var prevOnReset function doReset(layer, force=false) { let row = layers[layer].row if (!force) { - if (tmp.layerAmt[layer].lt(tmp.layerReqs[layer])) return; - let gain = tmp.resetGain[layer] + if (tmp[layer].baseAmount.lt(tmp[layer].requires)) return; + let gain = tmp[layer].resetGain if (layers[layer].type=="static") { - if (tmp.layerAmt[layer].lt(tmp.nextAt[layer])) return; + if (tmp[layer].baseAmount.lt(tmp[layer].nextAt)) return; gain =(layers[layer].canBuyMax() ? gain : 1) } if (layers[layer].type=="custom") { - if (!tmp.canReset[layer]) return; + if (!tmp[layer].canReset) return; } if (layers[layer].onPrestige) @@ -185,10 +194,10 @@ function doReset(layer, force=false) { } } - tmp.layerAmt[layer] = new Decimal(0) // quick fix + tmp[layer].baseAmount = new Decimal(0) // quick fix } - if (layers[layer].resetsNothing && layers[layer].resetsNothing()) return + if (tmp[layer].resetsNothing) return for (layerResetting in layers) { @@ -201,7 +210,6 @@ function doReset(layer, force=false) { for (let x = row; x >= 0; x--) rowReset(x, layer) prevOnReset = undefined - setupTemp(); updateTemp() updateTemp() } @@ -216,7 +224,7 @@ function respecBuyables(layer) { function canAffordUpg(layer, id) { let upg = layers[layer].upgrades[id] - let cost = tmp.upgrades[layer][id].cost + let cost = tmp[layer].upgrades[id].cost return canAffordPurchase(layer, upg, cost) } @@ -233,15 +241,15 @@ function hasChall(layer, id){ } function upgEffect(layer, id){ - return (tmp.upgrades[layer][id].effect) + return (tmp[layer].upgrades[id].effect) } function challEffect(layer, id){ - return (tmp.challs[layer][id].effect) + return (tmp[layer].challs[id].effect) } function buyableEffect(layer, id){ - return (tmp.buyables[layer][id].effect) + return (tmp[layer].buyables[id].effect) } function canAffordPurchase(layer, thing, cost) { @@ -265,7 +273,7 @@ function buyUpg(layer, id) { if (!layers[layer].upgrades[id].unl()) return if (player[layer].upgrades.includes(id)) return let upg = layers[layer].upgrades[id] - let cost = tmp.upgrades[layer][id].cost + let cost = tmp[layer].upgrades[id].cost if (upg.currencyInternalName){ let name = upg.currencyInternalName @@ -290,8 +298,8 @@ function buyUpg(layer, id) { function buyMaxBuyable(layer, id) { if (!player[layer].unl) return - if (!tmp.buyables[layer][id].unl) return - if (!tmp.buyables[layer][id].canAfford) return + if (!tmp[layer].buyables[id].unl) return + if (!tmp[layer].buyables[id].canAfford) return if (!layers[layer].buyables[id].buyMax) return layers[layer].buyables[id].buyMax() @@ -300,8 +308,8 @@ function buyMaxBuyable(layer, id) { function buyBuyable(layer, id) { if (!player[layer].unl) return - if (!tmp.buyables[layer][id].unl) return - if (!tmp.buyables[layer][id].canAfford) return + if (!tmp[layer].buyables[id].unl) return + if (!tmp[layer].buyables[id].canAfford) return layers[layer].buyables[id].buy() updateBuyableTemp(layer) diff --git a/js/layers.js b/js/layers.js index c6cbe20..62db90a 100644 --- a/js/layers.js +++ b/js/layers.js @@ -97,7 +97,7 @@ addLayer("c", { if (ret.gte("1e20000000")) ret = ret.sqrt().times("1e10000000") return ret; }, - effectDisplay(fx) { return format(fx)+"x" }, // Add formatting to the effect + effectDisplay() { return format(this.effect())+"x" }, // Add formatting to the effect }, 13: { desc:() => "Unlock a secret subtab and make this layer act if you unlocked it first.", @@ -132,12 +132,12 @@ addLayer("c", { respecText:() => "Respec Thingies", // Text on Respec button, optional 11: { title:() => "Exhancers", // Optional, displayed at the top in a larger font - cost(x) { // cost for buying xth buyable, can be an object if there are multiple currencies + cost(x=player[this.layer].buyables[this.id]) { // cost for buying xth buyable, can be an object if there are multiple currencies if (x.gte(25)) x = x.pow(2).div(25) let cost = Decimal.pow(2, x.pow(1.5)) return cost.floor() }, - effect(x) { // Effects of owning x of the items, x is a decimal + effect(x=player[this.layer].buyables[this.id]) { // Effects of owning x of the items, x is a decimal let eff = {} if (x.gte(0)) eff.first = Decimal.pow(25, x.pow(1.1)) else eff.first = Decimal.pow(1/25, x.times(-1).pow(1.1)) @@ -147,16 +147,16 @@ addLayer("c", { return eff; }, display() { // Everything else displayed in the buyable button after the title - let data = tmp.buyables[this.layer][this.id] + let data = tmp[this.layer].buyables[this.id] return "Cost: " + format(data.cost) + " lollipops\n\ Amount: " + player[this.layer].buyables[this.id] + "\n\ Adds + " + format(data.effect.first) + " things and multiplies stuff by " + format(data.effect.second) }, unl() { return player[this.layer].unl }, canAfford() { - return player[this.layer].points.gte(tmp.buyables[this.layer][this.id].cost)}, + return player[this.layer].points.gte(tmp[this.layer].buyables[this.id].cost)}, buy() { - cost = tmp.buyables[this.layer][this.id].cost + cost = tmp[this.layer].buyables[this.id].cost player[this.layer].points = player[this.layer].points.sub(cost) player[this.layer].buyables[this.id] = player[this.layer].buyables[this.id].add(1) player[this.layer].spentOnBuyables = player[this.layer].spentOnBuyables.add(cost) // This is a built-in system that you can use for respeccing but it only works with a single Decimal value @@ -173,8 +173,6 @@ addLayer("c", { }, // Do any gameloop things (e.g. resource generation) inherent to this layer automate() { }, // Do any automation inherent to this layer if appropriate - updateTemp() { - }, // Do any necessary temp updating, not that important usually resetsNothing() {return false}, onPrestige(gain) { return @@ -232,7 +230,7 @@ addLayer("c", { buttonStyle() {return {'color': 'orange'}}, content: ["main-display", - ["prestige-button", function() {return "Melt your points into "}], + "prestige-button", ["blank", "5px"], // Height ["raw-html", function() {return ""}], ["display-text", @@ -249,8 +247,8 @@ addLayer("c", { ["toggle", ["c", "beep"]], ["blank", ["30px", "10px"]], // Width, height ["display-text", function() {return "Beep"}], "blank", ["v-line", "200px"], ["column", [ - ["prestige-button", function() {return "Be redundant for "}, {'width': '150px', 'height': '30px'}], - ["prestige-button", function() {return "Be redundant for "}, {'width': '150px', 'height': '30px'}], + ["prestige-button", "", {'width': '150px', 'height': '80px'}], + ["prestige-button", "", {'width': '100px', 'height': '150px'}], ]], ], {'width': '600px', 'height': '350px', 'background-color': 'green', 'border-style': 'solid'}], "blank", @@ -284,7 +282,8 @@ addLayer("c", { shouldNotify() { // Optional, layer will be highlighted on the tree if true. // Layer will automatically highlight if an upgrade is purchasable. return (player.c.buyables[11] == 1) - } + }, + resetDesc: "Melt your points into ", }) // This layer is mostly minimal but it uses a custom prestige type @@ -325,8 +324,8 @@ addLayer("f", { // The following are only currently used for "custom" Prestige type: prestigeButtonText() { //Is secretly HTML - if (!this.canBuyMax()) return "Hi! I'm a weird dinosaur and I'll give you a Farm Point in exchange for all of your candies and lollipops! (At least " + formatWhole(tmp.nextAt[layer]) + " candies)" - if (this.canBuyMax()) return "Hi! I'm a weird dinosaur and I'll give you " + formatWhole(tmp.resetGain[this.layer]) + " Farm Points in exchange for all of your candies and lollipops! (You'll get another one at " + formatWhole(tmp.nextAtDisp[layer]) + " candies)" + if (!this.canBuyMax()) return "Hi! I'm a weird dinosaur and I'll give you a Farm Point in exchange for all of your candies and lollipops! (At least " + formatWhole(tmp[this.layer].nextAt) + " candies)" + if (this.canBuyMax()) return "Hi! I'm a weird dinosaur and I'll give you " + formatWhole(tmp[this.layer].resetGain) + " Farm Points in exchange for all of your candies and lollipops! (You'll get another one at " + formatWhole(tmp[layer].nextAtDisp) + " candies)" }, getResetGain() { return getResetGain(this.layer, useType = "static") @@ -335,7 +334,7 @@ addLayer("f", { return getNextAt(this.layer, canMax, useType = "static") }, canReset() { - return tmp.layerAmt[this.layer].gte(tmp.nextAt[this.layer]) + return tmp[this.layer].baseAmount.gte(tmp[this.layer].nextAt) }, }, ) diff --git a/js/saves.js b/js/saves.js deleted file mode 100644 index 021a823..0000000 --- a/js/saves.js +++ /dev/null @@ -1,3 +0,0 @@ -const SAVES = { - PRE_SUPER_BOOSTERS: "eyJ0YWIiOiJvcHRpb25zIiwidGltZSI6MTU5ODE5ODI4NjQ4OCwiYXV0b3NhdmUiOnRydWUsInBvaW50cyI6IjMuMzYwMTkyNjc5ODczNDgzZTQxNDMiLCJwIjp7InVubCI6dHJ1ZSwicG9pbnRzIjoiMi4xMjI1NzI5ODA3NjQzMTQ2ZTI3NjMiLCJ1cGdyYWRlcyI6WzExLDEyLDIxLDIyLDEzLDIzXSwiYmVzdCI6IjUxMDIyNjAwNiJ9LCJiIjp7InVubCI6dHJ1ZSwicG9pbnRzIjoiMTgwIiwidXBncmFkZXMiOlsxMSwxMiwxMywyMiwyMSwyM10sImJlc3QiOiIxODAiLCJhdXRvIjp0cnVlfSwiZyI6eyJ1bmwiOnRydWUsInBvaW50cyI6IjEzOSIsInBvd2VyIjoiMi4zNDMxNTg3NTczMjc0ODVlMzM5IiwidXBncmFkZXMiOlsxMSwxMiwxMywxNCwxNSwyMiwyMSwyMywyNCwyNV0sImJlc3QiOiIxMzkiLCJhdXRvIjp0cnVlfSwiZSI6eyJ1bmwiOnRydWUsInBvaW50cyI6IjEuNzAxNTAzNTMzMDU4MTA3NmU4NiIsImJlc3QiOiIxLjcwMTUwMzUzMzA1ODEwNzZlODYiLCJlbmhhbmNlcnMiOiIzMyIsInVwZ3JhZGVzIjpbMTEsMTIsMTMsMTQsMTUsMjEsMjMsMjIsMjQsMjVdLCJvcmRlciI6MH0sInQiOnsidW5sIjp0cnVlLCJvcmRlciI6MCwicG9pbnRzIjoiMTYiLCJiZXN0IjoiMTYiLCJlbmVyZ3kiOiIxLjA4MDMzODY3NDA5Mjg3NmU5NCIsImV4dENhcHN1bGVzIjoiMjYiLCJ1cGdyYWRlcyI6WzExLDEyLDEzLDE0LDIxLDIyLDIzLDI0LDMxLDMyLDMzXX0sInMiOnsidW5sIjp0cnVlLCJvcmRlciI6MCwicG9pbnRzIjoiMTYiLCJiZXN0IjoiMTYiLCJzcGVudCI6IjY4IiwiYnVpbGRpbmdzIjp7IjEiOiIxNyIsIjIiOiIyNiIsIjMiOiIxMyIsIjQiOiI4IiwiNSI6IjQifSwidXBncmFkZXMiOlsxMSwxMiwxMywxNCwyMSwyMywyNCwzMSwyMiwzMiwzMywzNF19LCJzYiI6eyJ1bmwiOmZhbHNlLCJvcmRlciI6MCwicG9pbnRzIjoiMCIsImJlc3QiOiIwIiwidXBncmFkZXMiOltdfSwidmVyc2lvblR5cGUiOiJhbHBoYSIsInZlcnNpb24iOjEwfQ==", -} \ No newline at end of file diff --git a/js/temp.js b/js/temp.js index efaebd6..b7046b6 100644 --- a/js/temp.js +++ b/js/temp.js @@ -1,338 +1,79 @@ -function setupTemp(){ - if (!tmp.challActive) {tmp.challActive = {}} - if (!tmp.challs) tmp.challs = {} - for (layer in layers) { - if(layers[layer].challs !== undefined){ - tmp.challActive[layer] = {} - setupChallTemp(layer) - } - } +var tmp = {} - if (!tmp.upgrades) tmp.upgrades = {} - for (layer in layers) { - if(layers[layer].upgrades !== undefined){ - setupUpgradeTemp(layer) - } +// Tmp will not call these +var activeFunctions = [ + "startData", "onPrestige", "doReset", "update", "automate", + "buy", "buyMax", "respec", "onComplete", "onPurchase", "onPress" +] + +function setupTemp() { + tmp = {} + setupTempData(layers, tmp) + + for (layer in layers){ + tmp[layer].resetGain = {} + tmp[layer].nextAt = {} + tmp[layer].nextAtDisp = {} + tmp[layer].notify = {} + tmp[layer].canReset = {} + tmp[layer].prestigeButtonText = {} } - - if (!tmp.milestones) tmp.milestones = {} - for (layer in layers) { - if(layers[layer].milestones !== undefined){ - setupMilestoneTemp(layer) +} + +function setupTempData(layerData, tmpData) { + tmp.pointGen = {} + + + for (item in layerData){ + if (layerData[item] == null) { + tmpData[item] = null } - } - if (!tmp.buyables) tmp.buyables = {} - for (layer in layers) if (layers[layer].buyables) { - if(layers[layer].buyables !== undefined){ - setupBuyableTemp(layer) + else if (Array.isArray(layerData[item])) { + tmpData[item] = [] + setupTempData(layerData[item], tmpData[item]) } - } + else if ((!!layerData[item]) && (layerData[item].constructor === Object)) { + tmpData[item] = {} + setupTempData(layerData[item], tmpData[item]) + } + else if (isFunction(layerData[item]) && !activeFunctions.includes(item)){ + tmpData[item] = {} + } else { + tmpData[item] = layerData[item] + } + } } function updateTemp() { - for (layer in layers) tmp[layer] = {} + if (tmp === undefined) + setupTemp() - if (tmp.genPoints == undefined) tmp.genPoints = false + 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) - if (!tmp.layerReqs) tmp.layerReqs = {} - for (layer in layers) tmp.layerReqs[layer] = layers[layer].requires() - - if (!tmp.layerEffs) tmp.layerEffs = {} - for (layer in layers) if (layers[layer].effect) tmp.layerEffs[layer] = layers[layer].effect() - - if (!tmp.gainMults) tmp.gainMults = {} - if (!tmp.gainExp) tmp.gainExp = {} - if (!tmp.resetGain) tmp.resetGain = {} - if (!tmp.nextAt) tmp.nextAt = {} - if (!tmp.layerAmt) tmp.layerAmt = {} - if (!tmp.layerColor) tmp.layerColor = {} - if (!tmp.layerShown) tmp.layerShown = {} - if (!tmp.effectDescription) tmp.effectDescription = {} - if (!tmp.style) tmp.style = {} - if (!tmp.nodeStyle) tmp.nodeStyle = {} - if (!tmp.notify) tmp.notify = {} - if (!tmp.nextAtDisp) tmp.nextAtDisp = {} - if (!tmp.prestigeButtonText) tmp.prestigeButtonText = {} - if (!tmp.canReset) tmp.canReset = {} - if (!tmp.tooltips) tmp.tooltips = {} - if (!tmp.tooltipsLocked) tmp.tooltipsLocked = {} - - for (layer in layers) { - if (layers[layer].color) tmp.layerColor[layer] = layers[layer].color() - if (layers[layer].style) tmp.style[layer] = layers[layer].style() - tmp.layerShown[layer] = layers[layer].layerShown() - tmp.layerAmt[layer] = layers[layer].baseAmount() - tmp.gainMults[layer] = layers[layer].gainMult() - tmp.gainExp[layer] = layers[layer].gainExp() - tmp.resetGain[layer] = getResetGain(layer) - tmp.nextAt[layer] = getNextAt(layer) - tmp.notify[layer] = shouldNotify(layer) - tmp.nextAtDisp[layer] = getNextAt(layer, true) - if (layers[layer].effectDescription) tmp.effectDescription[layer] = layers[layer].effectDescription() - if (layers[layer].canReset) tmp.canReset[layer] = layers[layer].canReset() - if (layers[layer].prestigeButtonText) tmp.prestigeButtonText[layer] = layers[layer].prestigeButtonText() - if (layers[layer].tooltip) tmp.tooltips[layer] = layers[layer].tooltip() - if (layers[layer].tooltipLocked) tmp.tooltipsLocked[layer] = layers[layer].tooltipLocked() - if (layers[layer].nodeStyle) tmp.nodeStyle[layer] = layers[layer].nodeStyle() } tmp.pointGen = getPointGen() - - for (layer in layers){ - if (layers[layer].updateTemp) layers[layer].updateTemp() - } - - if (!tmp.componentStyles) tmp.componentStyles = {} - for (layer in layers) if (layers[layer].componentStyles) { - if(layers[layer].componentStyles !== undefined){ - tmp.componentStyles[layer] = {} - for (item in layers[layer].componentStyles) - tmp.componentStyles[layer][item] = layers[layer].componentStyles[item]() - } - } - - - if (!tmp.microtabs) tmp.microtabs = {} - for (layer in layers) { - if (!tmp.microtabs[layer]) tmp.microtabs[layer] = {} - if (layers[layer].microtabs) { - if(layers[layer].microtabs !== undefined){ - updateMicrotabTemp(layer) - } - } - if(layers[layer].tabFormat && !Array.isArray(layers[layer].tabFormat)){ - let data2 = layers[layer].tabFormat - let set = "mainTabs" - if (!tmp.microtabs[layer][set]) tmp.microtabs[layer][set] = {} - for (tab in data2) { - if (!tmp.microtabs[layer][set][tab]) - tmp.microtabs[layer][set][tab] = {} - if(data2[tab].style) - tmp.microtabs[layer][set][tab].style = data2[tab].style() - if(data2[tab].buttonStyle) - tmp.microtabs[layer][set][tab].buttonStyle = data2[tab].buttonStyle() - } - } - } - - - if (!tmp.challActive) {tmp.challActive = {}} - if (!tmp.challs) tmp.challs = {} - for (layer in layers) { - if(layers[layer].challs !== undefined){ - tmp.challActive[layer] = {} - updateChallTemp(layer) - } - } - - if (!tmp.upgrades) tmp.upgrades = {} - for (layer in layers) { - if(layers[layer].upgrades !== undefined){ - updateUpgradeTemp(layer) - } - } - - if (!tmp.milestones) tmp.milestones = {} - for (layer in layers) { - if(layers[layer].milestones !== undefined){ - updateMilestoneTemp(layer) - } - } - if (!tmp.buyables) tmp.buyables = {} - for (layer in layers) if (layers[layer].buyables) { - if(layers[layer].buyables !== undefined){ - updateBuyableTemp(layer) - } - } - - for (layer in layers) { - if(layers[layer].gagues !== undefined){ - tmp[layer].gagues = {} - updateGagueTemp(layer) - } - } } +function updateTempData(layerData, tmpData) { - -function updateChallTemp(layer) { - if (player[layer] === undefined) return - if (!tmp.challs[layer]) tmp.challs[layer] = {} - - let data = tmp.challActive[layer] - let data2 = layers[layer].challs - let customActive = data2.active !== undefined - for (let row = 1; row <= data2.rows; row++) { - for (let col = 1; col <= data2.cols; col++) { - let id = row * 10 + col - tmp.challs[layer][id] = {} - - if (customActive ? data2.active(id) : player[layer].active == id) data[id] = 1 - else delete data[id] - - tmp.challs[layer][id].unl = data2[id].unl() - if(data2[id].name) tmp.challs[layer][id].name = data2[id].name() - if(data2[id].desc) tmp.challs[layer][id].desc = data2[id].desc() - if(data2[id].reward) tmp.challs[layer][id].reward = data2[id].reward() - if(data2[id].effect) tmp.challs[layer][id].effect = data2[id].effect() - if(data2[id].effectDisplay) tmp.challs[layer][id].effectDisplay = data2[id].effectDisplay(tmp.challs[layer][id].effect) - tmp.challs[layer][id].goal = data2[id].goal() - if(data2[id].style) tmp.challs[layer][id].style = data2[id].style() + for (item in layerData){ + if (Array.isArray(layerData[item])) { + updateTempData(layerData[item], tmpData[item]) } - } -} - -function updateUpgradeTemp(layer) { - if (layers[layer] === undefined) return - if (!tmp.upgrades[layer]) tmp.upgrades[layer] = {} - - let data2 = layers[layer].upgrades - for (let row = 1; row <= data2.rows; row++) { - for (let col = 1; col <= data2.cols; col++) { - let id = row * 10 + col - tmp.upgrades[layer][id] = {} - tmp.upgrades[layer][id].unl = data2[id].unl() - if(data2[id].effect) tmp.upgrades[layer][id].effect = data2[id].effect() - tmp.upgrades[layer][id].cost = data2[id].cost() - if(data2[id].effectDisplay) tmp.upgrades[layer][id].effectDisplay = data2[id].effectDisplay(tmp.upgrades[layer][id].effect) - if(data2[id].desc) tmp.upgrades[layer][id].desc = data2[id].desc() - if(data2[id].title) tmp.upgrades[layer][id].title = data2[id].title() - if(data2[id].style) tmp.upgrades[layer][id].style = data2[id].style() + else if ((!!layerData[item]) && (layerData[item].constructor === Object)) { + updateTempData(layerData[item], tmpData[item]) } - } -} - -function updateMilestoneTemp(layer) { - if (layers[layer] === undefined) return - if (!tmp.milestones[layer]) tmp.milestones[layer] = {} - - let data2 = layers[layer].milestones - for (id in data2) { - tmp.milestones[layer][id] = {} - if(data2[id].unl) tmp.milestones[layer][id].unl = data2[id].unl() - tmp.milestones[layer][id].done = data2[id].done() - if(data2[id].requirementDesc) tmp.milestones[layer][id].requirementDesc = data2[id].requirementDesc() - if(data2[id].effectDesc) tmp.milestones[layer][id].effectDesc = data2[id].effectDesc() - if(data2[id].style) tmp.milestones[layer][id].style = data2[id].style() - - } -} - -function updateBuyableTemp(layer) { - if (layers[layer] === undefined) return - if (!tmp.buyables[layer]) tmp.buyables[layer] = {} - let data2 = layers[layer].buyables - if(data2.respecText) tmp.buyables[layer].respecText = data2.respecText() - for (let row = 1; row <= data2.rows; row++) { - for (let col = 1; col <= data2.cols; col++) { - let id = row * 10 + col - let amt = player[layer].buyables[id] - tmp.buyables[layer][id] = {} - tmp.buyables[layer][id].unl = data2[id].unl() - if(data2[id].effect) tmp.buyables[layer][id].effect = data2[id].effect(amt) - tmp.buyables[layer][id].cost = data2[id].cost(amt) - tmp.buyables[layer][id].canAfford = data2[id].canAfford() - if(data2[id].title) tmp.buyables[layer][id].title = data2[id].title() - if(data2[id].display) tmp.buyables[layer][id].display = data2[id].display() - if(data2[id].style) tmp.buyables[layer][id].style = data2[id].style() - + else if (isFunction(layerData[item]) && !activeFunctions.includes(item)){ + tmpData[item] = layerData[item]() } - } -} - -function updateMicrotabTemp(layer) { - if (layers[layer] === undefined) return - let data2 = layers[layer].microtabs - for (set in data2) { - if (!tmp.microtabs[layer][set]) tmp.microtabs[layer][set] = {} - for (tab in data2[set]) { - if (!tmp.microtabs[layer][set][tab]) - tmp.microtabs[layer][set][tab] = {} - if(data2[set][tab].style) - tmp.microtabs[layer][set][tab].style = data2[set][tab].style() - if(data2[set][tab].buttonStyle) - tmp.microtabs[layer][set][tab].buttonStyle = data2[set][tab].buttonStyle() - - } - } -} - - -function setupChallTemp(layer) { - if (player[layer] === undefined) return - if (!tmp.challs[layer]) tmp.challs[layer] = {} - - let data = tmp.challActive[layer] - let data2 = layers[layer].challs - let customActive = data2.active !== undefined - for (let row = 1; row <= data2.rows; row++) { - for (let col = 1; col <= data2.cols; col++) { - let id = row * 10 + col - - tmp.challs[layer][id] = {} - if(data2[id].effect) tmp.challs[layer][id].effect = {} - if(data2[id].style) tmp.challs[layer][id].style = {} - } - } -} - -function setupUpgradeTemp(layer) { - if (layers[layer] === undefined) return - if (!tmp.upgrades[layer]) tmp.upgrades[layer] = {} - - let data2 = layers[layer].upgrades - for (let row = 1; row <= data2.rows; row++) { - for (let col = 1; col <= data2.cols; col++) { - let id = row * 10 + col - tmp.upgrades[layer][id] = {} - if(data2[id].effect) tmp.upgrades[layer][id].effect = {} - if(data2[id].style) tmp.upgrades[layer][id].style = {} - } - } -} - -function setupMilestoneTemp(layer) { - if (layers[layer] === undefined) return - if (!tmp.milestones[layer]) tmp.milestones[layer] = {} - - let data2 = layers[layer].milestones - for (id in data2) { - tmp.milestones[layer][id] = {} - if(data2[id].style) tmp.milestones[layer][id].style = {} - } -} - -function setupBuyableTemp(layer) { - if (layers[layer] === undefined) return - if (!tmp.buyables[layer]) tmp.buyables[layer] = {} - let data2 = layers[layer].buyables - for (let row = 1; row <= data2.rows; row++) { - for (let col = 1; col <= data2.cols; col++) { - let id = row * 10 + col - let amt = player[layer].buyables[id] - tmp.buyables[layer][id] = {} - if(data2[id].effect) tmp.buyables[layer][id].effect = {} - tmp.buyables[layer][id].cost = {} - if(data2[id].style) tmp.buyables[layer][id].style = {} - - } - } -} - - -// The start of not being backwards with tmp -function updateGagueTemp(layer) { - if (layers[layer] === undefined) return - let gagues = layers[layer].gagues - for (id in gagues) { - tmp[layer].gagues[id] = {} - for (item in gagues[id]) { - let thing = gagues[id][item] - if (isFunction(thing)) - tmp[layer].gagues[id] = thing() - else - tmp[layer].gagues[id] = thing - } - } + } } \ No newline at end of file diff --git a/js/utils.js b/js/utils.js index 764525c..eef5d86 100644 --- a/js/utils.js +++ b/js/utils.js @@ -333,7 +333,7 @@ function notifyLayer(name) { } function nodeShown(layer) { - if (tmp.layerShown[layer]) return true + if (tmp[layer].layerShown) return true switch(layer) { case "idk": return player.l.unl @@ -343,7 +343,7 @@ function nodeShown(layer) { } function layerUnl(layer) { - return LAYERS.includes(layer) && (player[layer].unl || (tmp.layerAmt[layer].gte(tmp.layerReqs[layer]) && layers[layer].layerShown())) + return LAYERS.includes(layer) && (player[layer].unl || (tmp[layer].baseAmount.gte(tmp[layer].requires) && layers[layer].layerShown())) } function keepGoing() { @@ -408,6 +408,21 @@ function focused(x) { onFocused = x } +function prestigeButtonText(layer) +{ + if(tmp[layer].type == "normal") + return `${ player[layer].points.lt(1e3) ? (tmp[layer].resetDesc !== undefined ? tmp[layer].resetDesc : "Reset for ") : ""}+${formatWhole(tmp[layer].resetGain)} ${tmp[layer].resource} ${tmp[layer].resetGain.lt(100) && player[layer].points.lt(1e3) ? `

Next at ${ (tmp[layer].resCeil ? formatWhole(tmp[layer].nextAt) : format(tmp[layer].nextAt))}` : ""} ${ tmp[layer].baseResource }` + else if(tmp[layer].type== "static") + return `${tmp[layer].resetDesc !== undefined ? tmp[layer].resetDesc : "Reset for "}+${formatWhole(tmp[layer].resetGain)} ${tmp[layer].resource}

${player[layer].points.lt(20) ? (tmp[layer].baseAmount.gte(tmp[layer].nextAt)&&(tmp[layer].canBuyMax !== undefined) && tmp[layer].canBuyMax?"Next":"Req") : ""}: ${formatWhole(tmp[layer].baseAmount)} / ${(tmp[layer].resCeil ? formatWhole(tmp[layer].nextAtDisp) : format(tmp[layer].nextAtDisp))} ${ tmp[layer].baseResource } + ` + else + return layers[layer].prestigeButtonText() +} + + + + + function isFunction(obj) { return !!(obj && obj.constructor && obj.call && obj.apply); }; diff --git a/js/v.js b/js/v.js index 923df0b..402a092 100644 --- a/js/v.js +++ b/js/v.js @@ -44,9 +44,9 @@ function loadVue() {
-
-
-
+
+
+
@@ -60,9 +60,9 @@ function loadVue() {
-
-
-
+
+
+
@@ -90,9 +90,9 @@ function loadVue() { props: ['layer'], template: `
-
-
- +
+
+
@@ -103,13 +103,13 @@ function loadVue() { Vue.component('chall', { props: ['layer', 'data'], template: ` -
-



-

-
- Goal: {{format(tmp.challs[layer][data].goal)}} {{layers[layer].challs[data].currencyDisplayName ? layers[layer].challs[data].currencyDisplayName : "points"}}
- Reward:
- Currently: +
+



+

+
+ Goal: {{format(tmp[layer].challs[data].goal)}} {{tmp[layer].challs[data].currencyDisplayName ? tmp[layer].challs[data].currencyDisplayName : "points"}}
+ Reward:
+ Currently:
` }) @@ -120,7 +120,7 @@ function loadVue() {
- +

@@ -132,12 +132,12 @@ function loadVue() { Vue.component('upgrade', { props: ['layer', 'data'], template: ` - ` }) @@ -147,8 +147,8 @@ function loadVue() { template: `
- - + +

@@ -160,17 +160,17 @@ function loadVue() { Vue.component('milestone', { props: ['layer', 'data'], template: ` - -


-
-   + +


+
+   ` }) Vue.component('toggle', { props: ['layer', 'data'], template: ` - + ` }) @@ -178,14 +178,10 @@ function loadVue() { Vue.component('prestige-button', { props: ['layer', 'data'], template: ` - - - - - + ` }) @@ -194,7 +190,7 @@ function loadVue() { Vue.component('main-display', { props: ['layer'], template: ` -
You have

{{formatWhole(player[layer].points)}}

{{layers[layer].resource}}, {{tmp.effectDescription[layer]}}

+
You have

{{formatWhole(player[layer].points)}}

{{tmp[layer].resource}}, {{tmp[layer].effectDescription}}

` }) @@ -203,10 +199,10 @@ function loadVue() { props: ['layer', 'data'], template: `
-
-
-
- +
+
+
+

@@ -219,12 +215,12 @@ function loadVue() { props: ['layer', 'data', 'size'], template: ` ` }) @@ -238,9 +234,9 @@ function loadVue() { template: `
- +
- +
` }) @@ -249,7 +245,7 @@ function loadVue() { Vue.component('gague', { props: ['layer', 'data'], template: ` -
@@ -264,7 +260,7 @@ function loadVue() { template: `
- +
` @@ -279,20 +275,20 @@ function loadVue() { showTab(layer) }" v-bind:tooltip=" - player[layer].unl ? (layers[layer].tooltip ? tmp.tooltips[layer] : formatWhole(player[layer].points) + ' ' + layers[layer].resource) - : (layers[layer].tooltipLocked ? tmp.tooltipsLocked[layer] : 'Reach ' + formatWhole(tmp.layerReqs[layer]) + ' ' + layers[layer].baseResource + ' to unlock (You have ' + formatWhole(tmp.layerAmt[layer]) + ' ' + layers[layer].baseResource + ')') + player[layer].unl ? (tmp[layer].tooltip ? tmp[layer].tooltip : formatWhole(player[layer].points) + ' ' + tmp[layer].resource) + : (tmp[layer].tooltipLocked ? tmp[layer].tooltipLocked : 'Reach ' + formatWhole(tmp[layer].requires) + ' ' + tmp[layer].baseResource + ' to unlock (You have ' + formatWhole(tmp[layer].baseAmount) + ' ' + tmp[layer].baseResource + ')') " v-bind:class="{ treeNode: true, [layer]: true, - hidden: !tmp.layerShown[layer], - locked: !player[layer].unl && !tmp.layerAmt[layer].gte(tmp.layerReqs[layer]), - notify: tmp.notify[layer], + hidden: !tmp[layer].layerShown, + locked: !player[layer].unl && !tmp[layer].baseAmount.gte(tmp[layer].requires), + notify: tmp[layer].notify, can: layerUnl(layer), }" v-bind:style="[layerUnl(layer) ? { - 'background-color': tmp.layerColor[layer], - } : {}, tmp.nodeStyle[layer]]"> + 'background-color': tmp[layer].color, + } : {}, tmp[layer].nodeStyle]"> {{abb}} `