CCCPaste

Chess Function canBeCaptured

   private static int[][] q = new int[][]{{1, 1, 'P', 'b'}, {-1, 1, 'P'}, {1, -1, 'p'}, {-1, -1, 'p'}};
   private static int[][] o = new int[][]{{0, 1, '.', 'r'}, {0, -1, '.'}, {1, 0, '.'}, {-1, 0, '.'}};
   private static int[][][] all = {q, o};

    public static boolean canBeCaptured(int x, int y, char[][] board) {

        char color = color(board[y][x]);
        for (int[][] q_o : all) {
            for (int[] dir : q_o) {
                for (int i = 1; i < 8; i++) {
                    char square = get(x + i * dir[0], y + i * dir[1], board);
                    if (square == ' ') {
                        continue;
                    }
                    if (color(square) == color|| square=='x') {
                        break;
                    }
                    if (sameLtr(square, 'q') || sameLtr(square, (char) q_o[0][3]) || (i == 1 && (square == dir[2] || sameLtr(square, 'k')))) {
                        return true;
                    }
                    break;
                }
            }
        }
for (int[] dir : q) {
            for (int[] n : new int[][]{{2, 1}, {1, 2}}) {
                char square = get(x + n[0] * dir[0], y + n[1] * dir[1], board);
                if (sameLtr(square, 'n') && color(square) != color) {
                    return true;
                }
            }
        }
        return false;
    }