just_another_tree/js/data/integrals.js

171 lines
8.1 KiB
JavaScript
Raw Permalink Normal View History

addLayer("i", {
name: "integrals", // This is optional, only used in a few places, If absent it just uses the layer id.
symbol: "∫", // This appears on the layer's node. Default is the id with the first letter capitalized
position: 0, // Horizontal position within a row. By default it uses the layer id and sorts in alphabetical order
startData() { return {
unlocked: false,
2024-04-09 15:19:14 +00:00
points: new Decimal(0),
total: new Decimal(0),
incDelta: 1,
number: [1]
}},
color: "#a62222",
2024-03-24 19:50:21 +00:00
requires: Decimal.pow(2, 127.9), // Can be a function that takes requirement increases into account
resource: "integrals", // Name of prestige currency
baseResource: "points", // Name of resource prestige is based on
baseAmount() {return player.points}, // Get the current amount of baseResource
type: "normal", // normal: cost to gain currency depends on amount gained. static: cost depends on how much you already have
2024-03-19 08:23:56 +00:00
exponent: 0.1, // Prestige currency exponent
gainMult() { // Calculate the multiplier for main currency from bonuses
return new Decimal(1)
},
gainExp() { // Calculate the exponent on main currency from bonuses
return new Decimal(1)
},
row: 3, // Row the layer is in on the tree (0 is the first row)
displayRow: 1,
hotkeys: [
{key: "i", description: "I: reset for integrals", onPress(){if (canReset(this.layer)) doReset(this.layer)}},
],
2024-04-09 15:19:14 +00:00
milestones: {
0: {
requirementDescription: "1 total Integral.",
effectDescription: "Gain double Files and halve total File effect on File cost.",
done() { return player[this.layer].total.gte(1) }
},
1: {
requirementDescription: "2 total Integrals.",
effectDescription: "Start every reset with 1000 PP, 250 SPP, and 5 Files",
done() { return player[this.layer].total.gte(2) }
},
2: {
requirementDescription: "3 total Integrals.",
effectDescription: "Unlock the Number.",
done() { return player[this.layer].total.gte(3) }
},
},
buyables: {
11: {
title: "Longer number",
effect() { return getBuyableAmount(this.layer, this.id).add(1).toNumber() },
cost() { return getBuyableAmount(this.layer, this.id).add(1).mul(2) },
display() {
return "Increase the length of your number.<br><br>Amount: " + format(getBuyableAmount(this.layer, this.id))
+ ".<br>Effect: " + format(this.effect(getBuyableAmount(this.layer, this.id))) + " digits.<br>Cost: "
+ format(this.cost(getBuyableAmount(this.layer, this.id))) + " Integrals."
},
canAfford() { return Decimal.gte(player[this.layer].points, this.cost()) },
buy() {
player[this.layer].points = player[this.layer].points.sub(this.cost())
addBuyables(this.layer, this.id, 1)
player[this.layer].number.push(0)
}
},
12: {
title: "Faster incrementing",
effect() { return getBuyableAmount(this.layer, this.id).add(1).pow(1.3).toNumber() },
cost() { return getBuyableAmount(this.layer, this.id).add(1).mul(3) },
display() {
return "Increase the speed of incrementing.<br><br>Amount: " + format(getBuyableAmount(this.layer, this.id))
+ ".<br>Effect: " + format(this.effect(getBuyableAmount(this.layer, this.id))) + "/s.<br>Cost: "
+ format(this.cost(getBuyableAmount(this.layer, this.id))) + " Integrals."
},
canAfford() { return Decimal.gte(player[this.layer].points, this.cost()) },
buy() {
player[this.layer].points = player[this.layer].points.sub(this.cost())
addBuyables(this.layer, this.id, 1)
}
},
13: {
title: "Higher base",
effect() { return getBuyableAmount(this.layer, this.id).add(2).toNumber() },
cost() { return getBuyableAmount(this.layer, this.id).add(1).mul(10) },
display() {
return "Increase the base of your number.<br><br>Amount: " + format(getBuyableAmount(this.layer, this.id))
+ "/" + format(this.purchaseLimit) + ".<br>Effect: "
+ format(this.effect(getBuyableAmount(this.layer, this.id))) + ".<br>Cost: "
+ format(this.cost(getBuyableAmount(this.layer, this.id))) + " Integrals."
},
canAfford() { return Decimal.gte(player[this.layer].points, this.cost()) },
buy() {
player[this.layer].points = player[this.layer].points.sub(this.cost())
addBuyables(this.layer, this.id, 1)
},
purchaseLimit: 34
},
},
numberEffect() {
return Math.sqrt(player[this.layer].number.reduceRight((x, y) => x * buyableEffect('i', 13) + y) + 1)
},
update(diff) {
if (isNaN(diff)) return
player[this.layer].incDelta += diff
player[this.layer].number[0] += Math.floor(player[this.layer].incDelta * buyableEffect('i', 12))
player[this.layer].incDelta %= 1/buyableEffect('i', 12)
for (let i = 0; i < player[this.layer].number.length - 1; i ++) {
player[this.layer].number[i+1] += Math.floor(player[this.layer].number[i] / buyableEffect('i', 13))
player[this.layer].number[i] %= buyableEffect('i', 13)
}
if (player[this.layer].number[player[this.layer].number.length - 1] >= buyableEffect('i', 13)) {
player[this.layer].number = new Array(buyableEffect('i', 11)).fill(buyableEffect('i', 13) - 1)
}
},
clickables: {
21: {
display() { return "Reset number buyables" },
onClick() {
if (confirm("Are you sure you want to respec? This will reset your number.")) {
if ([11, 12, 13].map(n => getBuyableAmount(this.layer, n)).reduce((a, b) => a.add(b)).eq(0)) {
player.ach.has75 = true
}
player[this.layer].points = player[this.layer].total
player[this.layer].buyables[11] = new Decimal(0)
player[this.layer].buyables[12] = new Decimal(0)
player[this.layer].buyables[13] = new Decimal(0)
}
},
canClick() { return true },
style: {
width: "60px",
minHeight: "60px"
}
}
},
tabFormat: {
main: {
content: [
"main-display",
"prestige-button",
"resource-display",
"blank",
"blank",
"milestones",
["raw-html", "More content coming your way!"]
]
},
number: {
content: [
"main-display",
"prestige-button",
"resource-display",
"blank",
"blank",
["raw-html", function() {
return `Your number is <h2 style="color: rgb(166, 34, 34); text-shadow: rgb(166, 34, 34) 0px 0px 10px;">`
+ player[this.layer].number.map(x => "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"[x]).reverse().join('')
+ `</h2><br>in base <h3 style="color: rgb(166, 34, 34); text-shadow: rgb(166, 34, 34) 0px 0px 10px;">`
+ format(buyableEffect(this.layer, 13))
+ `</h3>,<br>giving you x<h2 style="color: rgb(166, 34, 34); text-shadow: rgb(166, 34, 34) 0px 0px 10px;">`
+ format(tmp[this.layer].numberEffect)
+ `</h2> to point, PP, and SPP gen.`
}],
"blank",
["buyables", [1]]
],
unlocked() { return hasMilestone('i', 2) }
}
},
layerShown(){ return player.points.gte("1e25") || player[this.layer].unlocked },
branches: ['p', 'sp', 'f']
})