Browse Source

Changed Bishop relative move because of a bug(negative coords didnt get validated)

feature-chess
Nick Stolbov 3 years ago
parent
commit
82aa161806
  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

@ -78,7 +78,7 @@ public class ChessFigure {
return true; return true;
break; break;
case BISHOP: case BISHOP:
if (dx == dy)
if (Math.abs(dx) == Math.abs(dy))
return true; return true;
break; break;
case KNIGHT: case KNIGHT:

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

@ -80,7 +80,7 @@ class ChessFigureTest {
} }
break; break;
case BISHOP: case BISHOP:
if (x == y) {
if (Math.abs(x) == Math.abs(y)) {
assertTrue(figure.isRelativeMoveValid(x, y)); assertTrue(figure.isRelativeMoveValid(x, y));
continue; continue;
} }

Loading…
Cancel
Save