From 70bd7023f2b549e06d25e03b0fe367b64e50eb1e Mon Sep 17 00:00:00 2001 From: Julius Dewender Date: Thu, 14 Jan 2021 22:04:47 +0100 Subject: [PATCH] figure movement: invalid step size (>1) --- fh.fd.ci.client/src/main/java/de/fd/fh/Figure.java | 7 ++++++- fh.fd.ci.client/src/test/java/de/fd/fh/FigureTest.java | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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 2ae7a40..89083a5 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,7 +16,12 @@ public class Figure return false; } - if (dst >= Figure.fieldLength * 7 + 0) + if (dst >= Figure.fieldLength * 7 + 0) // weißer Bauer kein Schritt "runter" + { + return false; + } + + if (dst <= 32) // weißer Bauer nicht mehr als 1 Schritt nach "oben" { return false; } 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 30b993b..59287fa 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 @@ -47,4 +47,11 @@ class FigureTest Figure f = new Figure(); assertFalse(f.moveAllowed(Figure.fieldLength * 6 + 0, Figure.fieldLength * 7 + 0, new int[Figure.fieldLength * Figure.fieldLength])); } + + @Test + void whiteFarmerInvalidDestinationUp() // mehr als 1 Schritt nach "oben" + { + Figure f = new Figure(); + assertFalse(f.moveAllowed(Figure.fieldLength * 6 + 0, Figure.fieldLength * 4 + 0, new int[Figure.fieldLength * Figure.fieldLength])); + } } \ No newline at end of file