Teleportation cells remains teleportation cells after the snake leave them
This commit is contained in:
		@@ -212,9 +212,11 @@ async function startGame(gameID) {
 | 
			
		||||
        })
 | 
			
		||||
    
 | 
			
		||||
    // Teleportation
 | 
			
		||||
    const teleportationCells = []
 | 
			
		||||
    if(level.hasOwnProperty("teleportation"))
 | 
			
		||||
        level.teleportation.forEach((f) => {
 | 
			
		||||
            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) {
 | 
			
		||||
                const oldPos = snake.shift()
 | 
			
		||||
                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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user