package project.chess; import java.awt.*; import java.util.ArrayList; import static project.ui.Display.loadImage; public class Knight extends ChessPiece { private Image whiteKnight = loadImage("./resources/chess_piece_2_black_knight.png"); private Image blackKnight = loadImage("./resources/chess_piece_2_white_knight.png"); public Knight(Board b, boolean isWhite, int x, int y) { super(b,isWhite,x,y); } public Image getImage(){ if (isWhite) return whiteKnight; return blackKnight; } @Override public ArrayList getMoves() { ArrayList moves = new ArrayList(); moves.add(new Move(x + 2, y + 1)); moves.add(new Move(x + 2, y - 1)); moves.add(new Move(x - 2, y + 1)); moves.add(new Move(x - 2, y - 1)); moves.add(new Move(x - 1, y - 2)); moves.add(new Move(x + 1, y - 2)); moves.add(new Move(x - 1, y + 2)); moves.add(new Move(x + 1, y + 2)); return moves; } public Knight clone () { return new Knight(this.b,this.isWhite,this.x,this.y); } }