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:
parent
6749edf080
commit
e4bf4f63af
2 changed files with 19 additions and 6 deletions
15
js/game.js
15
js/game.js
|
@ -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])
|
||||
|
|
|
@ -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])
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue