mirror of
https://github.com/Acamaeda/The-Modding-Tree.git
synced 2024-11-25 01:41:45 +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
11
js/game.js
11
js/game.js
|
@ -246,14 +246,19 @@ function resetRow(row) {
|
||||||
|
|
||||||
function startChallenge(layer, x) {
|
function startChallenge(layer, x) {
|
||||||
let enter = false
|
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) {
|
if (player[layer].activeChallenge == x) {
|
||||||
|
// This needs to be embedded due to how 'enter' works
|
||||||
|
if(canExitChallenge(layer, x)){
|
||||||
completeChallenge(layer, x)
|
completeChallenge(layer, x)
|
||||||
Vue.set(player[layer], "activeChallenge", null)
|
Vue.set(player[layer], "activeChallenge", null)
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
enter = true
|
enter = true
|
||||||
}
|
}
|
||||||
doReset(layer, true)
|
if(enter || canExitChallenge(layer, x)) doReset(layer, true)
|
||||||
if(enter) {
|
if(enter) {
|
||||||
Vue.set(player[layer], "activeChallenge", x)
|
Vue.set(player[layer], "activeChallenge", x)
|
||||||
run(layers[layer].challenges[x].onEnter, layers[layer].challenges[x])
|
run(layers[layer].challenges[x].onEnter, layers[layer].challenges[x])
|
||||||
|
|
|
@ -22,6 +22,14 @@ function challengeCompletions(layer, id) {
|
||||||
return (player[layer].challenges[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) {
|
function getBuyableAmount(layer, id) {
|
||||||
return (player[layer].buyables[id])
|
return (player[layer].buyables[id])
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue