diff --git a/changelog.md b/changelog.md
index c350827..6e3aac9 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,10 @@
# The Modding Tree changelog:
+### v2.2.7 11/30/20
+- Added autoUpgrade feature.
+- resource-display now shows resource gain per second if passiveGain is active.
+- Fixed formatting issues on some large numbers.
+- Better support for using classed objects in player and in layers/tmp.
- Made hard resetting more effective.
- Removed Herobrine from getStartClickables.
diff --git a/docs/layer-features.md b/docs/layer-features.md
index 59a99b1..538f109 100644
--- a/docs/layer-features.md
+++ b/docs/layer-features.md
@@ -136,7 +136,9 @@ You can make almost any value dynamic by using a function in its place, includin
- 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 automation things other than prestige, if appropriate.
+- autoUpgrade: **optional**, a boolean value, if true, the game will attempt to buy this layer's upgrades every tick. Defaults to false.
+
+- automate(): **optional**. This function is called every game tick, after production. Use it to activate automation things that aren't otherwise supported.
- resetsNothing: **optional**. Returns true if this layer shouldn't trigger any resets when you prestige.
diff --git a/js/Demo/demoLayers.js b/js/Demo/demoLayers.js
index 905ca41..0c4bbc0 100644
--- a/js/Demo/demoLayers.js
+++ b/js/Demo/demoLayers.js
@@ -27,7 +27,6 @@ addLayer("c", {
// For normal layers, gain beyond [softcap] points is put to the [softcapPower]th power
softcap: new Decimal(1e100),
softcapPower: new Decimal(0.5),
-
canBuyMax() {}, // Only needed for static layers with buy max
gainMult() { // Calculate the multiplier for main currency from bonuses
mult = new Decimal(1)
diff --git a/js/Demo/demoMod.js b/js/Demo/demoMod.js
index 4d6e724..eae2d18 100644
--- a/js/Demo/demoMod.js
+++ b/js/Demo/demoMod.js
@@ -12,7 +12,7 @@ let modInfo = {
// Set your version in num and name
let VERSION = {
- num: "2.2.6",
+ num: "2.2.7",
name: "Uprooted",
}
@@ -69,4 +69,4 @@ function maxTickLength() {
// Use this if you need to undo inflation from an older version. If the version is older than the version that fixed the issue,
// you can cap their current resources with this.
function fixOldSave(oldVersion){
-}
\ No newline at end of file
+}
diff --git a/js/components.js b/js/components.js
index afe6509..d7831b0 100644
--- a/js/components.js
+++ b/js/components.js
@@ -222,6 +222,7 @@ function loadVue() {
template: `
You have {{formatWhole(tmp[layer].baseAmount)}} {{tmp[layer].baseResource}}
+
You are gaining {{formatWhole(tmp[layer].resetGain.times(tmp[layer].passiveGeneration))}} {{tmp[layer].resource}} per second
Your best {{tmp[layer].resource}} is {{formatWhole(player[layer].best)}}
You have made a total of {{formatWhole(player[layer].total)}} {{tmp[layer].resource}}
diff --git a/js/game.js b/js/game.js
index 2b4efa2..5a0cedd 100644
--- a/js/game.js
+++ b/js/game.js
@@ -4,7 +4,7 @@ var gameEnded = false;
// Don't change this
const TMT_VERSION = {
- tmtNum: "2.2.6",
+ tmtNum: "2.2.7",
tmtName: "Uprooted"
}
@@ -312,6 +312,7 @@ function gameLoop(diff) {
let layer = TREE_LAYERS[x][item]
if (tmp[layer].autoPrestige && tmp[layer].canReset) doReset(layer);
if (layers[layer].automate) layers[layer].automate();
+ if (layers[layer].autoUpgrade) autobuyUpgrades(layer)
}
}
@@ -320,6 +321,7 @@ function gameLoop(diff) {
let layer = OTHER_LAYERS[row][item]
if (tmp[layer].autoPrestige && tmp[layer].canReset) doReset(layer);
if (layers[layer].automate) layers[layer].automate();
+ if (layers[layer].autoUpgrade) autobuyUpgrades(layer)
}
}
@@ -330,6 +332,13 @@ function gameLoop(diff) {
}
+function autobuyUpgrades(layer){
+ if (!tmp[layer].upgrades) return
+ for (id in tmp[layer].upgrades)
+ if (layers[layer].canAfford === undefined || layers[layer].canAfford() === true)
+ buyUpg(layer, id)
+}
+
function hardReset() {
if (!confirm("Are you sure you want to do this? You will lose all your progress!")) return
player = null
diff --git a/js/technical/temp.js b/js/technical/temp.js
index c07b9de..f058ba1 100644
--- a/js/technical/temp.js
+++ b/js/technical/temp.js
@@ -13,6 +13,9 @@ for (item in noCall) {
activeFunctions.push(noCall[item])
}
+// Add the names of classes to traverse
+var traversableClasses = []
+
function setupTemp() {
tmp = {}
tmp.pointGen = {}
@@ -46,6 +49,9 @@ function setupTempData(layerData, tmpData) {
tmpData[item] = {}
setupTempData(layerData[item], tmpData[item])
}
+ else if ((!!layerData[item]) && (typeof layerData[item] === "object") && traversableClasses.includes(layerData[item].constructor.name)) {
+ tmpData[item] = new layerData[item].constructor()
+ }
else if (isFunction(layerData[item]) && !activeFunctions.includes(item)){
tmpData[item] = new Decimal(1) // The safest thing to put probably?
} else {
@@ -87,7 +93,7 @@ function updateTempData(layerData, tmpData) {
if (Array.isArray(layerData[item])) {
updateTempData(layerData[item], tmpData[item])
}
- else if ((!!layerData[item]) && (layerData[item].constructor === Object)) {
+ else if ((!!layerData[item]) && (layerData[item].constructor === Object) || (typeof layerData[item] === "object") && traversableClasses.includes(layerData[item].constructor.name)){
updateTempData(layerData[item], tmpData[item])
}
else if (isFunction(layerData[item]) && !activeFunctions.includes(item)){
diff --git a/js/utils.js b/js/utils.js
index 382f87b..ed3915c 100644
--- a/js/utils.js
+++ b/js/utils.js
@@ -1,6 +1,6 @@
// ************ Number formatting ************
-function exponentialFormat(num, precision) {
+function exponentialFormat(num, precision, mantissa = true) {
let e = num.log10().floor()
let m = num.div(Decimal.pow(10, e))
if(m.toStringWithDecimalPlaces(precision) == 10) {
@@ -8,13 +8,15 @@ function exponentialFormat(num, precision) {
e = e.add(1)
}
e = (e.gte(10000) ? commaFormat(e, 0) : e.toStringWithDecimalPlaces(0))
- return m.toStringWithDecimalPlaces(precision)+"e"+e
-}
+ if (mantissa)
+ return m.toStringWithDecimalPlaces(precision)+"e"+e
+ else return "e"+e
+ }
function commaFormat(num, precision) {
if (num === null || num === undefined) return "NaN"
if (num.mag < 0.001) return (0).toFixed(precision)
- return num.toStringWithDecimalPlaces(precision).replace(/\B(?=(\d{3})+(?!\d))/g, ",")
+ return num.toStringWithDecimalPlaces(precision).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")
}
@@ -34,7 +36,7 @@ function sumValues(x) {
return x.reduce((a, b) => Decimal.add(a, b))
}
-function format(decimal, precision=2) {
+function format(decimal, precision=2,) {
decimal = new Decimal(decimal)
if (isNaN(decimal.sign)||isNaN(decimal.layer)||isNaN(decimal.mag)) {
player.hasNaN = true;
@@ -46,7 +48,9 @@ function format(decimal, precision=2) {
var slog = decimal.slog()
if (slog.gte(1e6)) return "F" + format(slog.floor())
else return Decimal.pow(10, slog.sub(slog.floor())).toStringWithDecimalPlaces(3) + "F" + commaFormat(slog.floor(), 0)
- } else if (decimal.gte("1e1000")) return exponentialFormat(decimal, 0)
+ }
+ else if (decimal.gte("1e100000")) return exponentialFormat(decimal, 0, false)
+ else if (decimal.gte("1e1000")) return exponentialFormat(decimal, 0)
else if (decimal.gte(1e9)) return exponentialFormat(decimal, precision)
else if (decimal.gte(1e3)) return commaFormat(decimal, 0)
else return regularFormat(decimal, precision)
@@ -224,8 +228,8 @@ function fixData(defaultData, newData) {
else
newData[item] = new Decimal(newData[item])
}
- else if ((!!defaultData[item]) && (defaultData[item].constructor === Object)) {
- if (newData[item] === undefined || (defaultData[item].constructor !== Object))
+ else if ((!!defaultData[item]) && (typeof defaultData[item] === "object")) {
+ if (newData[item] === undefined || (typeof defaultData[item] !== "object"))
newData[item] = defaultData[item]
else
fixData(defaultData[item], newData[item])