Fixed knight move validation, renamed test

This commit is contained in:
Kai S. K. Engelbart 2019-07-12 10:07:02 +02:00
parent 6d98d9a963
commit d12b06a1ff
2 changed files with 4 additions and 4 deletions

View File

@ -17,7 +17,8 @@ public class Knight extends Piece {
@Override
public boolean isValidMove(Move move) {
return Math.abs(move.xDist - move.yDist) == 1 && (move.xDist == 1 || move.yDist == 1) && isFreePath(move);
return Math.abs(move.xDist - move.yDist) == 1
&& (move.xDist == 1 && move.yDist == 2 || move.xDist == 2 && move.yDist == 1) && checkDestination(move);
}
private void checkAndInsertMove(List<Move> moves, Position pos, int offsetX, int offsetY) {

View File

@ -12,11 +12,11 @@ import dev.kske.chess.board.Queen;
/**
* Project: <strong>Chess</strong><br>
* File: <strong>BoardCloneTest.java</strong><br>
* File: <strong>BoardTest.java</strong><br>
* Created: <strong>08.07.2019</strong><br>
* Author: <strong>Kai S. K. Engelbart</strong>
*/
class BoardCloneTest {
class BoardTest {
Board board;
@ -40,5 +40,4 @@ class BoardCloneTest {
clone.getBoardArr()[0][0] = new Queen(Color.BLACK, clone);
assertNotEquals(clone.getBoardArr()[0][0], board.getBoardArr()[0][0]);
}
}