diff --git a/pemFioi/blocklyCrane_lib-1.1.js b/pemFioi/blocklyCrane_lib-1.1.js index aacbb3fde..a2c055f66 100644 --- a/pemFioi/blocklyCrane_lib-1.1.js +++ b/pemFioi/blocklyCrane_lib-1.1.js @@ -4,6 +4,58 @@ var dustUrl = "crane/dust.png"; var spotlightUrl = "crane/spotlight.png"; +/* variant functions */ + +function swapColumns(grid, col1, col2) { + for (var row = 0; row < grid.length; row++) { + tmp = grid[row][col1]; + grid[row][col1] = grid[row][col2]; + grid[row][col2] = tmp; + } + return grid; +} +function swapRows(grid, row1, row2) { + tmp = grid[row1]; + grid[row1] = grid[row2]; + grid[row2] = tmp; + return grid; +} +function swapBricks(grid, type1, type2) { + for (var row = 0; row < grid.length; row++) { + for (var col = 0; col < grid[0].length; col++) { + var type = grid[row][col]; + if (type == type1) { + type = type2; + } else if (grid[row][col] == type2) { + type = type1; + } + grid[row][col] = type; + } + } + return grid; +} +function revertHorizontal(grid) { + var nbCols = grid[0].length; + for (var row = 0; row < grid.length; row++) { + for (var col = 0; col < nbCols / 2; col++) { + var tmp = grid[row][col]; + grid[row][col] = grid[row][nbCols - 1 - col]; + grid[row][nbCols - 1 - col] = tmp; + } + } + return grid; +} +function removeRow(grid, row) { + grid.splice(row, 1); + return grid; +} +function removeColumn(grid, column) { + for (var row = 0; row < grid.length; row++) { + grid[row].splice(column, 1); + } + return grid; +} + var getContext = function(display, infos, curLevel) { var localLanguageStrings = { fr: {