Movement restriction for Knight

main
Kyle Kim 2 years ago
parent 45f7544151
commit 6f51247019

@ -5,10 +5,16 @@ public class Knight extends Piece {
super(black);
}
@Override
public ArrayList<BoardCoordinate> getPossibleMoves(BoardCoordinate position) {
ArrayList<BoardCoordinate> possibleMoves = new ArrayList<>();
possibleMoves.add(new BoardCoordinate(position.x, position.y - 1)); // to up
possibleMoves.add(new BoardCoordinate(position.x - 2, position.y - 1));
possibleMoves.add(new BoardCoordinate(position.x - 1, position.y - 2));
possibleMoves.add(new BoardCoordinate(position.x + 1, position.y - 2));
possibleMoves.add(new BoardCoordinate(position.x + 2, position.y - 1));
possibleMoves.add(new BoardCoordinate(position.x + 2, position.y + 1));
possibleMoves.add(new BoardCoordinate(position.x + 1, position.y + 2));
possibleMoves.add(new BoardCoordinate(position.x - 1, position.y + 2));
possibleMoves.add(new BoardCoordinate(position.x - 2, position.y + 1));
return possibleMoves;
}
}