Fix wrong highlight positions by correcting board index calculation

Quicksave
Justin 2025-06-19 20:24:38 +02:00
parent 441d4a3343
commit 3b3cc2dd0b
1 changed files with 4 additions and 4 deletions

View File

@ -30,10 +30,10 @@ public class ChessEngine {
Square fromSq = Square.valueOf(from.toUpperCase());
for (Move move : board.legalMoves()) {
if (move.getFrom().equals(fromSq)) {
int fromRow = 8 - fromSq.getRank().ordinal();
int fromCol = fromSq.getFile().ordinal();
int toRow = 8 - move.getTo().getRank().ordinal();
int toCol = move.getTo().getFile().ordinal();
int fromRow = 8 - fromSq.getRank().ordinal() - 1;
int fromCol = fromSq.getFile().ordinal();
int toRow = 8 - move.getTo().getRank().ordinal() - 1;
int toCol = move.getTo().getFile().ordinal();;
destinations.add(new MoveDTO(fromRow, fromCol, toRow, toCol));
}
}