diff --git a/src/main/java/Game/ChessObj/ChessBoard.java b/src/main/java/Game/ChessObj/ChessBoard.java index 8477a4b..f7f0f3b 100644 --- a/src/main/java/Game/ChessObj/ChessBoard.java +++ b/src/main/java/Game/ChessObj/ChessBoard.java @@ -92,6 +92,8 @@ public class ChessBoard { sourceY += stepY; if (!isCellInBoard(sourceX, sourceY) || !isCellInBoard(destX, destY)) return false; + if(Math.abs(deltaX) <= 1 && Math.abs(deltaY) <= 1) + return true; while (!(sourceX == destX && sourceY == destY)) { if (board[sourceY][sourceX] != null) return false; @@ -119,7 +121,7 @@ public class ChessBoard { return this.board; } - protected void setChessBoard(ChessFigure[][] board) { + public void setChessBoard(ChessFigure[][] board) { this.board = board; } } diff --git a/src/main/java/Game/ChessObj/ChessFigure.java b/src/main/java/Game/ChessObj/ChessFigure.java index 878c66e..0b06f00 100644 --- a/src/main/java/Game/ChessObj/ChessFigure.java +++ b/src/main/java/Game/ChessObj/ChessFigure.java @@ -86,7 +86,7 @@ public class ChessFigure { return true; break; case PAWN: - if (dx == 0) + if (dx != 0) return false; if (getTeam() == Team.WHITE && (dy == 1)) return true; diff --git a/src/test/java/Game/ChessObj/ChessFigureTest.java b/src/test/java/Game/ChessObj/ChessFigureTest.java index 8e5235a..1542ef4 100644 --- a/src/test/java/Game/ChessObj/ChessFigureTest.java +++ b/src/test/java/Game/ChessObj/ChessFigureTest.java @@ -92,11 +92,11 @@ class ChessFigureTest { } break; case PAWN: - if (figure.getTeam() == ChessFigure.Team.WHITE && (y == 1) && x != 0) { + if (figure.getTeam() == ChessFigure.Team.WHITE && (y == 1) && x == 0) { assertTrue(figure.isRelativeMoveValid(x, y)); continue; } - if (figure.getTeam() == ChessFigure.Team.BLACK && (y == -1) && x != 0) { + if (figure.getTeam() == ChessFigure.Team.BLACK && (y == -1) && x == 0) { assertTrue(figure.isRelativeMoveValid(x, y)); continue; }