diff --git a/docs/layer-features.md b/docs/layer-features.md
index 1ec74ac..98bdf9c 100644
--- a/docs/layer-features.md
+++ b/docs/layer-features.md
@@ -49,6 +49,11 @@ Key:
],
```
+- branches: **optional**, determines what lines should appear on the tree when this layer is visible.
+ An array of pairs consisting of a layer name and a number from 1 to 3.
+ A branch will appear connecting this layer to the correspodnding layer, with the color based on the number.
+ You should add the branch value to the layer that is unlocked second.
+
- style: A CSS object containing any CSS that should affect this layer's whole tab.
Can also be a function returning a dynamic CSS object.
@@ -132,8 +137,5 @@ Key:
- incr_order: **optional**, an array of layer ids. When this layer is unlocked for the first time, the "order" value
for any not-yet-unlocked layers in this list increases. This can be used to make them harder to unlock.
-- branches: **optional**, determines what lines should appear on the tree when this layer is visible.
- An array of pairs consisting of a layer name and a number from 1 to 3.
- A branch will appear connecting this layer to the correspodnding layer, with the color based on the number.
- You should add the branch value to the layer that is unlocked second.
-
+- should_notify: **optional**, a function to return true if this layer should be highlighted in the tree.
+ The layer will automatically be highlighted if you can buy an upgrade whether you have this or not.
\ No newline at end of file
diff --git a/index.html b/index.html
index 8868fe8..5f26a27 100644
--- a/index.html
+++ b/index.html
@@ -45,6 +45,12 @@
+
v1.2.4
+
+
Layers are now highlighted if you can buy an upgrade, and a new feature, shouldNotify, lets you make it highlight other ways.
+
Fixed bugs with hasUpg, hasChall, hasMilestone, and inChallenge.
+
Changed the sample code to use the above functions for convenience.
+
v1.2.3
Added a row component, which displays a list of objects in a row.
diff --git a/js/game.js b/js/game.js
index 2ee13eb..b2ba59a 100644
--- a/js/game.js
+++ b/js/game.js
@@ -5,7 +5,7 @@ var NaNalert = false;
var gameEnded = false;
let VERSION = {
- num: "1.2.3",
+ num: "1.2.4",
name: "This changes everything!"
}
@@ -48,9 +48,10 @@ function getPointGen() {
// Function to determine if the player is in a challenge
function inChallenge(layer, id){
- if (player.c.active==x) return true
+ let chall = player[layer].active
+ if (chall==toNumber(id)) return true
- if (layers[layer].challs[id].countsAs)
+ if (layers[layer].challs[chall].countsAs)
return layers[layer].challs[id].countsAs.includes(id)
}
@@ -103,6 +104,23 @@ function getNextAt(layer) {
}
}
+// Return true if the layer should be highlighted. By default checks for upgrades only.
+function shouldNotify(layer){
+ for (id in layers[layer].upgrades){
+ if (!isNaN(id)){
+ if (canAffordUpg(layer, id) && !hasUpg(layer, id) && tmp.upgrades[layer][id].unl){
+ return true
+ }
+ }
+ }
+
+ if (layers[layer].shouldNotify){
+ return layers[layer].shouldNotify()
+ }
+ else
+ return false
+}
+
function rowReset(row, layer) {
for (lr in ROW_LAYERS[row]){
if(layers[lr].doReset)
@@ -208,15 +226,15 @@ function canAffordUpg(layer, id) {
}
function hasUpg(layer, id){
- return (player[layer].upgrades.includes(id))
+ return (player[layer].upgrades.includes(toNumber(id)))
}
function hasMilestone(layer, id){
- return (player[layer].milestones.includes(id))
+ return (player[layer].milestones.includes(toNumber(id)))
}
function hasChall(layer, id){
- return (player[layer].challs.includes(id))
+ return (player[layer].challs.includes(toNumber(id)))
}
function canAffordPurchase(layer, thing, cost) {
diff --git a/js/layers.js b/js/layers.js
index 5a8d9f6..74df6b4 100644
--- a/js/layers.js
+++ b/js/layers.js
@@ -20,8 +20,8 @@ addLayer("c", {
canBuyMax() {}, // Only needed for static layers with buy max
gainMult() { // Calculate the multiplier for main currency from bonuses
mult = new Decimal(1)
- if (player[this.layer].upgrades.includes(21)) mult = mult.times(2)
- if (player[this.layer].upgrades.includes(23)) mult = mult.times(this.upgrades[23].currently())
+ if (hasUpg(this.layer, 166)) mult = mult.times(2)
+ if (hasUpg(this.layer, 12)) mult = mult.times(this.upgrades[12].effect())
return mult
},
gainExp() { // Calculate the exponent on main currency from bonuses
@@ -83,7 +83,7 @@ addLayer("c", {
12: {
desc:() => "Candy generation is faster based on your unspent Lollipops.",
cost:() => new Decimal(1),
- unl() { return player[this.layer].upgrades.includes(11) },
+ unl() { return (hasUpg(this.layer, 11))},
effect() { // Calculate bonuses from the upgrade. Can return a single value or an object with multiple values
let ret = player[this.layer].points.add(1).pow(player[this.layer].upgrades.includes(24)?1.1:(player[this.layer].upgrades.includes(14)?0.75:0.5))
if (ret.gte("1e20000000")) ret = ret.sqrt().times("1e10000000")
@@ -97,7 +97,7 @@ addLayer("c", {
currencyDisplayName: "candies", // Use if using a nonstandard currency
currencyInternalName: "points", // Use if using a nonstandard currency
currencyLayer: "", // Leave empty if not in a layer "e.g. points"
- unl() { return player[this.layer].upgrades.includes(12) },
+ unl() { return (hasUpg(this.layer, 12))},
onPurchase() { // This function triggers when the upgrade is purchased
player[this.layer].order = 0
}
@@ -192,6 +192,10 @@ addLayer("c", {
style() {return {
'background-color': '#3325CC'
}},
+ 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)
+ }
})
addLayer("f", {
diff --git a/js/temp.js b/js/temp.js
index 3153905..c3b2959 100644
--- a/js/temp.js
+++ b/js/temp.js
@@ -44,6 +44,7 @@ function updateTemp() {
if (!tmp.layerShown) tmp.layerShown = {}
if (!tmp.effectDescription) tmp.effectDescription = {}
if (!tmp.style) tmp.style = {}
+ if (!tmp.notify) tmp.notify = {}
for (layer in layers) {
@@ -55,6 +56,7 @@ function updateTemp() {
tmp.gainExp[layer] = layers[layer].gainExp()
tmp.resetGain[layer] = getResetGain(layer)
tmp.nextAt[layer] = getNextAt(layer)
+ tmp.notify[layer] = shouldNotify(layer)
if (layers[layer].effectDescription) tmp.effectDescription[layer] = layers[layer].effectDescription()
}
diff --git a/js/v.js b/js/v.js
index a889d70..74c3734 100644
--- a/js/v.js
+++ b/js/v.js
@@ -18,6 +18,7 @@ function loadVue() {
[layer]: true,
hidden: !tmp.layerShown[layer],
locked: !player[layer].unl && !tmp.layerAmt[layer].gte(tmp.layerReqs[layer]),
+ notify: tmp.notify[layer],
can: layerUnl(layer),
}"
v-bind:style="{