From f961d1639c2ad499da2bed30b6f040ffc33293d2 Mon Sep 17 00:00:00 2001 From: Julius Dewender Date: Fri, 15 Jan 2021 17:19:16 +0100 Subject: [PATCH] figure movement test: white rook invalid step left/up --- 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 d592c94..acb0778 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 @@ -16,6 +16,11 @@ public class Figure return false; } + if ((src - dst) / fieldLength > 0 && (src - dst) % fieldLength > 0) // diagonal nach links 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 da24316..7320505 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 @@ -84,4 +84,11 @@ class FigureTest Figure f = new Figure(); assertTrue(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 7 + 4, new int[Figure.fieldLength * Figure.fieldLength])); } + + @Test + void whiteRookInvalidMoveLeftUp() // diagonal nach links oben + { + Figure f = new Figure(); + assertFalse(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 3 + 3, new int[Figure.fieldLength * Figure.fieldLength])); + } } \ No newline at end of file