1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2025-05-12 13:01:05 +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

@ -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) {

View file

@ -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", {

View file

@ -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()
}

View file

@ -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="{