(final Move move)
| 537 | } |
| 538 | |
| 539 | private void updateForBlockedCell(final Move move) { |
| 540 | final Cell affectedCell = move.target; |
| 541 | longRangeUpdate(affectedCell, (piece) -> { |
| 542 | moves.get(piece.position).remove(Move.get(piece, affectedCell, true)); |
| 543 | moves.get(piece.position).remove(Move.get(piece, affectedCell, false)); |
| 544 | guards.get(piece.position).remove(Move.get(piece, affectedCell, false)); |
| 545 | if (move.piece.color.equals(piece.color)) { |
| 546 | guards.get(piece.position).add(Move.get(piece, affectedCell, false)); |
| 547 | } else { |
| 548 | moves.get(piece.position).add(Move.get(piece, affectedCell, true)); |
| 549 | } |
| 550 | }, |
| 551 | (m, position) -> moves.get(position).remove(m), |
| 552 | (m, position) -> guards.get(position).remove(m)); |
| 553 | for (final int[] coordinate : Knight.diff) { |
| 554 | final int row = affectedCell.row + coordinate[0]; |
| 555 | final int col = affectedCell.col + coordinate[1]; |
| 556 | if (Utils.withinBoardLimits(row, col)) { |
| 557 | if (!isEmpty(row, col)) { |
| 558 | final Piece knight = getPiece(row, col); |
| 559 | if (knight.sameType(PieceType.KNIGHT)) { |
| 560 | if (moves.get(knight.position) != null) { |
| 561 | moves.get(knight.position).remove(Move.get(knight, affectedCell, true)); |
| 562 | moves.get(knight.position).remove(Move.get(knight, affectedCell, false)); |
| 563 | guards.get(knight.position).remove(Move.get(knight, affectedCell, false)); |
| 564 | if (move.piece.color.equals(knight.color)) { |
| 565 | guards.get(knight.position).add(Move.get(knight, affectedCell, false)); |
| 566 | } else { |
| 567 | moves.get(knight.position).add(Move.get(knight, affectedCell, true)); |
| 568 | } |
| 569 | } |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | } |
| 574 | removeMoves(affectedCell); |
| 575 | for (int i = -2; i <= 2; i++) { |
| 576 | for (int j = -1; j <= 1; j++) { |
| 577 | if ((i != 0 || j != 0) && (Math.abs(i) + Math.abs(j) <= 2)) { |
| 578 | final int row = affectedCell.row + i; |
| 579 | final int col = affectedCell.col + j; |
| 580 | if (Utils.withinBoardLimits(row, col)) { |
| 581 | if (!isEmpty(row, col)) { |
| 582 | final Piece pawn = getPiece(row, col); |
| 583 | if (pawn.sameType(PieceType.PAWN) && (pawn.color == Color.BLACK ? i > 0 : i < 0)) { |
| 584 | removeMoves(pawn.position); |
| 585 | } |
| 586 | } |
| 587 | } |
| 588 | } |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | private void removeUnusedEnpassant() { |
| 594 | if (!moveList.isEmpty()) { |
no test coverage detected