import java.util.*; import javax.swing.ImageIcon; public class Knight extends Piece { static int[] xDir = {-1, -2, -2, -1, 1, 2, 2, 1}; static int[] yDir = {-2, -1, 1, 2, 2, 1, -1, -2}; public Knight(int x, int y, String color) { super(x, y, color, new ImageIcon("sprites/" + color + "/knight.png").getImage()); } public Piece copy() { Piece newP = new Knight(this.pos.x, this.pos.y, this.color); return newP; } public ArrayList getPseudoLegalMoves(Board board) { ArrayList positions = new ArrayList(); for (int i = 0; i < xDir.length; i++) { Position test = new Position(pos.x + xDir[i], pos.y + yDir[i]); if (!Board.inBounds(test)) continue; if (board.isOpen(test)) { positions.add(test); continue; } if (!board.getPiece(test).colorMatches(this)) { positions.add(test); } } return positions; } public ArrayList getLegalMoves(Board board) { return null; } }