multidoku constraints gui
Some checks are pending
Linux arm64 / Build (push) Waiting to run

This commit is contained in:
2025-01-28 09:20:48 +01:00
parent 182f79d4b4
commit c7d3430d21
3 changed files with 22 additions and 16 deletions

View File

@@ -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;
}
}