Fix wrong highlight positions by correcting board index calculation
parent
441d4a3343
commit
3b3cc2dd0b
|
|
@ -30,10 +30,10 @@ public class ChessEngine {
|
||||||
Square fromSq = Square.valueOf(from.toUpperCase());
|
Square fromSq = Square.valueOf(from.toUpperCase());
|
||||||
for (Move move : board.legalMoves()) {
|
for (Move move : board.legalMoves()) {
|
||||||
if (move.getFrom().equals(fromSq)) {
|
if (move.getFrom().equals(fromSq)) {
|
||||||
int fromRow = 8 - fromSq.getRank().ordinal();
|
int fromRow = 8 - fromSq.getRank().ordinal() - 1;
|
||||||
int fromCol = fromSq.getFile().ordinal();
|
int fromCol = fromSq.getFile().ordinal();
|
||||||
int toRow = 8 - move.getTo().getRank().ordinal();
|
int toRow = 8 - move.getTo().getRank().ordinal() - 1;
|
||||||
int toCol = move.getTo().getFile().ordinal();
|
int toCol = move.getTo().getFile().ordinal();;
|
||||||
destinations.add(new MoveDTO(fromRow, fromCol, toRow, toCol));
|
destinations.add(new MoveDTO(fromRow, fromCol, toRow, toCol));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue