From 82aa161806384da6783ade80ed43519d9645bd95 Mon Sep 17 00:00:00 2001 From: Nick Stolbov Date: Mon, 31 Jan 2022 11:39:27 +0100 Subject: [PATCH] Changed Bishop relative move because of a bug(negative coords didnt get validated) --- src/main/java/Game/ChessObj/ChessFigure.java | 2 +- src/test/java/Game/ChessObj/ChessFigureTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/Game/ChessObj/ChessFigure.java b/src/main/java/Game/ChessObj/ChessFigure.java index 0b06f00..029b233 100644 --- a/src/main/java/Game/ChessObj/ChessFigure.java +++ b/src/main/java/Game/ChessObj/ChessFigure.java @@ -78,7 +78,7 @@ public class ChessFigure { return true; break; case BISHOP: - if (dx == dy) + if (Math.abs(dx) == Math.abs(dy)) return true; break; case KNIGHT: diff --git a/src/test/java/Game/ChessObj/ChessFigureTest.java b/src/test/java/Game/ChessObj/ChessFigureTest.java index 1542ef4..2232596 100644 --- a/src/test/java/Game/ChessObj/ChessFigureTest.java +++ b/src/test/java/Game/ChessObj/ChessFigureTest.java @@ -80,7 +80,7 @@ class ChessFigureTest { } break; case BISHOP: - if (x == y) { + if (Math.abs(x) == Math.abs(y)) { assertTrue(figure.isRelativeMoveValid(x, y)); continue; }