`
});
addLayer("color", {
name: "color",
resource: "color energy",
color: "white",
startData() {
return {
points: new Decimal(0),
// vue is giving me trouble, so I had to do this...
// hope I don't need over 100 batteries (end game should have 14)
batteries: new Array(100).fill(1).reduce((acc,curr,i) => {
acc[i] = {
active: false,
progress: 0,
lastActive: 0
};
return acc;
}, {})
};
},
getResetGain() {
let { base, multi } = getRedColorEffect();
let gain = new Decimal(0.1).add(base);
let batteryGain = new Decimal(0);
for (const index in player.color.batteries) {
batteryGain = batteryGain.add(player.color.batteries[index].progress);
}
gain = gain.add(batteryGain.times(getBlueColorEffect()));
gain = gain.times(multi);
if (hasUpgrade(this.layer, 1)) {
gain = gain.times(5);
}
if (hasUpgrade(this.layer, 5)) {
gain = gain.times(upgradeEffect(this.layer, 5));
}
gain = gain.times(buyableEffect("color", 3));
if (hasYellowEffect(5)) {
gain = gain.times(getBlueColorEffect()).max(1);
}
gain = gain.pow(buyableEffect("color", 55));
return gain;
},
update(diff) {
for (const index in player.color.batteries) {
const battery = player.color.batteries[index];
let gain = new Decimal(diff);
if (battery.active || (index % 2 === 1 && hasCyanEffect(4)) || (index % 2 === 0 && hasCyanEffect(5))) {
gain = gain.div(10);
gain = gain.times(buyableEffect("color", 13));
battery.lastActive = 0;
} else if (hasCyanEffect(2) && battery.lastActive >= 0 && battery.lastActive < getTotalSecondaryLight().div(4)) {
gain = gain.div(10);
gain = gain.times(buyableEffect("color", 13));
battery.lastActive = battery.lastActive + diff;
} else {
gain = gain.times(-1).div(20);
gain = gain.div(buyableEffect("color", 13));
battery.lastActive = -1;
}
battery.progress = new Decimal(battery.progress).add(gain).clamp(0, 1).toNumber();
}
},
automate() {
if (hasCyanEffect(1)) {
for (id in tmp[this.layer].upgrades) {
if (isPlainObject(tmp[this.layer].upgrades[id]) && (layers[this.layer].upgrades[id].canAfford === undefined || layers[this.layer].upgrades[id].canAfford() === true)) {
buyUpg(this.layer, id);
}
}
if (hasCyanEffect(3)) {
for (id in layers[this.layer].buyables) {
/*
if (layers[this.layer].buyables[id].buyMax) {
layers[this.layer].buyables[id].buyMax();
}
*/
if (isPlainObject(tmp[this.layer].buyables[id]) && (layers[this.layer].buyables[id].canAfford === undefined || layers[this.layer].buyables[id].canAfford() === true)) {
buyBuyable(this.layer, id);
}
}
}
}
},
passiveGeneration: new Decimal(1),
tabFormat: () => [
["tree-tab-challenge", 1],
"blank",
["display-text", `You have
${format(player.color.points)}
color energy`],
"blank",
["display-text", `You are collecting ${format(tmp.color.getResetGain)} color energy per second`],
"blank",
["row", [["upgrade", 1], ["upgrade", 5], ["upgrade", 21]]],
["row", [["upgrade", 2], ["upgrade", 8], ["upgrade", 34]]],
"blank",
["row", [["buyable", 3], ["buyable", 13], ["buyable", 55]]],
["row", [["buyMax", 3], ["buyMax", 13], ["buyMax", 55]]],
"blank",
["row", new Array(getNumBatteries().times(2).max(1).sub(1).toNumber()).fill(1).map((_, i) => i % 2 === 0 ? ["column", [
["charger", { index: i, color: getCurrentColor(.5) }],
"blank",
["display-text", `+${format(new Decimal((player.color.batteries[i] && player.color.batteries[i].progress) || 0).times(getBlueColorEffect()))}`],
["battery", i],
["blank", "34px"]
]] : "blank")]
],
buyables: {
3: {
title: "Alhazen",
display() {
return ` Rebuyable. Double color energy gain.