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

feat: chal.canEnter(), chal.canExit()

This commit is contained in:
Braeden 2024-10-27 18:22:34 -04:00
parent 6749edf080
commit e4bf4f63af
2 changed files with 19 additions and 6 deletions

View file

@ -246,14 +246,19 @@ function resetRow(row) {
function startChallenge(layer, x) {
let enter = false
if (!player[layer].unlocked || !tmp[layer].challenges[x].unlocked) return
if (!player[layer].unlocked || !tmp[layer].challenges[x].unlocked || !canEnterChallenge(layer, x)) return
if (player[layer].activeChallenge == x) {
completeChallenge(layer, x)
Vue.set(player[layer], "activeChallenge", null)
} else {
// This needs to be embedded due to how 'enter' works
if(canExitChallenge(layer, x)){
completeChallenge(layer, x)
Vue.set(player[layer], "activeChallenge", null)
}
}
else {
enter = true
}
doReset(layer, true)
}
if(enter || canExitChallenge(layer, x)) doReset(layer, true)
if(enter) {
Vue.set(player[layer], "activeChallenge", x)
run(layers[layer].challenges[x].onEnter, layers[layer].challenges[x])

View file

@ -22,6 +22,14 @@ function challengeCompletions(layer, id) {
return (player[layer].challenges[id])
}
function canEnterChallenge(layer, id){
return tmp[layer].challenges[id].canEnter ?? true
}
function canExitChallenge(layer, id){
return tmp[layer].challenges[id].canExit ?? true
}
function getBuyableAmount(layer, id) {
return (player[layer].buyables[id])
}