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 00d4e1a..265338f 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,18 +16,13 @@ public class Figure return false; } - int stepSize = src / fieldLength - dst / fieldLength; + int stepSize = src / fieldLength - dst / fieldLength; // hoch/runter if (stepSize <= 0) // weißer Bauer kein Schritt "runter" { return false; } - if (stepSize > 1) // weißer Bauer nicht mehr als 1 Schritt nach "oben" - { - return false; - } - return true; } } diff --git a/fh.fd.ci.client/src/main/java/de/fd/fh/FigureFarmer.java b/fh.fd.ci.client/src/main/java/de/fd/fh/FigureFarmer.java index 45830f3..ddddd9a 100644 --- a/fh.fd.ci.client/src/main/java/de/fd/fh/FigureFarmer.java +++ b/fh.fd.ci.client/src/main/java/de/fd/fh/FigureFarmer.java @@ -5,6 +5,13 @@ public class FigureFarmer extends Figure @Override public boolean moveAllowed(int src, int dst, int[] field) { + int stepSize = src / fieldLength - dst / fieldLength; // hoch/runter + + if (stepSize > 1) // weißer Bauer nicht mehr als 1 Schritt nach "oben" + { + return false; + } + return super.moveAllowed(src, dst, field); } } 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 2be91bb..28b74b0 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 @@ -69,4 +69,12 @@ class FigureTest Figure f = new FigureFarmer(); assertFalse(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 5 + 4, new int[Figure.fieldLength * Figure.fieldLength])); } + + // weißer Turm + @Test + void whiteRookValidMoveUp() + { + Figure f = new Figure(); + assertTrue(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 0 + 4, new int[Figure.fieldLength * Figure.fieldLength])); + } } \ No newline at end of file