Browse Source

figure movement: invalid step size (>1)

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

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

@ -16,7 +16,12 @@ public class Figure
return false; 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; return false;
} }

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

@ -47,4 +47,11 @@ class FigureTest
Figure f = new Figure(); Figure f = new Figure();
assertFalse(f.moveAllowed(Figure.fieldLength * 6 + 0, Figure.fieldLength * 7 + 0, new int[Figure.fieldLength * Figure.fieldLength])); 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]));
}
} }
Loading…
Cancel
Save