1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-21 16:13:55 +00:00

Added side layer reset functionality + documentation

This commit is contained in:
Acamaeda 2020-10-14 19:46:35 -04:00
parent d784a6c2e4
commit d9d2f777a7
5 changed files with 19 additions and 14 deletions

View file

@ -30,7 +30,11 @@ Key:
- color: A color associated with this layer, used in many places. (A string in hex format with a #)
- row: The row of the layer, starting at 0.
- row: The row of the layer, starting at 0. This affects where the node appears on the tree, and which resets affect the layer.
Using "side" instead of a number will cause the layer to appear off to the side as a smaller node (useful for achievements
and statistics). Side layers are not affected by resets unless you add a doReset to them.
- resource: Name of the main currency you gain by resetting on this layer.
@ -146,6 +150,7 @@ Key:
- doReset(resettingLayer): **optional**, is triggered when a layer on a row greater than or equal to this one does a reset.
The default behavior is to reset everything on the row, but only if it was triggered by a layer in a higher row.
(doReset is always called for side layers, but for these the default behavior is to reset nothing.)
If you want to keep things, determine what to keep based on the resettingLayer, milestones, and such, then call
resetLayerData(layer, keep), where layer is this layer, and keep is an array of the names of things to keep.

View file

@ -117,11 +117,11 @@ function canReset(layer)
function rowReset(row, layer) {
for (lr in ROW_LAYERS[row]){
if(layers[lr].doReset) {
player[lr].active = null // Exit challenges on any row reset on an equal or higher row
player[lr].activeChallenge = null // Exit challenges on any row reset on an equal or higher row
layers[lr].doReset(layer)
}
else
if(layers[layer].row > layers[lr].row) layerDataReset(lr)
if(layers[layer].row > layers[lr].row && row !== "side") layerDataReset(lr)
}
}
@ -208,6 +208,7 @@ function doReset(layer, force=false) {
player.points = (row == 0 ? new Decimal(0) : new Decimal(10))
for (let x = row; x >= 0; x--) rowReset(x, layer)
rowReset("side", layer)
prevOnReset = undefined
updateTemp()
@ -233,21 +234,21 @@ function resetRow(row) {
function startChallenge(layer, x) {
let enter = false
if (!player[layer].unlocked) return
if (player[layer].active == x) {
if (player[layer].activeChallenge == x) {
completeChallenge(layer, x)
delete player[layer].active
delete player[layer].activeChallenge
} else {
enter = true
}
doReset(layer, true)
if(enter) player[layer].active = x
if(enter) player[layer].activeChallenge = x
updateChallengeTemp(layer)
}
function canCompleteChallenge(layer, x)
{
if (x != player[layer].active) return
if (x != player[layer].activeChallenge) return
let challenge = layers[layer].challenges[x]
@ -268,10 +269,10 @@ function canCompleteChallenge(layer, x)
}
function completeChallenge(layer, x) {
var x = player[layer].active
var x = player[layer].activeChallenge
if (!x) return
if (! canCompleteChallenge(layer, x)){
delete player[layer].active
delete player[layer].activeChallenge
return
}
if (player[layer].challenges[x] < tmp[layer].challenges[x].completionLimit) {
@ -279,7 +280,7 @@ function completeChallenge(layer, x) {
player[layer].challenges[x] += 1
if (layers[layer].challenges[x].onComplete) layers[layer].challenges[x].onComplete()
}
delete player[layer].active
delete player[layer].activeChallenge
updateChallengeTemp(layer)
}

View file

@ -592,7 +592,6 @@ addLayer("a", {
tooltipUnlocked() { // Optional, tooltip displays when the layer is locked
return ("YEETS")
},
},
)

View file

@ -479,7 +479,7 @@ function clickClickable(layer, id) {
// Function to determine if the player is in a challenge
function inChallenge(layer, id){
let challenge = player[layer].active
let challenge = player[layer].activeChallenge
if (challenge==toNumber(id)) return true
if (layers[layer].challenges[challenge].countsAs)

View file

@ -103,9 +103,9 @@ function loadVue() {
Vue.component('challenge', {
props: ['layer', 'data'],
template: `
<div v-if="layers[layer].challenges && layers[layer].challenges[data]!== undefined && tmp[layer].challenges[data].unlocked && !(player.hideChallenges && hasChallenge(layer, [data]))" v-bind:class="{hChallenge: true, done: hasChallenge(layer, data), canComplete: player[layer].active == data&&!hasChallenge(layer, data)&&canCompleteChallenge(layer, data)}">
<div v-if="layers[layer].challenges && layers[layer].challenges[data]!== undefined && tmp[layer].challenges[data].unlocked && !(player.hideChallenges && hasChallenge(layer, [data]))" v-bind:class="{hChallenge: true, done: hasChallenge(layer, data), canComplete: player[layer].activeChallenge == data&&!hasChallenge(layer, data)&&canCompleteChallenge(layer, data)}">
<br><h3 v-html="tmp[layer].challenges[data].name"></h3><br><br>
<button v-bind:class="{ longUpg: true, can: true, [layer]: true }" v-bind:style="{'background-color': tmp[layer].color}" v-on:click="startChallenge(layer, data)">{{player[layer].active==(data)?(canCompleteChallenge(layer, data)?"Finish":"Exit Early"):(hasChallenge(layer, data)?"Completed":"Start")}}</button><br><br>
<button v-bind:class="{ longUpg: true, can: true, [layer]: true }" v-bind:style="{'background-color': tmp[layer].color}" v-on:click="startChallenge(layer, data)">{{player[layer].activeChallenge==(data)?(canCompleteChallenge(layer, data)?"Finish":"Exit Early"):(hasChallenge(layer, data)?"Completed":"Start")}}</button><br><br>
<span v-html="tmp[layer].challenges[data].challengeDescription"></span><br>
Goal: {{format(tmp[layer].challenges[data].goal)}} {{tmp[layer].challenges[data].currencyDisplayName ? tmp[layer].challenges[data].currencyDisplayName : "points"}}<br>
Reward: <span v-html="tmp[layer].challenges[data].rewardDescription"></span><br>