1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2025-05-13 05:11:10 +00:00

More features and customization for Challenges

This commit is contained in:
Acamaeda 2020-09-27 18:01:36 -04:00
parent 906ece54ab
commit 029f5546c0
3 changed files with 60 additions and 7 deletions

View file

@ -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)

View file

@ -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
},