Browse Source

Changed test because of bug

feature-chess
Nick Stolbov 3 years ago
parent
commit
9bbf82c4a5
  1. 4
      src/main/java/Game/ChessObj/ChessBoard.java
  2. 2
      src/main/java/Game/ChessObj/ChessFigure.java
  3. 4
      src/test/java/Game/ChessObj/ChessFigureTest.java

4
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;
}
}

2
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;

4
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;
}

Loading…
Cancel
Save