Browse Source

figure movement test: white rook invalid step left/down

feat-figureMovement
JD 4 years ago
parent
commit
e0f40bc559
  1. 5
      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

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

@ -26,6 +26,11 @@ public class Figure
return false; return false;
} }
if (src / 8 - dst / 8 < 0 && src % 8 - dst % 8 > 0) // diagonal nach rechts oben
{
return false;
}
return true; return true;
} }
} }

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

@ -62,4 +62,11 @@ class FigureTest
Figure f = new Figure(); Figure f = new Figure();
assertFalse(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 3 + 5, new int[Figure.fieldLength * Figure.fieldLength])); assertFalse(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 3 + 5, new int[Figure.fieldLength * Figure.fieldLength]));
} }
@Test
void whiteRookInvalidMoveLeftDown() // diagonal nach links unten
{
Figure f = new Figure();
assertFalse(f.moveAllowed(36, 43, new int[8 * 8]));
}
} }
Loading…
Cancel
Save