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: # 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. - Made hard resetting more effective.
- Removed Herobrine from getStartClickables. - 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. - 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. - 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 // For normal layers, gain beyond [softcap] points is put to the [softcapPower]th power
softcap: new Decimal(1e100), softcap: new Decimal(1e100),
softcapPower: new Decimal(0.5), softcapPower: new Decimal(0.5),
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)

View file

@ -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.6", num: "2.2.7",
name: "Uprooted", 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, // 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. // you can cap their current resources with this.
function fixOldSave(oldVersion){ function fixOldSave(oldVersion){
} }

View file

@ -222,6 +222,7 @@ function loadVue() {
template: ` template: `
<div style="margin-top: -13px"> <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].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> <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].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> <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 // Don't change this
const TMT_VERSION = { const TMT_VERSION = {
tmtNum: "2.2.6", tmtNum: "2.2.7",
tmtName: "Uprooted" tmtName: "Uprooted"
} }
@ -312,6 +312,7 @@ function gameLoop(diff) {
let layer = TREE_LAYERS[x][item] let layer = TREE_LAYERS[x][item]
if (tmp[layer].autoPrestige && tmp[layer].canReset) doReset(layer); if (tmp[layer].autoPrestige && tmp[layer].canReset) doReset(layer);
if (layers[layer].automate) layers[layer].automate(); 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] let layer = OTHER_LAYERS[row][item]
if (tmp[layer].autoPrestige && tmp[layer].canReset) doReset(layer); if (tmp[layer].autoPrestige && tmp[layer].canReset) doReset(layer);
if (layers[layer].automate) layers[layer].automate(); 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() { function hardReset() {
if (!confirm("Are you sure you want to do this? You will lose all your progress!")) return if (!confirm("Are you sure you want to do this? You will lose all your progress!")) return
player = null player = null

View file

@ -13,6 +13,9 @@ for (item in noCall) {
activeFunctions.push(noCall[item]) activeFunctions.push(noCall[item])
} }
// Add the names of classes to traverse
var traversableClasses = []
function setupTemp() { function setupTemp() {
tmp = {} tmp = {}
tmp.pointGen = {} tmp.pointGen = {}
@ -46,6 +49,9 @@ function setupTempData(layerData, tmpData) {
tmpData[item] = {} tmpData[item] = {}
setupTempData(layerData[item], 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)){ else if (isFunction(layerData[item]) && !activeFunctions.includes(item)){
tmpData[item] = new Decimal(1) // The safest thing to put probably? tmpData[item] = new Decimal(1) // The safest thing to put probably?
} else { } else {
@ -87,7 +93,7 @@ function updateTempData(layerData, tmpData) {
if (Array.isArray(layerData[item])) { if (Array.isArray(layerData[item])) {
updateTempData(layerData[item], tmpData[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]) updateTempData(layerData[item], tmpData[item])
} }
else if (isFunction(layerData[item]) && !activeFunctions.includes(item)){ else if (isFunction(layerData[item]) && !activeFunctions.includes(item)){

View file

@ -1,6 +1,6 @@
// ************ Number formatting ************ // ************ Number formatting ************
function exponentialFormat(num, precision) { function exponentialFormat(num, precision, mantissa = true) {
let e = num.log10().floor() let e = num.log10().floor()
let m = num.div(Decimal.pow(10, e)) let m = num.div(Decimal.pow(10, e))
if(m.toStringWithDecimalPlaces(precision) == 10) { if(m.toStringWithDecimalPlaces(precision) == 10) {
@ -8,13 +8,15 @@ function exponentialFormat(num, precision) {
e = e.add(1) e = e.add(1)
} }
e = (e.gte(10000) ? commaFormat(e, 0) : e.toStringWithDecimalPlaces(0)) 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) { function commaFormat(num, precision) {
if (num === null || num === undefined) return "NaN" if (num === null || num === undefined) return "NaN"
if (num.mag < 0.001) return (0).toFixed(precision) 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)) return x.reduce((a, b) => Decimal.add(a, b))
} }
function format(decimal, precision=2) { function format(decimal, precision=2,) {
decimal = new Decimal(decimal) decimal = new Decimal(decimal)
if (isNaN(decimal.sign)||isNaN(decimal.layer)||isNaN(decimal.mag)) { if (isNaN(decimal.sign)||isNaN(decimal.layer)||isNaN(decimal.mag)) {
player.hasNaN = true; player.hasNaN = true;
@ -46,7 +48,9 @@ function format(decimal, precision=2) {
var slog = decimal.slog() var slog = decimal.slog()
if (slog.gte(1e6)) return "F" + format(slog.floor()) 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 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(1e9)) return exponentialFormat(decimal, precision)
else if (decimal.gte(1e3)) return commaFormat(decimal, 0) else if (decimal.gte(1e3)) return commaFormat(decimal, 0)
else return regularFormat(decimal, precision) else return regularFormat(decimal, precision)
@ -224,8 +228,8 @@ function fixData(defaultData, newData) {
else else
newData[item] = new Decimal(newData[item]) newData[item] = new Decimal(newData[item])
} }
else if ((!!defaultData[item]) && (defaultData[item].constructor === Object)) { else if ((!!defaultData[item]) && (typeof defaultData[item] === "object")) {
if (newData[item] === undefined || (defaultData[item].constructor !== Object)) if (newData[item] === undefined || (typeof defaultData[item] !== "object"))
newData[item] = defaultData[item] newData[item] = defaultData[item]
else else
fixData(defaultData[item], newData[item]) fixData(defaultData[item], newData[item])