- Should add validation so user cannot place robot or destination in a coordinate previously defined as a wall
if (cellType === 'robot') { // Check if there's a wall if (cell.isWall) { alert("Cannot place robot on a wall! Please select another position."); return; } // Clear previous robot position if (robotPos) { newGrid[robotPos.row][robotPos.col].isRobot = false; } cell.isRobot = true; setRobotPos({ row, col }); } else if (cellType === 'destination') { // Check if there's a wall if (cell.isWall) { alert("Cannot place destination on a wall! Please select another position."); return; } // Clear previous destination
if (cellType === 'robot') { // Check if there's a wall if (cell.isWall) { alert("Cannot place robot on a wall! Please select another position."); return; } // Clear previous robot position if (robotPos) { newGrid[robotPos.row][robotPos.col].isRobot = false; } cell.isRobot = true; setRobotPos({ row, col }); } else if (cellType === 'destination') { // Check if there's a wall if (cell.isWall) { alert("Cannot place destination on a wall! Please select another position."); return; } // Clear previous destination