From e0f40bc559db4c59c404b4ac10eeaffcb8e567e8 Mon Sep 17 00:00:00 2001 From: Julius Dewender Date: Fri, 15 Jan 2021 17:47:03 +0100 Subject: [PATCH] figure movement test: white rook invalid step left/down --- fh.fd.ci.client/src/main/java/de/fd/fh/Figure.java | 5 +++++ fh.fd.ci.client/src/test/java/de/fd/fh/FigureTest.java | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/fh.fd.ci.client/src/main/java/de/fd/fh/Figure.java b/fh.fd.ci.client/src/main/java/de/fd/fh/Figure.java index 9aabba5..8d39fdd 100644 --- a/fh.fd.ci.client/src/main/java/de/fd/fh/Figure.java +++ b/fh.fd.ci.client/src/main/java/de/fd/fh/Figure.java @@ -26,6 +26,11 @@ public class Figure return false; } + if (src / 8 - dst / 8 < 0 && src % 8 - dst % 8 > 0) // diagonal nach rechts oben + { + return false; + } + return true; } } diff --git a/fh.fd.ci.client/src/test/java/de/fd/fh/FigureTest.java b/fh.fd.ci.client/src/test/java/de/fd/fh/FigureTest.java index 4201262..e451411 100644 --- a/fh.fd.ci.client/src/test/java/de/fd/fh/FigureTest.java +++ b/fh.fd.ci.client/src/test/java/de/fd/fh/FigureTest.java @@ -62,4 +62,11 @@ class FigureTest Figure f = new Figure(); assertFalse(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 3 + 5, new int[Figure.fieldLength * Figure.fieldLength])); } + + @Test + void whiteRookInvalidMoveLeftDown() // diagonal nach links unten + { + Figure f = new Figure(); + assertFalse(f.moveAllowed(36, 43, new int[8 * 8])); + } } \ No newline at end of file