From f0c394225361d9cb29ea3c91aae0c479ace0fb84 Mon Sep 17 00:00:00 2001 From: Acamaeda Date: Sat, 7 Nov 2020 23:34:53 -0500 Subject: [PATCH] Added standardized automation --- changelog.md | 3 +++ docs/layer-features.md | 15 ++++++++++++--- js/Demo/demoLayers.js | 2 +- js/components.js | 2 ++ js/game.js | 4 ++++ js/technical/systemComponents.js | 3 ++- js/technical/temp.js | 6 ++++-- js/utils.js | 20 ++++++++++++++++---- style.css | 10 +++++----- 9 files changed, 49 insertions(+), 16 deletions(-) diff --git a/changelog.md b/changelog.md index 037bf5c..3755e7c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,9 +1,12 @@ # The Modding Tree changelog: ### v2.2.1 - 11/7/20 +- Added a small highlight to layers you can meaningfully prestige on. +- Added passiveGeneration and autoPrestige features to standardize prestige automation. (The old ways still work, but the new ones work better with other things) - Improved milestones visually a bit. - "best" and "total" are now only displayed if present in startData. - Fixed issues with things not updating visually. (Thank you to to Jacorb!) +- Side layers and button nodes can now be highlighted. - Updated docs on the new tree-related features. ## v2.2: Uprooted - 11/7/20 diff --git a/docs/layer-features.md b/docs/layer-features.md index 4077339..fc5fbcc 100644 --- a/docs/layer-features.md +++ b/docs/layer-features.md @@ -102,7 +102,13 @@ You can make almost any value dynamic by using a function in its place, includin - resetDesc: **optional**. Use this to replace "Reset for " on the Prestige button with something else. -- prestigeButtonText(): **sometimes required**. Use this to make the entirety of the text a Prestige button contains. Only required for custom layers, but usable by all types. +- prestigeButtonText(): **sometimes required**. Use this to make the entirety of the text a Prestige button contains. Only required for custom layers, but usable by all types. + +- passiveGain(): **optional**, returns a regular number. You automatically generate your gain times this number every second (does nothing if absent) + This is good for automating Normal layers. + +- autoPrestige(): **optional**, returns a boolean, if true, the layer will always automatically do a prestige if it can. + This is good for automating Static layers. ## Tree/node features @@ -122,9 +128,9 @@ You can make almost any value dynamic by using a function in its place, includin If you want to keep things, determine what to keep based on `resettingLayer`, `milestones`, and such, then call `layerDataReset(layer, keep)`, where `layer` is this layer, and `keep` is an array of the names of things to keep. It can include things like "points", "best", "total" (for this layer's prestige currency), "upgrades", any unique variables like "generatorPower", etc. If you want to only keep specific upgrades or something like that, save them in a separate variable, then call `layerDataReset`, and then set `player[this.layer].upgrades` to the saved upgrades. -- update(diff): **optional**. This function is called every game tick. Use it for any passive resource production or time-based things. `diff` is the time since the last tick. Suggestion: use `addPoints(layer, gain)` when generating points to automatically update the best and total amounts. +- update(diff): **optional**. This function is called every game tick. Use it for any passive resource production or time-based things. `diff` is the time since the last tick. -- 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. +- automate(): **optional**. This function is called every game tick, after production. Use it to activate automation things other than prestige, if appropriate. - resetsNothing: **optional**. Returns true if this layer shouldn't trigger any resets when you prestige. @@ -148,3 +154,6 @@ componentStyles: { - getNextAt(canMax=false): **for custom prestige type**. Returns how many of the base currency you need to get to the next point. `canMax` is an optional variable used with Static-ish layers to differentiate between if it's looking for the first point you can reset at, or the requirement for any gain at all (Supporting both is good). You can also call `getNextAt(this.layer, canMax=false, useType = "static")` or similar to calculate what your next at would be under another prestige type (provided you have all of the required features in the layer). - canReset(): **for custom prestige type**. Return true only if you have the resources required to do a prestige here. + +- prestigeNotify(): **mostly for custom prestige types**, returns true if this layer should be subtly highlighted to indicate you + can prestige for a meaningful gain. \ No newline at end of file diff --git a/js/Demo/demoLayers.js b/js/Demo/demoLayers.js index 95dceda..eb6e408 100644 --- a/js/Demo/demoLayers.js +++ b/js/Demo/demoLayers.js @@ -379,7 +379,7 @@ addLayer("f", { resource: "farm points", baseResource: "candies", baseAmount() {return player.points}, - type: "custom", // A "Custom" type which is effectively static + type: "static", exponent: 0.5, base: 3, roundUpCost: true, diff --git a/js/components.js b/js/components.js index 3350434..c9625ba 100644 --- a/js/components.js +++ b/js/components.js @@ -430,6 +430,8 @@ function loadVue() { hasChallenge, maxedChallenge, canAffordUpgrade, + subtabShouldNotify, + subtabResetNotify, VERSION, LAYERS, hotkeys diff --git a/js/game.js b/js/game.js index db1e1e3..5b774be 100644 --- a/js/game.js +++ b/js/game.js @@ -290,6 +290,7 @@ function gameLoop(diff) { for (x = 0; x <= maxRow; x++){ for (item in TREE_LAYERS[x]) { let layer = TREE_LAYERS[x][item] + if (tmp[layer].passiveGeneration) generatePoints(layer, diff*tmp[layer].passiveGeneration); if (layers[layer].update) layers[layer].update(diff); } } @@ -297,6 +298,7 @@ function gameLoop(diff) { for (row in OTHER_LAYERS){ for (item in OTHER_LAYERS[row]) { let layer = OTHER_LAYERS[row][item] + if (tmp[layer].passiveGeneration) generatePoints(layer, diff*tmp[layer].passiveGeneration); if (layers[layer].update) layers[layer].update(diff); } } @@ -304,6 +306,7 @@ function gameLoop(diff) { for (x = maxRow; x >= 0; x--){ for (item in TREE_LAYERS[x]) { let layer = TREE_LAYERS[x][item] + if (tmp[layer].autoPrestige && tmp[layer].canReset) doReset(layer); if (layers[layer].automate) layers[layer].automate(); } } @@ -311,6 +314,7 @@ function gameLoop(diff) { for (row in OTHER_LAYERS){ for (item in OTHER_LAYERS[row]) { let layer = OTHER_LAYERS[row][item] + if (tmp[layer].autoPrestige && tmp[layer].canReset) doReset(layer); if (layers[layer].automate) layers[layer].automate(); } } diff --git a/js/technical/systemComponents.js b/js/technical/systemComponents.js index ee1764b..ab71ec3 100644 --- a/js/technical/systemComponents.js +++ b/js/technical/systemComponents.js @@ -4,7 +4,7 @@ var systemComponents = { template: `
- +
` @@ -58,6 +58,7 @@ var systemComponents = { hidden: !tmp[layer].layerShown, locked: !player[layer].unlocked && !tmp[layer].baseAmount.gte(tmp[layer].requires), notify: tmp[layer].notify, + resetNotify: tmp[layer].prestigeNotify, can: player[layer].unlocked, }" v-bind:style="[layerunlocked(layer) ? { diff --git a/js/technical/temp.js b/js/technical/temp.js index fd866e8..b1d353d 100644 --- a/js/technical/temp.js +++ b/js/technical/temp.js @@ -23,8 +23,9 @@ function setupTemp() { tmp[layer].resetGain = {} tmp[layer].nextAt = {} tmp[layer].nextAtDisp = {} - tmp[layer].notify = {} tmp[layer].canReset = {} + tmp[layer].notify = {} + tmp[layer].prestigeNotify = {} tmp[layer].prestigeButtonText = {} setupBarStyles(layer) } @@ -63,8 +64,9 @@ function updateTemp() { 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].notify = shouldNotify(layer) + tmp[layer].prestigeNotify = prestigeNotify(layer) tmp[layer].prestigeButtonText = prestigeButtonText(layer) constructBarStyles(layer) } diff --git a/js/utils.js b/js/utils.js index 6173f08..cd52fae 100644 --- a/js/utils.js +++ b/js/utils.js @@ -629,6 +629,14 @@ function layOver(obj1, obj2) { } } +function prestigeNotify(layer) { + if (layers[layer].prestigeNotify) return layers[layer].prestigeNotify() + else if (tmp[layer].autoPrestige || tmp[layer].passiveGeneration) return false + else if (tmp[layer].type == "static") return tmp[layer].canReset + else if (tmp[layer].type == "normal") return (tmp[layer].canReset && (tmp[layer].resetGain.gte(player[layer].points.div(10)))) + else return false +} + function notifyLayer(name) { if (player.tab == name || !layerunlocked(name)) return player.notify[name] = 1 @@ -643,6 +651,14 @@ function subtabShouldNotify(layer, family, id){ else return subtab.shouldNotify } +function subtabResetNotify(layer, family, id){ + let subtab = {} + if (family == "mainTabs") subtab = tmp[layer].tabFormat[id] + else subtab = tmp[layer].microtabs[family][id] + if (subtab.embedLayer) return tmp[subtab.embedLayer].prestigeNotify + else return false +} + function nodeShown(layer) { if (tmp[layer].layerShown) return true switch(layer) { @@ -742,10 +758,6 @@ function prestigeButtonText(layer) return layers[layer].prestigeButtonText() } - - - - function isFunction(obj) { return !!(obj && obj.constructor && obj.call && obj.apply); }; diff --git a/style.css b/style.css index a90eddd..bc74b1a 100644 --- a/style.css +++ b/style.css @@ -93,6 +93,7 @@ h1, h2, h3, b, input { } + .smallNode { height: 60px; width: 60px; @@ -123,10 +124,9 @@ h1, h2, h3, b, input { box-shadow: 0px 0px 20px var(--points) } -.treeNode.notify { - transform: scale(1.1, 1.1); - border-color: rgba(0, 0, 0, 0.125); - box-shadow: var(--hqProperty2a), 0px 0px 20px #ff0000; + +.resetNotify { + box-shadow: var(--hqProperty2a), 0px 0px 8px #ffffff; z-index: 3 } @@ -136,7 +136,7 @@ h1, h2, h3, b, input { z-index: 4 } -.tabButton.notify { +.notify { transform: scale(1.05, 1.05); border-color: rgba(0, 0, 0, 0.125); box-shadow: var(--hqProperty2a), 0px 0px 20px #ff0000;