-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueen.java
More file actions
31 lines (28 loc) · 901 Bytes
/
Queen.java
File metadata and controls
31 lines (28 loc) · 901 Bytes
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
public class Queen extends Piece{
public Queen(int x, int y, Player owner) {
super(x, y, owner);
}
@Override
public boolean isMoveAuthorized(Board board, Coordinates destination) {
/* if (board.sameDiagonalNothingBetween(this.position,destination)&& board.isEmptyCell(destination) && board.sameColumnNothingBetween(this.position,destination)&&board.sameRowNothingBetween(this.position,destination)){
return true;
}
return false;*/
int dx = destination.getX();
int dy = destination.getY();
int ox = this.getX();
int oy = this.getY();
if (dx == ox || dy == oy){
return true;
}
return Math.abs(dx - ox) == Math.abs(dy - oy);
}
@Override
public Type getType() {
return Type.QUEEN;
}
@Override
public int getValue() {
return 9;
}
}