2022-07-28 17:39:51 +02:00
|
|
|
import CellSet;
|
|
|
|
import Grid;
|
2022-08-06 20:18:30 +02:00
|
|
|
import iter from Grid.Util;
|
2022-07-28 17:39:51 +02:00
|
|
|
import Toolbox;
|
2022-08-06 20:18:30 +02:00
|
|
|
import Mode;
|
2022-07-28 17:39:51 +02:00
|
|
|
|
|
|
|
return {
|
|
|
|
ize: colorize,
|
2022-08-06 20:18:30 +02:00
|
|
|
paint: paint,
|
|
|
|
set: set
|
2022-07-28 17:39:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
function colorize(row, column, color) {
|
|
|
|
var grid = Grid.get();
|
2022-08-06 20:15:53 +02:00
|
|
|
grid.colors[row][column] = color || Toolbox.color();
|
|
|
|
Grid.cell(row, column).className = 'color' + grid.colors[row][column];
|
2022-07-28 17:39:51 +02:00
|
|
|
grid.missing.remove(row, column);
|
|
|
|
}
|
|
|
|
|
2022-07-31 16:32:24 +02:00
|
|
|
function paint(row, column) {
|
2022-07-31 16:11:22 +02:00
|
|
|
var cellSet = CellSet.make(
|
2022-08-06 20:15:53 +02:00
|
|
|
{type: 'isochrome', row: row, column: column, grid: Grid.get().colors}
|
2022-07-31 16:11:22 +02:00
|
|
|
);
|
|
|
|
cellSet.iter(colorize);
|
2022-07-28 17:39:51 +02:00
|
|
|
}
|
2022-08-06 20:18:30 +02:00
|
|
|
|
|
|
|
function set(grid) {
|
|
|
|
if(grid != undefined) {
|
|
|
|
iter(grid, function(row, column) {
|
|
|
|
if(grid[row][column] != undefined) {
|
|
|
|
colorize(row, column, grid[row][column]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if(Grid.get().missing.isEmpty()) {
|
|
|
|
Mode.setEnabled(true, ['play', 'solve']);
|
|
|
|
} else {
|
|
|
|
Mode.set('edit');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|