Movement restriction for Knight
This commit is contained in:
parent
45f7544151
commit
6f51247019
1 changed files with 8 additions and 2 deletions
|
@ -5,10 +5,16 @@ public class Knight extends Piece {
|
||||||
super(black);
|
super(black);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ArrayList<BoardCoordinate> getPossibleMoves(BoardCoordinate position) {
|
public ArrayList<BoardCoordinate> getPossibleMoves(BoardCoordinate position) {
|
||||||
ArrayList<BoardCoordinate> possibleMoves = new ArrayList<>();
|
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;
|
return possibleMoves;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue