1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-21 16:13:55 +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

@ -150,13 +150,13 @@
<div v-if="layers[layer].challs" class="upgTable">
<div v-for="row in layers[layer].challs.rows" class="upgRow">
<div v-for="col in layers[layer].challs.cols">
<div v-if="layers[layer].challs[row*10+col].unl()" v-bind:class="{hChall: true, done: player[layer].challs.includes(row*10+col), canComplete: (player.points.gte(layers[layer].challs[row*10+col].goal)&&tmp.challActive[layer][row*10+col]&&!player[layer].challs.includes(row*10+col))}">
<div v-if="layers[layer].challs[row*10+col].unl()" v-bind:class="{hChall: true, done: player[layer].challs.includes(row*10+col), canComplete: tmp.challActive[layer][row*10+col]&&!player[layer].challs.includes(row*10+col)&&canCompleteChall(layer, row*10+col)}">
<br><h3>{{layers[layer].challs[row*10+col].name}}</h3><br><br>
<button v-bind:class="{ longUpg: true, can: true, [layer]: true }" v-on:click="startChall(layer, row*10+col)">{{player[layer].active==(row*10+col)?(player.points.gte(layers[layer].challs[row*10+col].goal)?"Finish":"Exit Early"):(player[layer].challs.includes(row*10+col)?"Completed":"Start")}}</button><br><br>
<button v-bind:class="{ longUpg: true, can: true, [layer]: true }" v-bind:style="{'background-color': layers[layer].color}" v-on:click="startChall(layer, row*10+col)">{{player[layer].active==(row*10+col)?(canCompleteChall(layer, row*10+col)?"Finish":"Exit Early"):(player[layer].challs.includes(row*10+col)?"Completed":"Start")}}</button><br><br>
{{layers[layer].challs[row*10+col].desc}}<br>
Goal: {{format(layers[layer].challs[row*10+col].goal)}} Points<br>
Goal: {{format(layers[layer].challs[row*10+col].goal)}} {{layers[layer].challs[row*10+col].currencyDisplayName ? layers[layer].challs[row*10+col].currencyDisplayName : "points"}}<br>
Reward: {{layers[layer].challs[row*10+col].reward}}<br>
<span v-if="layers[layer].challs[row*10+col].effDisp!==undefined">Currently: {{layers[layer].challs[row*10+col].effDisp(layers[layer].challs[row*10+col].effect())}}</span>
<span v-if="layers[layer].challs[row*10+col].effDisp!==undefined">Currently: {{(layers[layer].challs[row*10+col].effDisp) ? (layers[layer].challs[row*10+col].effDisp(layers[layer].challs[row*10+col].effect())) : format(layers[layer].challs[row*10+col].effect())}}</span>
</div>
</div>
</div>

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