fix renderable multidoku max coords
All checks were successful
Linux arm64 / Build (push) Successful in 29s

This commit is contained in:
2025-02-02 00:37:07 +01:00
parent 70eef1646d
commit 1e67e7a9d4

View File

@@ -90,29 +90,23 @@ public class RenderableMultidoku {
}
private static Coordinate getMaxSudokuCoordinate(Map<Sudoku, Coordinate> sudokusOffset) {
Coordinate maxCoordinate = null;
Sudoku maxSudoku = null;
float maxDistanceSquared = 0;
int maxX = 0;
int maxY = 0;
Sudoku lastSudoku = null;
for (var entry : sudokusOffset.entrySet()) {
Coordinate coordinate = entry.getValue();
float distanceSquared = coordinate.getX() * coordinate.getX() + coordinate.getY() * coordinate.getY();
if (maxCoordinate == null) {
maxCoordinate = coordinate;
maxDistanceSquared = distanceSquared;
maxSudoku = entry.getKey();
}
if (distanceSquared > maxDistanceSquared) {
maxDistanceSquared = distanceSquared;
maxSudoku = entry.getKey();
maxCoordinate = coordinate;
}
if (coordinate.getX() > maxX)
maxX = coordinate.getX();
if (coordinate.getY() > maxY)
maxY = coordinate.getY();
lastSudoku = entry.getKey();
}
int blockWidth = maxSudoku.getBlockWidth();
int blockHeight = maxSudoku.getSize() / blockWidth;
Coordinate maxCoordinate = new Coordinate(maxX, maxY);
// tous les sudokus sont censés faire la même taille
int sudokuSize = lastSudoku.getSize();
return new Coordinate(maxCoordinate.getX() + maxSudoku.getSize(), maxCoordinate.getY() + maxSudoku.getSize());
return new Coordinate(maxCoordinate.getX() + sudokuSize, maxCoordinate.getY() + sudokuSize);
}
public static RenderableMultidoku fromMultidoku(MultiDoku doku) {