king, copy board logic, getPseudoMoves

This commit is contained in:
CT
2026-04-24 13:34:00 -05:00
parent 984c37a833
commit c3318f834c
16 changed files with 185 additions and 120 deletions

View File

@@ -9,13 +9,16 @@ public class Knight extends Piece {
super(x, y, color, new ImageIcon("sprites/" + color + "/knight.png").getImage());
}
public ArrayList<Position> getLegalMoves(Board board) {
public Piece copy() {
Piece newP = new Knight(this.pos.x, this.pos.y, this.color);
return newP;
}
public ArrayList<Position> getPseudoLegalMoves(Board board) {
ArrayList<Position> positions = new ArrayList<Position>();
for (int i = 0; i < xDir.length; i++) {
int xPlus = xDir[i];
int yPlus = yDir[i];
Position test = new Position(pos.x + xPlus, pos.y + yPlus);
Position test = new Position(pos.x + xDir[i], pos.y + yDir[i]);
if (!Board.inBounds(test)) continue;
if (board.isOpen(test)) {
positions.add(test);
@@ -28,4 +31,8 @@ public class Knight extends Piece {
return positions;
}
public ArrayList<Position> getLegalMoves(Board board) {
return null;
}
}