fix: serialize

This commit is contained in:
2025-01-30 00:51:22 +01:00
committed by Melvyn
parent f1d963e546
commit c4becf2d55
11 changed files with 212 additions and 415 deletions

View File

@@ -27,10 +27,6 @@ public class RenderableMultidoku {
this.doku = doku;
}
public boolean isResolved() {
return this.doku.isSolved();
}
public int getWidth() {
return width;
}
@@ -51,21 +47,7 @@ public class RenderableMultidoku {
return cells.get(index);
}
public boolean setCellValue(Cell cell, int value) {
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;
}
private static record PositionConstraint(Sudoku sudoku1, Sudoku sudoku2, Coordinate offset) {
}

View File

@@ -76,8 +76,8 @@ public class SudokuRenderer {
}
} else {
if (ImGui.button(Integer.toString(i + 1), cellSize)) {
this.doku.setCellValue(currentCell, i);
if (this.doku.isResolved())
currentCell.trySetValue(i);
if (this.doku.getDoku().isSolved())
this.onResolve.emit();
ImGui.closeCurrentPopup();
}