just_another_tree/js/levels.js

73 lines
No EOL
3.6 KiB
JavaScript

function cumulativeExponential(base, levels) {
return Decimal.add(levels, 1).pow_base(base).sub(1).div(Decimal.sub(base, 1))
}
function inverseCumulativeExponential(base, levels) {
return Decimal.sub(base, 1).mul(levels).add(1).log(base)
}
function getAlphaLevel(points = player.p.points) {
if (Decimal.eq(points, 0)) return new Decimal(0)
return inverseCumulativeExponential(1.1, Decimal.pow(points, buyableEffect('p', 13).pow(-1))).floor()
}
function getAlphaCost(points = player.p.points) {
return cumulativeExponential(1.1, getAlphaLevel(points)).pow(buyableEffect('p', 13))
}
function getAlphaEffect(points = player.p.points) {
return getAlphaLevel(points).mul(getAlphaRankEffect(points).add(1/20))
}
function getBetaLevel(points = player.p.points) {
if (Decimal.eq(points, 0)) return new Decimal(0)
return inverseCumulativeExponential(1.25, Decimal.div(Decimal.pow(points, buyableEffect('p', 13).pow(-1)), 5)).floor()
}
function getBetaCost(points = player.p.points) {
return cumulativeExponential(1.25, getBetaLevel(points)).mul(5).pow(buyableEffect('p', 13))
}
function getBetaEffect(points = player.p.points) {
return getBetaLevel(points).mul(getBetaRankEffect(points).add(1/20)).add(1).pow(hasUpgrade('f', 41) ? 1.2 : 1)
}
function getGammaLevel(points = player.p.points) {
if (Decimal.eq(points, 0)) return new Decimal(0)
return inverseCumulativeExponential(1.5, Decimal.div(Decimal.pow(points, buyableEffect('p', 13).pow(-1)), 15)).floor()
}
function getGammaCost(points = player.p.points) {
return cumulativeExponential(1.5, getGammaLevel(points)).mul(15).pow(buyableEffect('p', 13))
}
function getGammaEffect(points = player.p.points) {
return Decimal.add(points, 1).add(hasUpgrade('f', 31) ? getTotalLevel() : 0).log(Decimal.pow(50, buyableEffect('p', 12)))
.add(1).pow(getGammaLevel(points).mul(getGammaRankEffect(points).add(1/10)))
}
function getDeltaLevel(points = player.p.points) {
if (Decimal.eq(points, 0)) return new Decimal(0)
return inverseCumulativeExponential(2, Decimal.div(Decimal.pow(points, buyableEffect('p', 13).pow(-1)), 30)).floor()
}
function getDeltaCost(points = player.p.points) {
return cumulativeExponential(2, getDeltaLevel(points)).mul(30).pow(buyableEffect('p', 13))
}
function getDeltaEffect(points = player.p.points) {
return getDeltaLevel(points).mul(getDeltaRankEffect(points).add(1/5)).add(1).pow(hasUpgrade('f', 41) ? 1.2 : 1)
}
function getEpsilonLevel(points = player.p.points) {
if (Decimal.eq(points, 0)) return new Decimal(0)
return inverseCumulativeExponential(2.5, Decimal.div(Decimal.pow(points, buyableEffect('p', 13).pow(-1)), 50)).floor()
}
function getEpsilonCost(points = player.p.points) {
return cumulativeExponential(2.5, getEpsilonLevel(points)).mul(50).pow(buyableEffect('p', 13))
}
function getEpsilonEffect(points = player.p.points) {
return getEpsilonLevel(points).mul(getEpsilonRankEffect(points).add(1/10)).add(1)
}
function getZetaLevel(points = player.p.points) {
if (Decimal.eq(points, 0)) return new Decimal(0)
return inverseCumulativeExponential(3, Decimal.div(Decimal.pow(points, buyableEffect('p', 13).pow(-1)), 80)).floor()
}
function getZetaCost(points = player.p.points) {
return cumulativeExponential(3, getZetaLevel(points)).mul(80).pow(buyableEffect('p', 13))
}
function getZetaEffect(points = player.p.points) {
return getZetaLevel(points).mul(getZetaRankEffect().add(1/3)).add(1).pow(hasUpgrade('f', 41) ? 1.2 : 1)
}
function getTotalLevel() {
return getAlphaLevel().add(getBetaLevel()).add(getGammaLevel()).add(getDeltaLevel()).add(getEpsilonLevel())
.add(getZetaLevel())
}