(final Cell affectedCell)
| 445 | } |
| 446 | |
| 447 | private void updateForClearCell(final Cell affectedCell) { |
| 448 | longRangeUpdate(affectedCell, (piece) -> { |
| 449 | moves.get(piece.position).remove(Move.get(piece, affectedCell, true)); |
| 450 | guards.get(piece.position).remove(Move.get(piece, affectedCell, false)); |
| 451 | moves.get(piece.position).add(Move.get(piece, affectedCell, false)); |
| 452 | }, |
| 453 | (m, position) -> moves.get(position).add(m), |
| 454 | (m, position) -> guards.get(position).add(m)); |
| 455 | for (final int[] coordinate : Knight.diff) { |
| 456 | final int row = affectedCell.row + coordinate[0]; |
| 457 | final int col = affectedCell.col + coordinate[1]; |
| 458 | if (Utils.withinBoardLimits(row, col)) { |
| 459 | if (!isEmpty(row, col)) { |
| 460 | final Piece knight = getPiece(row, col); |
| 461 | if (knight.sameType(PieceType.KNIGHT)) { |
| 462 | if (moves.get(knight.position) != null) { |
| 463 | moves.get(knight.position).remove(Move.get(knight, affectedCell, true)); |
| 464 | guards.get(knight.position).remove(Move.get(knight, affectedCell, false)); |
| 465 | moves.get(knight.position).add(Move.get(knight, affectedCell, false)); |
| 466 | } |
| 467 | } |
| 468 | } |
| 469 | } |
| 470 | } |
| 471 | for (int i = -2; i <= 2; i++) { |
| 472 | for (int j = -1; j <= 1; j++) { |
| 473 | if (i != 0 || j != 0) { |
| 474 | final int row = affectedCell.row + i; |
| 475 | final int col = affectedCell.col + j; |
| 476 | if (Utils.withinBoardLimits(row, col)) { |
| 477 | if (!isEmpty(row, col)) { |
| 478 | final Piece pawn = getPiece(row, col); |
| 479 | if (pawn.sameType(PieceType.PAWN) && (pawn.color.equals(Color.BLACK) ? i > 0 : i < 0)) { |
| 480 | removeMoves(pawn.position); |
| 481 | } |
| 482 | } |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | private void longRangeUpdate(final Cell affectedCell, |
| 490 | final Consumer<Piece> initialOperation, |
no test coverage detected