This commit is contained in:
@@ -48,18 +48,17 @@ public class RenderableMultidoku {
|
||||
}
|
||||
|
||||
public boolean setCellValue(Cell cell, int value) {
|
||||
// TODO: fix constraints
|
||||
// for (Sudoku s : doku.getSubGrids()) {
|
||||
// int cellIndex = s.getCells().indexOf(cell);
|
||||
// // la cellule existe
|
||||
// if (cellIndex != -1) {
|
||||
// int cellX = cellIndex % s.getSize();
|
||||
// int cellY = cellIndex / s.getSize();
|
||||
// if (s.canBePlaced(cellX, cellY, value)) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
for (Sudoku s : doku.getSubGrids()) {
|
||||
int cellIndex = s.getCells().indexOf(cell);
|
||||
// la cellule existe
|
||||
if (cellIndex != -1) {
|
||||
int cellX = cellIndex % s.getSize();
|
||||
int cellY = cellIndex / s.getSize();
|
||||
if (!s.canBePlaced(cellX, cellY, value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
cell.setSymbolIndex(value);
|
||||
return true;
|
||||
}
|
||||
@@ -100,7 +99,8 @@ public class RenderableMultidoku {
|
||||
for (Coordinate coordinate : sudokusOffset.values()) {
|
||||
if (minCoordinate == null)
|
||||
minCoordinate = coordinate;
|
||||
minCoordinate = new Coordinate(Math.min(minCoordinate.getX(), coordinate.getX()), Math.min(minCoordinate.getY(), coordinate.getY()));
|
||||
minCoordinate = new Coordinate(Math.min(minCoordinate.getX(), coordinate.getX()),
|
||||
Math.min(minCoordinate.getY(), coordinate.getY()));
|
||||
}
|
||||
return minCoordinate;
|
||||
}
|
||||
@@ -134,7 +134,8 @@ public class RenderableMultidoku {
|
||||
public static RenderableMultidoku fromMultidoku(MultiDoku doku) {
|
||||
if (doku.getNbSubGrids() == 1) {
|
||||
Sudoku sudoku = doku.getSubGrid(0);
|
||||
return new RenderableMultidoku(doku, sudoku.getBlocks(), sudoku.getCells(), sudoku.getSize(), sudoku.getSize());
|
||||
return new RenderableMultidoku(doku, sudoku.getBlocks(), sudoku.getCells(), sudoku.getSize(),
|
||||
sudoku.getSize());
|
||||
}
|
||||
Map<Sudoku, Coordinate> sudokusOffset = new HashMap<>();
|
||||
// coordinates in cell
|
||||
@@ -203,4 +204,8 @@ public class RenderableMultidoku {
|
||||
return new RenderableMultidoku(doku, blocks, cells, maxCoordinate.getX(), maxCoordinate.getY());
|
||||
}
|
||||
|
||||
public MultiDoku getDoku() {
|
||||
return doku;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user