-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pawn.java
33 lines (29 loc) · 1.04 KB
/
Pawn.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.ArrayList;
public class Pawn extends Piece {
public Pawn(int player, int xCor, int yCor) {
super(player,xCor,yCor);
setUpgradePiece("golden");
}
@Override
public String getType() {
return "pawn";
}
@Override
public ArrayList<Coordinates> getMoves(int x, int y, ArrayList<Coordinates> whitePositions, ArrayList<Coordinates> blackPositions) {
if (this.getOwner() == 0) {
ArrayList<Coordinates> moves = new ArrayList<Coordinates>();
int newX = x - 1;
moves.add(new Coordinates(newX,y));
moves = friendBlock(moves, whitePositions);
moves = nullifier(moves);
return moves;
} else {
ArrayList<Coordinates> moves = new ArrayList<Coordinates>();
int newX = x + 1;
moves.add(new Coordinates(newX,y));
moves = friendBlock(moves, blackPositions);
moves = nullifier(moves);
return moves;
}
}
}