From 54f0424d7a3471e43b2e343bba5a3ef4b36765f5 Mon Sep 17 00:00:00 2001 From: Julius Dewender Date: Thu, 14 Jan 2021 22:20:17 +0100 Subject: [PATCH] figure movement test: white farmer invalid var2 --- 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, 10 insertions(+), 2 deletions(-) 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 5a410d5..00d4e1a 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,12 +16,13 @@ public class Figure return false; } - if (dst >= Figure.fieldLength * 7 + 0) // weißer Bauer kein Schritt "runter" + int stepSize = src / fieldLength - dst / fieldLength; + + if (stepSize <= 0) // weißer Bauer kein Schritt "runter" { return false; } - int stepSize = src / fieldLength - dst / fieldLength; if (stepSize > 1) // 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 5ac89c6..8c040ec 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(); assertTrue(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 3 + 4, new int[Figure.fieldLength * Figure.fieldLength])); } + + @Test + void whiteFarmerInvalidDestinationDownVar2() // Bauer (w) steht in der Mitte vom Feld und geht 1 nach unten + { + Figure f = new Figure(); + assertFalse(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 5 + 4, new int[Figure.fieldLength * Figure.fieldLength])); + } } \ No newline at end of file