Browse Source

Fixed bug for Queen with negative values

Nick Stolbov 3 years ago
parent
commit
e234eb2e50
  1. 2
      src/main/java/Game/ChessObj/ChessFigure.java
  2. 2
      src/test/java/Game/ChessObj/ChessFigureTest.java

2
src/main/java/Game/ChessObj/ChessFigure.java

@ -70,7 +70,7 @@ public class ChessFigure {
return true;
break;
case QUEEN:
if ((dx == dy) || (dx == 0 ^ dy == 0))
if ((Math.abs(dx) == Math.abs(dy)) || (dx == 0 ^ dy == 0))
return true;
break;
case CASTLE:

2
src/test/java/Game/ChessObj/ChessFigureTest.java

@ -68,7 +68,7 @@ class ChessFigureTest {
}
break;
case QUEEN:
if ((x == y) || (x == 0 ^ y == 0)) {
if (Math.abs(x) == Math.abs(y) || (x == 0 ^ y == 0)) {
assertTrue(figure.isRelativeMoveValid(x, y));
continue;
}

Loading…
Cancel
Save