king, copy board logic, getPseudoMoves
This commit is contained in:
15
Knight.java
15
Knight.java
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user