@Test /** internal (axial) coordinates should match chess notation */ public void testGetFieldByNotation() throws Exception { Hexagon hexagon = hexboard.getFieldByNotation("I8"); String notation = hexagon.getNotation(); int q = hexagon.getQ(); int r = hexagon.getR(); int[] expected = {-1, 8}; int[] actual = {q, r}; assertArrayEquals(expected, actual); assertEquals(notation, "I8"); }
/** * {@inheritDoc} * * @param positions A {@link List} of {@link Hexagon}s to check. * @return Returns true if at least one position is occupied. Returns false if no position is * occupied. */ @Override public boolean areFieldsOccupied(List<Hexagon> positions) { return getFigures() .stream() // Filter removed figures out .filter(hexagonFigure -> !hexagonFigure.isRemoved()) // Just keep the figures, that have the same position as one in our "positions" List. .filter( hexagonFigure -> { for (Hexagon position : positions) { if (hexagonFigure.getPosition().getNotation().equals(position.getNotation())) return true; } return false; }) .count() == positions.size(); }