diff --git a/js/game.js b/js/game.js
index 43d5fdd..e446e02 100644
--- a/js/game.js
+++ b/js/game.js
@@ -36,6 +36,14 @@ function getPointGen() {
return gain
}
+// Function to determine if the player is in a challenge
+function inChallenge(layer, id){
+ if (player.c.active==x) return true
+
+ if (layers[layer].challs[id].countsAs)
+ return layers[layer].challs[id].countsAs.includes(id)
+}
+
function save() {
localStorage.setItem("prestige-tree", btoa(JSON.stringify(player)))
}
@@ -263,7 +271,6 @@ function layerUnl(layer) {
function rowReset(row, layer) {
for (lr in ROW_LAYERS[row]){
- console.log(lr)
if(layers[lr].doReset)
layers[lr].doReset(layer)
else
@@ -412,13 +419,36 @@ function startChall(layer, x) {
updateChallTemp(layer)
}
+function canCompleteChall(layer, x)
+{
+ if (x != player[layer].active) return
+
+ let chall = layers[layer].challs[x]
+
+ if (chall.currencyInternalName){
+ let name = chall.currencyInternalName
+ if (chall.currencyLayer){
+ let lr = chall.currencyLayer
+ return !(player[lr][name].lt(chall.goal))
+ }
+ else {
+ return !(player[name].lt(chall.cost))
+ }
+ }
+ else {
+ return !(player[layer].points.lt(chall.cost))
+ }
+
+}
+
function completeChall(layer, x) {
var x = player[layer].active
if (!x) return
- if (!player.points.gte(layers[layer].challs[x].goal)) return
+ if (! canCompleteChall(layer, x)) return
if (!player[layer].challs.includes(x)) {
- //if (layer == "h" && x == 62) needCanvasUpdate = true
+ needCanvasUpdate = true
player[layer].challs.push(x);
+ if (layers[layer].challs[x].onComplete) layers[layer].challs[x].onComplete()
}
delete player[layer].active
updateChallTemp(layer)
diff --git a/js/layers.js b/js/layers.js
index 81a2c72..d7c660e 100644
--- a/js/layers.js
+++ b/js/layers.js
@@ -7,6 +7,7 @@ var layers = {
total: new Decimal(0),
upgrades: [],
milestones: [],
+ challs: [],
beep: false,
}},
color: "#4BEC13",
@@ -81,6 +82,28 @@ var layers = {
}
},
},
+
+ challs: {
+ rows: 1,
+ cols: 1,
+ 11: {
+ name: "Fun",
+ desc: "Makes the game 0% harder",
+ unl() { return player.c.best.gt(0) },
+ goal: new Decimal("20"),
+ currencyDisplayName: "lollipops", // Use if using a nonstandard currency
+ currencyInternalName: "points", // Use if using a nonstandard currency
+ currencyLayer: "c", // Leave empty if not in a layer
+ effect() {
+ let ret = player.c.points.add(1).tetrate(0.02)
+ return ret;
+ },
+ effDisp(x) { return format(x)+"x" },
+ countsAs: [12, 21], // Use this for if a challenge includes the effects of other challenges. Being in this challenge "counts as" being in these.
+ reward: "Says hi",
+ onComplete() {console.log("hiii")} // Called when you complete the challenge
+ },
+ },
doReset(layer){
if(layers[layer].row > layers["c"].row) fullLayerReset('c') // This is actually the default behavior
},