Browse Source

figure movement test: white farmer valid var2

feat-figureMovement
JD 4 years ago
parent
commit
fb6127732c
  1. 3
      fh.fd.ci.client/src/main/java/de/fd/fh/Figure.java
  2. 8
      fh.fd.ci.client/src/test/java/de/fd/fh/FigureTest.java

3
fh.fd.ci.client/src/main/java/de/fd/fh/Figure.java

@ -21,7 +21,8 @@ public class Figure
return false; return false;
} }
if (dst <= Figure.fieldLength * 4 + 0) // weißer Bauer nicht mehr als 1 Schritt nach "oben"
int stepSize = src / fieldLength - dst / fieldLength;
if (stepSize > 1) // weißer Bauer nicht mehr als 1 Schritt nach "oben"
{ {
return false; return false;
} }

8
fh.fd.ci.client/src/test/java/de/fd/fh/FigureTest.java

@ -34,6 +34,7 @@ class FigureTest
assertFalse(f.moveAllowed(Figure.fieldLength * 6 + 0, Figure.fieldLength * 6 + 0, new int[Figure.fieldLength * Figure.fieldLength])); assertFalse(f.moveAllowed(Figure.fieldLength * 6 + 0, Figure.fieldLength * 6 + 0, new int[Figure.fieldLength * Figure.fieldLength]));
} }
// weißer Bauer
@Test @Test
void checkMoveWithValidDestination() void checkMoveWithValidDestination()
{ {
@ -54,4 +55,11 @@ class FigureTest
Figure f = new Figure(); Figure f = new Figure();
assertFalse(f.moveAllowed(Figure.fieldLength * 6 + 0, Figure.fieldLength * 4 + 0, new int[Figure.fieldLength * Figure.fieldLength])); assertFalse(f.moveAllowed(Figure.fieldLength * 6 + 0, Figure.fieldLength * 4 + 0, new int[Figure.fieldLength * Figure.fieldLength]));
} }
@Test
void checkMoveWithValidDestinationVar2() // Bauer (w) steht in der Mitte vom Feld und geht 1 nach oben
{
Figure f = new Figure();
assertTrue(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 3 + 4, new int[Figure.fieldLength * Figure.fieldLength]));
}
} }
Loading…
Cancel
Save