1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-24 17:31:50 +00:00

1.2.4: Added layer notification highlighting, fixed bugs with useful functions

Did not add Duke Fishron
This commit is contained in:
Acamaeda 2020-10-04 11:23:38 -04:00
parent f2a0a5ac28
commit b43b97991e
6 changed files with 48 additions and 15 deletions

View file

@ -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. - 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. 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 - 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. 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. - should_notify: **optional**, a function to return true if this layer should be highlighted in the tree.
An array of pairs consisting of a layer name and a number from 1 to 3. The layer will automatically be highlighted if you can buy an upgrade whether you have this or not.
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.

View file

@ -45,6 +45,12 @@
</div> </div>
<div v-if="player.tab=='changelog'" class="col right"> <div v-if="player.tab=='changelog'" class="col right">
<button class="back" onclick="showTab('tree')"></button><br> <button class="back" onclick="showTab('tree')"></button><br>
<h3>v1.2.4</h3>
<ul>
<li>Layers are now highlighted if you can buy an upgrade, and a new feature, shouldNotify, lets you make it highlight other ways.</li>
<li>Fixed bugs with hasUpg, hasChall, hasMilestone, and inChallenge.</li>
<li>Changed the sample code to use the above functions for convenience.</li>
</ul><br>
<h3>v1.2.3</h3> <h3>v1.2.3</h3>
<ul> <ul>
<li>Added a row component, which displays a list of objects in a row.</li> <li>Added a row component, which displays a list of objects in a row.</li>

View file

@ -5,7 +5,7 @@ var NaNalert = false;
var gameEnded = false; var gameEnded = false;
let VERSION = { let VERSION = {
num: "1.2.3", num: "1.2.4",
name: "This changes everything!" name: "This changes everything!"
} }
@ -48,9 +48,10 @@ function getPointGen() {
// Function to determine if the player is in a challenge // Function to determine if the player is in a challenge
function inChallenge(layer, id){ 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) 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) { function rowReset(row, layer) {
for (lr in ROW_LAYERS[row]){ for (lr in ROW_LAYERS[row]){
if(layers[lr].doReset) if(layers[lr].doReset)
@ -208,15 +226,15 @@ function canAffordUpg(layer, id) {
} }
function hasUpg(layer, id){ function hasUpg(layer, id){
return (player[layer].upgrades.includes(id)) return (player[layer].upgrades.includes(toNumber(id)))
} }
function hasMilestone(layer, id){ function hasMilestone(layer, id){
return (player[layer].milestones.includes(id)) return (player[layer].milestones.includes(toNumber(id)))
} }
function hasChall(layer, id){ function hasChall(layer, id){
return (player[layer].challs.includes(id)) return (player[layer].challs.includes(toNumber(id)))
} }
function canAffordPurchase(layer, thing, cost) { function canAffordPurchase(layer, thing, cost) {

View file

@ -20,8 +20,8 @@ addLayer("c", {
canBuyMax() {}, // Only needed for static layers with buy max canBuyMax() {}, // Only needed for static layers with buy max
gainMult() { // Calculate the multiplier for main currency from bonuses gainMult() { // Calculate the multiplier for main currency from bonuses
mult = new Decimal(1) mult = new Decimal(1)
if (player[this.layer].upgrades.includes(21)) mult = mult.times(2) if (hasUpg(this.layer, 166)) mult = mult.times(2)
if (player[this.layer].upgrades.includes(23)) mult = mult.times(this.upgrades[23].currently()) if (hasUpg(this.layer, 12)) mult = mult.times(this.upgrades[12].effect())
return mult return mult
}, },
gainExp() { // Calculate the exponent on main currency from bonuses gainExp() { // Calculate the exponent on main currency from bonuses
@ -83,7 +83,7 @@ addLayer("c", {
12: { 12: {
desc:() => "Candy generation is faster based on your unspent Lollipops.", desc:() => "Candy generation is faster based on your unspent Lollipops.",
cost:() => new Decimal(1), 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 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)) 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") if (ret.gte("1e20000000")) ret = ret.sqrt().times("1e10000000")
@ -97,7 +97,7 @@ addLayer("c", {
currencyDisplayName: "candies", // Use if using a nonstandard currency currencyDisplayName: "candies", // Use if using a nonstandard currency
currencyInternalName: "points", // 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" 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 onPurchase() { // This function triggers when the upgrade is purchased
player[this.layer].order = 0 player[this.layer].order = 0
} }
@ -192,6 +192,10 @@ addLayer("c", {
style() {return { style() {return {
'background-color': '#3325CC' '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", { addLayer("f", {

View file

@ -44,6 +44,7 @@ function updateTemp() {
if (!tmp.layerShown) tmp.layerShown = {} if (!tmp.layerShown) tmp.layerShown = {}
if (!tmp.effectDescription) tmp.effectDescription = {} if (!tmp.effectDescription) tmp.effectDescription = {}
if (!tmp.style) tmp.style = {} if (!tmp.style) tmp.style = {}
if (!tmp.notify) tmp.notify = {}
for (layer in layers) { for (layer in layers) {
@ -55,6 +56,7 @@ function updateTemp() {
tmp.gainExp[layer] = layers[layer].gainExp() tmp.gainExp[layer] = layers[layer].gainExp()
tmp.resetGain[layer] = getResetGain(layer) tmp.resetGain[layer] = getResetGain(layer)
tmp.nextAt[layer] = getNextAt(layer) tmp.nextAt[layer] = getNextAt(layer)
tmp.notify[layer] = shouldNotify(layer)
if (layers[layer].effectDescription) tmp.effectDescription[layer] = layers[layer].effectDescription() if (layers[layer].effectDescription) tmp.effectDescription[layer] = layers[layer].effectDescription()
} }

View file

@ -18,6 +18,7 @@ function loadVue() {
[layer]: true, [layer]: true,
hidden: !tmp.layerShown[layer], hidden: !tmp.layerShown[layer],
locked: !player[layer].unl && !tmp.layerAmt[layer].gte(tmp.layerReqs[layer]), locked: !player[layer].unl && !tmp.layerAmt[layer].gte(tmp.layerReqs[layer]),
notify: tmp.notify[layer],
can: layerUnl(layer), can: layerUnl(layer),
}" }"
v-bind:style="{ v-bind:style="{