1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-21 16:13:55 +00:00

2.2.7 stuff

This commit is contained in:
Acamaeda 2020-11-30 21:58:42 -05:00
parent acd6d2c4d3
commit 0168e11f7f
8 changed files with 40 additions and 14 deletions

View file

@ -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.

View file

@ -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.

View file

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

View file

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

View file

@ -222,6 +222,7 @@ function loadVue() {
template: `
<div style="margin-top: -13px">
<span v-if="tmp[layer].type=='normal' && tmp[layer].resetGain.lt(100) && player[layer].points.lt(1e3)"><br>You have {{formatWhole(tmp[layer].baseAmount)}} {{tmp[layer].baseResource}}</span>
<span v-if="tmp[layer].passiveGeneration"><br>You are gaining {{formatWhole(tmp[layer].resetGain.times(tmp[layer].passiveGeneration))}} {{tmp[layer].resource}} per second</span>
<br><br>
<span v-if="tmp[layer].showBest">Your best {{tmp[layer].resource}} is {{formatWhole(player[layer].best)}}<br></span>
<span v-if="tmp[layer].showTotal">You have made a total of {{formatWhole(player[layer].total)}} {{tmp[layer].resource}}<br></span>

View file

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

View file

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

View file

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