it finnaly works, need to check board getPiece(x,y) instead of
selectedXY because only 1 case is concerned, knight an king soon ok
This commit is contained in:
parent
759930016b
commit
6787c0eae2
|
|
@ -228,15 +228,11 @@ public class Move {
|
|||
public boolean isKnightMoveValid(int x, int y, boolean color, int selectX, int selectY) {
|
||||
|
||||
|
||||
if (selectX == x + 1 && selectY == y + 2) {
|
||||
if (selectX == x + 1 && selectY == y + 2) { // check one of the 8 possible cases
|
||||
|
||||
if(board.getPiece(selectX + 1, selectY + 2) != null) {
|
||||
|
||||
if(color != board.getPiece(selectX+ 1, selectY + 2).isWhite()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
if(board.getPiece(x, y) != null) { // check at the exact tox and ToY coordinates if there is a piece
|
||||
return color != board.getPiece(x, y).isWhite(); // no need for additional if statement compared to previous move methods, its a comparator in between the color of the played piece and the color of the piece at the destination, if different, it will return true (possibility to eat the piecebc ishighlighted will be true) , if the same it will return false
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue