Fixed knight move validation, renamed test

This commit is contained in:
Kai S. K. Engelbart 2019-07-12 10:07:02 +02:00
parent c7bac23420
commit 0c59c7e540
Signed by: kske
GPG Key ID: 8BEB13EC5DF7EF13
2 changed files with 4 additions and 4 deletions

View File

@ -17,7 +17,8 @@ public class Knight extends Piece {
@Override @Override
public boolean isValidMove(Move move) { 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) { 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> * Project: <strong>Chess</strong><br>
* File: <strong>BoardCloneTest.java</strong><br> * File: <strong>BoardTest.java</strong><br>
* Created: <strong>08.07.2019</strong><br> * Created: <strong>08.07.2019</strong><br>
* Author: <strong>Kai S. K. Engelbart</strong> * Author: <strong>Kai S. K. Engelbart</strong>
*/ */
class BoardCloneTest { class BoardTest {
Board board; Board board;
@ -40,5 +40,4 @@ class BoardCloneTest {
clone.getBoardArr()[0][0] = new Queen(Color.BLACK, clone); clone.getBoardArr()[0][0] = new Queen(Color.BLACK, clone);
assertNotEquals(clone.getBoardArr()[0][0], board.getBoardArr()[0][0]); assertNotEquals(clone.getBoardArr()[0][0], board.getBoardArr()[0][0]);
} }
} }