From d12b06a1ffa689f4c76bc89a713be493efce52af Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Fri, 12 Jul 2019 10:07:02 +0200 Subject: [PATCH] Fixed knight move validation, renamed test --- src/dev/kske/chess/board/Knight.java | 3 ++- .../kske/chess/test/{BoardCloneTest.java => BoardTest.java} | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/dev/kske/chess/test/{BoardCloneTest.java => BoardTest.java} (88%) diff --git a/src/dev/kske/chess/board/Knight.java b/src/dev/kske/chess/board/Knight.java index 15d4d78..b225e14 100644 --- a/src/dev/kske/chess/board/Knight.java +++ b/src/dev/kske/chess/board/Knight.java @@ -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 moves, Position pos, int offsetX, int offsetY) { diff --git a/src/dev/kske/chess/test/BoardCloneTest.java b/src/dev/kske/chess/test/BoardTest.java similarity index 88% rename from src/dev/kske/chess/test/BoardCloneTest.java rename to src/dev/kske/chess/test/BoardTest.java index 5c7df20..415d3a4 100644 --- a/src/dev/kske/chess/test/BoardCloneTest.java +++ b/src/dev/kske/chess/test/BoardTest.java @@ -12,11 +12,11 @@ import dev.kske.chess.board.Queen; /** * Project: Chess
- * File: BoardCloneTest.java
+ * File: BoardTest.java
* Created: 08.07.2019
* Author: Kai S. K. Engelbart */ -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]); } - }