1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-28 02:51:55 +00:00

Used decimalZero and decimalOne more

This commit is contained in:
Harley White 2021-05-10 20:19:29 -04:00
parent b5591197a6
commit c681f1a4dc
5 changed files with 20 additions and 20 deletions

View file

@ -18,14 +18,14 @@ function getResetGain(layer, useType = null) {
}
if(tmp[layer].type == "none")
return new Decimal (0)
if (tmp[layer].gainExp.eq(0)) return new Decimal(0)
if (tmp[layer].gainExp.eq(0)) return decimalZero
if (type=="static") {
if ((!tmp[layer].canBuyMax) || tmp[layer].baseAmount.lt(tmp[layer].requires)) return new Decimal(1)
if ((!tmp[layer].canBuyMax) || tmp[layer].baseAmount.lt(tmp[layer].requires)) return decimalOne
let gain = tmp[layer].baseAmount.div(tmp[layer].requires).div(tmp[layer].gainMult).max(1).log(tmp[layer].base).times(tmp[layer].gainExp).pow(Decimal.pow(tmp[layer].exponent, -1))
gain = gain.times(tmp[layer].directMult)
return gain.floor().sub(player[layer].points).add(1).max(1);
} else if (type=="normal"){
if (tmp[layer].baseAmount.lt(tmp[layer].requires)) return new Decimal(0)
if (tmp[layer].baseAmount.lt(tmp[layer].requires)) return decimalZero
let gain = tmp[layer].baseAmount.div(tmp[layer].requires).pow(tmp[layer].exponent).times(tmp[layer].gainMult).pow(tmp[layer].gainExp)
if (gain.gte(tmp[layer].softcap)) gain = gain.pow(tmp[layer].softcapPower).times(tmp[layer].softcap.pow(decimalOne.sub(tmp[layer].softcapPower)))
gain = gain.times(tmp[layer].directMult)
@ -33,7 +33,7 @@ function getResetGain(layer, useType = null) {
} else if (type=="custom"){
return layers[layer].getResetGain()
} else {
return new Decimal(0)
return decimalZero
}
}
@ -68,7 +68,7 @@ function getNextAt(layer, canMax=false, useType = null) {
} else if (type=="custom"){
return layers[layer].getNextAt(canMax)
} else {
return new Decimal(0)
return decimalZero
}}
function softcap(value, cap, power = 0.5) {
@ -167,7 +167,7 @@ function layerDataReset(layer, keep = []) {
function resetBuyables(layer){
if (layers[layer].buyables)
player[layer].buyables = getStartBuyables(layer)
player[layer].spentOnBuyables = new Decimal(0)
player[layer].spentOnBuyables = decimalZero
}
@ -215,7 +215,7 @@ function doReset(layer, force=false) {
}
}
tmp[layer].baseAmount = new Decimal(0) // quick fix
tmp[layer].baseAmount = decimalZero // quick fix
}
if (tmp[layer].resetsNothing) return
@ -226,7 +226,7 @@ function doReset(layer, force=false) {
}
prevOnReset = {...player} //Deep Copy
player.points = (row == 0 ? new Decimal(0) : getStartPoints())
player.points = (row == 0 ? decimalZero : getStartPoints())
for (let x = row; x >= 0; x--) rowReset(x, layer)
rowReset("side", layer)

View file

@ -165,9 +165,9 @@ function setupLayer(layer){
if(!layers[layer].componentStyles) layers[layer].componentStyles = {}
if(layers[layer].symbol === undefined) layers[layer].symbol = layer.charAt(0).toUpperCase() + layer.slice(1)
if(layers[layer].unlockOrder === undefined) layers[layer].unlockOrder = []
if(layers[layer].gainMult === undefined) layers[layer].gainMult = new Decimal(1)
if(layers[layer].gainExp === undefined) layers[layer].gainExp = new Decimal(1)
if(layers[layer].directMult === undefined) layers[layer].directMult = new Decimal(1)
if(layers[layer].gainMult === undefined) layers[layer].gainMult = decimalOne
if(layers[layer].gainExp === undefined) layers[layer].gainExp = decimalOne
if(layers[layer].directMult === undefined) layers[layer].directMult = decimalOne
if(layers[layer].type === undefined) layers[layer].type = "none"
if(layers[layer].base === undefined || layers[layer].base <= 1) layers[layer].base = 2
if(layers[layer].softcap === undefined) layers[layer].softcap = new Decimal("e1e7")

View file

@ -42,8 +42,8 @@ function setupTemp() {
}
tmp.other = {
lastPoints: player.points || new Decimal(0),
oomps: new Decimal(0),
lastPoints: player.points || decimalZero,
oomps: decimalZero,
}
updateWidth()
@ -74,7 +74,7 @@ function setupTempData(layerData, tmpData, funcsData) {
}
else if (isFunction(layerData[item]) && !activeFunctions.includes(item)){
funcsData[item] = layerData[item]
tmpData[item] = new Decimal(1) // The safest thing to put probably?
tmpData[item] = decimalOne // The safest thing to put probably?
} else {
tmpData[item] = layerData[item]
}

View file

@ -3,7 +3,7 @@ function exponentialFormat(num, precision, mantissa = true) {
let e = num.log10().floor()
let m = num.div(Decimal.pow(10, e))
if (m.toStringWithDecimalPlaces(precision) == 10) {
m = new Decimal(1)
m = decimalOne
e = e.add(1)
}
e = (e.gte(1e9) ? format(e, 1) : (e.gte(10000) ? commaFormat(e, 0) : e.toStringWithDecimalPlaces(0)))
@ -32,7 +32,7 @@ function fixValue(x, y = 0) {
function sumValues(x) {
x = Object.values(x)
if (!x[0]) return new Decimal(0)
if (!x[0]) return decimalZero
return x.reduce((a, b) => Decimal.add(a, b))
}

View file

@ -66,9 +66,9 @@ function getStartLayerData(layer) {
if (layerdata.unlocked === undefined)
layerdata.unlocked = true;
if (layerdata.total === undefined)
layerdata.total = new Decimal(0);
layerdata.total = decimalZero;
if (layerdata.best === undefined)
layerdata.best = new Decimal(0);
layerdata.best = decimalZero;
if (layerdata.resetTime === undefined)
layerdata.resetTime = 0;
if (layerdata.forceTooltip === undefined)
@ -78,7 +78,7 @@ function getStartLayerData(layer) {
if (layerdata.noRespecConfirm === undefined) layerdata.noRespecConfirm = false
if (layerdata.clickables == undefined)
layerdata.clickables = getStartClickables(layer);
layerdata.spentOnBuyables = new Decimal(0);
layerdata.spentOnBuyables = decimalZero;
layerdata.upgrades = [];
layerdata.milestones = [];
layerdata.lastMilestone = null;
@ -91,7 +91,7 @@ function getStartBuyables(layer) {
if (layers[layer].buyables) {
for (id in layers[layer].buyables)
if (isPlainObject(layers[layer].buyables[id]))
data[id] = new Decimal(0);
data[id] = decimalZero;
}
return data;
}