Teleportation cells remains teleportation cells after the snake leave them
This commit is contained in:
parent
f9aa6a469b
commit
42c8da4578
@ -212,9 +212,11 @@ async function startGame(gameID) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Teleportation
|
// Teleportation
|
||||||
|
const teleportationCells = []
|
||||||
if(level.hasOwnProperty("teleportation"))
|
if(level.hasOwnProperty("teleportation"))
|
||||||
level.teleportation.forEach((f) => {
|
level.teleportation.forEach((f) => {
|
||||||
map[f[0]-1][f[1]-1] = TELEPORTATION
|
map[f[0]-1][f[1]-1] = TELEPORTATION
|
||||||
|
teleportationCells.push(JSON.stringify([f[0]-1,f[1]-1]));
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -297,6 +299,10 @@ async function startGame(gameID) {
|
|||||||
if(!increaseSize) {
|
if(!increaseSize) {
|
||||||
const oldPos = snake.shift()
|
const oldPos = snake.shift()
|
||||||
map[oldPos[0]][oldPos[1]] = map[oldPos[0]][oldPos[1]] == ICE_SNAKE ? ICE : EMPTY
|
map[oldPos[0]][oldPos[1]] = map[oldPos[0]][oldPos[1]] == ICE_SNAKE ? ICE : EMPTY
|
||||||
|
|
||||||
|
// If the cell was a teleportation cell, then revert it back to the right state
|
||||||
|
if(teleportationCells.includes(JSON.stringify(oldPos)))
|
||||||
|
map[oldPos[0]][oldPos[1]] = TELEPORTATION
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the user has won
|
// Check if the user has won
|
||||||
|
Loading…
Reference in New Issue
Block a user