mirror of
https://github.com/Acamaeda/The-Modding-Tree.git
synced 2024-11-25 01:41:45 +00:00
2.2.5
This commit is contained in:
parent
977643f5f6
commit
324e868430
9 changed files with 83 additions and 46 deletions
|
@ -1,5 +1,9 @@
|
||||||
# The Modding Tree changelog:
|
# The Modding Tree changelog:
|
||||||
|
|
||||||
|
- Added fullDisplay feature to upgrades and challenges, overrides other displays and lets you set the full text.
|
||||||
|
- best, total, and unlocked are always automatically added to layerData (but best and total will only display if you add them yourself).
|
||||||
|
- Fixed getStartClickables.
|
||||||
|
|
||||||
### v2.2.4 - 11/28/20
|
### v2.2.4 - 11/28/20
|
||||||
- Added softcap and softcapPower features (for Normal layers)
|
- Added softcap and softcapPower features (for Normal layers)
|
||||||
- Offline time limit and default max tick length were fixed (previously the limits were 1000x too large)
|
- Offline time limit and default max tick length were fixed (previously the limits were 1000x too large)
|
||||||
|
|
|
@ -37,6 +37,8 @@ Individual Challenges can have these features:
|
||||||
|
|
||||||
- rewardDisplay(): **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.
|
- rewardDisplay(): **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.
|
||||||
|
|
||||||
|
- fullDisplay(): **OVERRIDE**. Overrides the other displays and descriptions, and lets you set the full text for the challenge. Can use basic HTML.
|
||||||
|
|
||||||
- goal: A Decimal for the amount of currency required to beat the challenge. By default, the goal is in basic Points. The goal can also be a function if its value changes.
|
- goal: A Decimal for the amount of currency required to beat the challenge. By default, the goal is in basic Points. The goal can also be a function if its value changes.
|
||||||
|
|
||||||
- unlocked(): **optional**. A function returning a bool to determine if the challenge is visible or not. Default is unlocked.
|
- unlocked(): **optional**. A function returning a bool to determine if the challenge is visible or not. Default is unlocked.
|
||||||
|
@ -62,3 +64,7 @@ By default, challenges use basic Points for the goal. You can change that using
|
||||||
- currencyLayer: **optional**. the internal name of the layer that currency is stored in. If it's not in a layer, omit. If it's not stored directly in a layer, instead use the next feature.
|
- currencyLayer: **optional**. the internal name of the layer that currency is stored in. If it's not in a layer, omit. If it's not stored directly in a layer, instead use the next feature.
|
||||||
|
|
||||||
- currencyLocation: **optional**. if your currency is stored in something inside a layer (e.g. a buyable's amount), you can access it this way. This is a function returning the object in "player" that contains the value (like `player[this.layer].buyables`)
|
- currencyLocation: **optional**. if your currency is stored in something inside a layer (e.g. a buyable's amount), you can access it this way. This is a function returning the object in "player" that contains the value (like `player[this.layer].buyables`)
|
||||||
|
|
||||||
|
You can also set a fully custom win condition that overrides other goal-related features (use fullDisplay along with this)
|
||||||
|
|
||||||
|
- canComplete(): **OVERRIDE**, returns true if you can complete the challenge
|
|
@ -35,11 +35,13 @@ Individual upgrades can have these features:
|
||||||
|
|
||||||
- effectDisplay(): **optional**. A function that returns a display of the current effects of the upgrade with formatting. Default displays nothing. Can use basic HTML.
|
- effectDisplay(): **optional**. A function that returns a display of the current effects of the upgrade with formatting. Default displays nothing. Can use basic HTML.
|
||||||
|
|
||||||
|
- fullDisplay(): **OVERRIDE**. Overrides the other displays and descriptions, and lets you set the full text for the upgrade. Can use basic HTML.
|
||||||
|
|
||||||
- cost: A Decimal for the cost of the upgrade. By default, upgrades cost the main prestige currency for the layer.
|
- cost: A Decimal for the cost of the upgrade. By default, upgrades cost the main prestige currency for the layer.
|
||||||
|
|
||||||
- unlocked(): **optional**. A function returning a bool to determine if the upgrade is visible or not. Default is unlocked.
|
- unlocked(): **optional**. A function returning a bool to determine if the upgrade is visible or not. Default is unlocked.
|
||||||
|
|
||||||
- onPurchase() - **optional**. This function will be called when the upgrade is purchased. Good for upgrades like "makes this layer act like it was unlocked first".
|
- onPurchase(): **optional**. This function will be called when the upgrade is purchased. Good for upgrades like "makes this layer act like it was unlocked first".
|
||||||
|
|
||||||
- style: **optional**. Applies CSS to this upgrade, in the form of an object where the keys are CSS attributes, and the values are the values for those attributes (both as strings).
|
- style: **optional**. Applies CSS to this upgrade, in the form of an object where the keys are CSS attributes, and the values are the values for those attributes (both as strings).
|
||||||
|
|
||||||
|
@ -56,3 +58,9 @@ By default, upgrades use the main prestige currency for the layer. You can inclu
|
||||||
- currencyLayer: **optional**. The internal name of the layer that currency is stored in. If it's not in a layer (like Points), omit. If it's not stored directly in a layer, instead use the next feature.
|
- currencyLayer: **optional**. The internal name of the layer that currency is stored in. If it's not in a layer (like Points), omit. If it's not stored directly in a layer, instead use the next feature.
|
||||||
|
|
||||||
- currencyLocation: **optional**. If your currency is stored in something inside a layer (e.g. a buyable's amount), you can access it this way. This is a function returning the object in "player" that contains the value (like `player[this.layer].buyables`)
|
- currencyLocation: **optional**. If your currency is stored in something inside a layer (e.g. a buyable's amount), you can access it this way. This is a function returning the object in "player" that contains the value (like `player[this.layer].buyables`)
|
||||||
|
|
||||||
|
If you want to do something more complicated like upgrades that cost two currencies, you can override the purchase system with these (and you need to use fullDisplay as well)
|
||||||
|
|
||||||
|
-canAfford(): **OVERRIDE**, a function determining if you are able to buy the upgrade
|
||||||
|
|
||||||
|
-pay(): **OVERRIDE**, a function that reduces your currencies when you buy the upgrade
|
|
@ -119,11 +119,6 @@ addLayer("c", {
|
||||||
effectDisplay() { return format(this.effect())+"x" }, // Add formatting to the effect
|
effectDisplay() { return format(this.effect())+"x" }, // Add formatting to the effect
|
||||||
},
|
},
|
||||||
13: {
|
13: {
|
||||||
description: "Unlock a <b>secret subtab</b> and make this layer act if you unlocked it first.",
|
|
||||||
cost: new Decimal(69),
|
|
||||||
currencyDisplayName: "candies", // Use if using a nonstandard currency
|
|
||||||
currencyInternalName: "points", // Use if using a nonstandard currency
|
|
||||||
currencyLocation: "", // The object in player data that the currency is contained in
|
|
||||||
unlocked() { return (hasUpgrade(this.layer, 12))},
|
unlocked() { return (hasUpgrade(this.layer, 12))},
|
||||||
onPurchase() { // This function triggers when the upgrade is purchased
|
onPurchase() { // This function triggers when the upgrade is purchased
|
||||||
player[this.layer].unlockOrder = 0
|
player[this.layer].unlockOrder = 0
|
||||||
|
@ -138,6 +133,9 @@ addLayer("c", {
|
||||||
}
|
}
|
||||||
} // Otherwise use the default
|
} // Otherwise use the default
|
||||||
},
|
},
|
||||||
|
canAfford(){return player.points.lte(7)},
|
||||||
|
pay(){player.points = player.points.add(7)},
|
||||||
|
fullDisplay: "Only buyable with less than 7 points, and gives you 7 more. Unlocks a secret subtab."
|
||||||
},
|
},
|
||||||
22: {
|
22: {
|
||||||
title: "This upgrade doesn't exist",
|
title: "This upgrade doesn't exist",
|
||||||
|
|
|
@ -12,7 +12,7 @@ let modInfo = {
|
||||||
|
|
||||||
// Set your version in num and name
|
// Set your version in num and name
|
||||||
let VERSION = {
|
let VERSION = {
|
||||||
num: "2.2.4",
|
num: "2.2.5",
|
||||||
name: "Uprooted",
|
name: "Uprooted",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,10 +153,13 @@ function loadVue() {
|
||||||
template: `
|
template: `
|
||||||
<button v-if="tmp[layer].upgrades && tmp[layer].upgrades[data]!== undefined && tmp[layer].upgrades[data].unlocked" v-on:click="buyUpg(layer, data)" v-bind:class="{ [layer]: true, upg: true, bought: hasUpgrade(layer, data), locked: (!(canAffordUpgrade(layer, data))&&!hasUpgrade(layer, data)), can: (canAffordUpgrade(layer, data)&&!hasUpgrade(layer, data))}"
|
<button v-if="tmp[layer].upgrades && tmp[layer].upgrades[data]!== undefined && tmp[layer].upgrades[data].unlocked" v-on:click="buyUpg(layer, data)" v-bind:class="{ [layer]: true, upg: true, bought: hasUpgrade(layer, data), locked: (!(canAffordUpgrade(layer, data))&&!hasUpgrade(layer, data)), can: (canAffordUpgrade(layer, data)&&!hasUpgrade(layer, data))}"
|
||||||
v-bind:style="[((!hasUpgrade(layer, data) && canAffordUpgrade(layer, data)) ? {'background-color': tmp[layer].color} : {}), tmp[layer].upgrades[data].style]">
|
v-bind:style="[((!hasUpgrade(layer, data) && canAffordUpgrade(layer, data)) ? {'background-color': tmp[layer].color} : {}), tmp[layer].upgrades[data].style]">
|
||||||
|
<span v-if="tmp[layer].upgrades[data].fullDisplay" v-html="tmp[layer].upgrades[data].fullDisplay"></span>
|
||||||
|
<span v-else>
|
||||||
<span v-if= "tmp[layer].upgrades[data].title"><h3 v-html="tmp[layer].upgrades[data].title"></h3><br></span>
|
<span v-if= "tmp[layer].upgrades[data].title"><h3 v-html="tmp[layer].upgrades[data].title"></h3><br></span>
|
||||||
<span v-html="tmp[layer].upgrades[data].description"></span>
|
<span v-html="tmp[layer].upgrades[data].description"></span>
|
||||||
<span v-if="tmp[layer].upgrades[data].effectDisplay"><br>Currently: <span v-html="tmp[layer].upgrades[data].effectDisplay"></span></span>
|
<span v-if="tmp[layer].upgrades[data].effectDisplay"><br>Currently: <span v-html="tmp[layer].upgrades[data].effectDisplay"></span></span>
|
||||||
<br><br>Cost: {{ formatWhole(tmp[layer].upgrades[data].cost) }} {{(tmp[layer].upgrades[data].currencyDisplayName ? tmp[layer].upgrades[data].currencyDisplayName : tmp[layer].resource)}}
|
<br><br>Cost: {{ formatWhole(tmp[layer].upgrades[data].cost) }} {{(tmp[layer].upgrades[data].currencyDisplayName ? tmp[layer].upgrades[data].currencyDisplayName : tmp[layer].resource)}}
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,7 +4,7 @@ var gameEnded = false;
|
||||||
|
|
||||||
// Don't change this
|
// Don't change this
|
||||||
const TMT_VERSION = {
|
const TMT_VERSION = {
|
||||||
tmtNum: "2.2.4",
|
tmtNum: "2.2.5",
|
||||||
tmtName: "Uprooted"
|
tmtName: "Uprooted"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ function layerDataReset(layer, keep = []) {
|
||||||
storedData[keep[thing]] = player[layer][keep[thing]]
|
storedData[keep[thing]] = player[layer][keep[thing]]
|
||||||
}
|
}
|
||||||
|
|
||||||
layOver(player[layer], layers[layer].startData());
|
layOver(player[layer], getStartLayerData(layer))
|
||||||
player[layer].upgrades = []
|
player[layer].upgrades = []
|
||||||
player[layer].milestones = []
|
player[layer].milestones = []
|
||||||
player[layer].challenges = getStartChallenges(layer)
|
player[layer].challenges = getStartChallenges(layer)
|
||||||
|
@ -230,8 +230,8 @@ function startChallenge(layer, x) {
|
||||||
function canCompleteChallenge(layer, x)
|
function canCompleteChallenge(layer, x)
|
||||||
{
|
{
|
||||||
if (x != player[layer].activeChallenge) return
|
if (x != player[layer].activeChallenge) return
|
||||||
|
|
||||||
let challenge = tmp[layer].challenges[x]
|
let challenge = tmp[layer].challenges[x]
|
||||||
|
if (challenge.canComplete !== undefined) return challenge.canComplete
|
||||||
|
|
||||||
if (challenge.currencyInternalName){
|
if (challenge.currencyInternalName){
|
||||||
let name = challenge.currencyInternalName
|
let name = challenge.currencyInternalName
|
||||||
|
|
|
@ -5,7 +5,7 @@ var NaNalert = false;
|
||||||
var activeFunctions = [
|
var activeFunctions = [
|
||||||
"startData", "onPrestige", "doReset", "update", "automate",
|
"startData", "onPrestige", "doReset", "update", "automate",
|
||||||
"buy", "buyMax", "respec", "onComplete", "onPurchase", "onPress", "onClick", "masterButtonPress",
|
"buy", "buyMax", "respec", "onComplete", "onPurchase", "onPress", "onClick", "masterButtonPress",
|
||||||
"sellOne", "sellAll",
|
"sellOne", "sellAll", "pay",
|
||||||
]
|
]
|
||||||
|
|
||||||
var noCall = doNotCallTheseFunctionsEveryTick
|
var noCall = doNotCallTheseFunctionsEveryTick
|
||||||
|
|
44
js/utils.js
44
js/utils.js
|
@ -115,17 +115,8 @@ function getStartPlayer() {
|
||||||
|
|
||||||
playerdata.infoboxes = {}
|
playerdata.infoboxes = {}
|
||||||
for (layer in layers){
|
for (layer in layers){
|
||||||
playerdata[layer] = {}
|
playerdata[layer] = getStartLayerData(layer)
|
||||||
if (layers[layer].startData)
|
|
||||||
playerdata[layer] = layers[layer].startData()
|
|
||||||
else playerdata[layer].unlocked = true
|
|
||||||
playerdata[layer].buyables = getStartBuyables(layer)
|
|
||||||
if(playerdata[layer].clickables == undefined) playerdata[layer].clickables = getStartClickables(layer)
|
|
||||||
playerdata[layer].spentOnBuyables = new Decimal(0)
|
|
||||||
playerdata[layer].upgrades = []
|
|
||||||
playerdata[layer].milestones = []
|
|
||||||
playerdata[layer].achievements = []
|
|
||||||
playerdata[layer].challenges = getStartChallenges(layer)
|
|
||||||
if (layers[layer].tabFormat && !Array.isArray(layers[layer].tabFormat)) {
|
if (layers[layer].tabFormat && !Array.isArray(layers[layer].tabFormat)) {
|
||||||
playerdata.subtabs[layer] = {}
|
playerdata.subtabs[layer] = {}
|
||||||
playerdata.subtabs[layer].mainTabs = Object.keys(layers[layer].tabFormat)[0]
|
playerdata.subtabs[layer].mainTabs = Object.keys(layers[layer].tabFormat)[0]
|
||||||
|
@ -140,10 +131,30 @@ function getStartPlayer() {
|
||||||
for (item in layers[layer].infoboxes)
|
for (item in layers[layer].infoboxes)
|
||||||
playerdata.infoboxes[layer][item] = false
|
playerdata.infoboxes[layer][item] = false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return playerdata
|
return playerdata
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getStartLayerData(layer){
|
||||||
|
layerdata = {}
|
||||||
|
if (layers[layer].startData)
|
||||||
|
layerdata = layers[layer].startData()
|
||||||
|
|
||||||
|
if (layerdata.unlocked === undefined) layerdata.unlocked = true
|
||||||
|
if (layerdata.total === undefined) layerdata.total = new Decimal(0)
|
||||||
|
if (layerdata.best === undefined) layerdata.best = new Decimal(0)
|
||||||
|
|
||||||
|
layerdata.buyables = getStartBuyables(layer)
|
||||||
|
if(layerdata.clickables == undefined) layerdata.clickables = getStartClickables(layer)
|
||||||
|
layerdata.spentOnBuyables = new Decimal(0)
|
||||||
|
layerdata.upgrades = []
|
||||||
|
layerdata.milestones = []
|
||||||
|
layerdata.achievements = []
|
||||||
|
layerdata.challenges = getStartChallenges(layer)
|
||||||
|
return layerdata
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function getStartBuyables(layer){
|
function getStartBuyables(layer){
|
||||||
let data = {}
|
let data = {}
|
||||||
|
@ -159,7 +170,6 @@ function getStartClickables(layer){
|
||||||
let data = {}
|
let data = {}
|
||||||
if (layers[layer].clickables) {
|
if (layers[layer].clickables) {
|
||||||
if (isPlainObject(layers[layer].clickables[id]))
|
if (isPlainObject(layers[layer].clickables[id]))
|
||||||
if (isPlainObject(id))
|
|
||||||
data[id] = ""
|
data[id] = ""
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
@ -439,6 +449,7 @@ function respecBuyables(layer) {
|
||||||
|
|
||||||
function canAffordUpgrade(layer, id) {
|
function canAffordUpgrade(layer, id) {
|
||||||
let upg = tmp[layer].upgrades[id]
|
let upg = tmp[layer].upgrades[id]
|
||||||
|
if (tmp[layer].upgrades[id].canAfford !== undefined) return tmp[layer].upgrades[id].canAfford
|
||||||
let cost = tmp[layer].upgrades[id].cost
|
let cost = tmp[layer].upgrades[id].cost
|
||||||
return canAffordPurchase(layer, upg, cost)
|
return canAffordPurchase(layer, upg, cost)
|
||||||
}
|
}
|
||||||
|
@ -528,10 +539,16 @@ function buyUpgrade(layer, id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function buyUpg(layer, id) {
|
function buyUpg(layer, id) {
|
||||||
|
let upg = tmp[layer].upgrades[id]
|
||||||
if (!player[layer].unlocked) return
|
if (!player[layer].unlocked) return
|
||||||
if (!tmp[layer].upgrades[id].unlocked) return
|
if (!tmp[layer].upgrades[id].unlocked) return
|
||||||
if (player[layer].upgrades.includes(id)) return
|
if (player[layer].upgrades.includes(id)) return
|
||||||
let upg = tmp[layer].upgrades[id]
|
if (upg.canAfford === false) return
|
||||||
|
let pay = layers[layer].upgrades[id].pay
|
||||||
|
if (pay !== undefined)
|
||||||
|
pay()
|
||||||
|
else
|
||||||
|
{
|
||||||
let cost = tmp[layer].upgrades[id].cost
|
let cost = tmp[layer].upgrades[id].cost
|
||||||
|
|
||||||
if (upg.currencyInternalName){
|
if (upg.currencyInternalName){
|
||||||
|
@ -554,6 +571,7 @@ function buyUpg(layer, id) {
|
||||||
if (player[layer].points.lt(cost)) return
|
if (player[layer].points.lt(cost)) return
|
||||||
player[layer].points = player[layer].points.sub(cost)
|
player[layer].points = player[layer].points.sub(cost)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
player[layer].upgrades.push(id);
|
player[layer].upgrades.push(id);
|
||||||
if (upg.onPurchase != undefined)
|
if (upg.onPurchase != undefined)
|
||||||
upg.onPurchase()
|
upg.onPurchase()
|
||||||
|
|
Loading…
Reference in a new issue