28 lines
638 B
Java
28 lines
638 B
Java
package laboratoire4;
|
|
|
|
public class Pusher extends Pawn {
|
|
public Pusher(Player player, int row, int col) {
|
|
super(player, row, col);
|
|
}
|
|
|
|
@Override
|
|
public boolean isMoveValid(Pawn[][] board, PawnMovement movement) {
|
|
Pawn to = board[row + direction][col + movement.getMove()];
|
|
|
|
if (to == null) {
|
|
return true;
|
|
}
|
|
|
|
return to.player != this.player && movement != PawnMovement.STRAIGHT;
|
|
}
|
|
|
|
@Override
|
|
public String toString() {
|
|
return "Pusher{" +
|
|
player +
|
|
", " + col +
|
|
", " + row +
|
|
"} ";
|
|
}
|
|
}
|