Browse Source

figure movement test: white rook invalid step left/up

feat-figureMovement
JD 4 years ago
parent
commit
f961d1639c
  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

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

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

@ -84,4 +84,11 @@ class FigureTest
Figure f = new Figure();
assertTrue(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 7 + 4, new int[Figure.fieldLength * Figure.fieldLength]));
}
@Test
void whiteRookInvalidMoveLeftUp() // diagonal nach links oben
{
Figure f = new Figure();
assertFalse(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 3 + 3, new int[Figure.fieldLength * Figure.fieldLength]));
}
}
Loading…
Cancel
Save