-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQueen.java
More file actions
62 lines (53 loc) · 2.22 KB
/
Queen.java
File metadata and controls
62 lines (53 loc) · 2.22 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package chessprj;
/**********************************************************************
* Houses information about the Queen chess piece
**********************************************************************/
public class Queen extends ChessPiece {
/**********************************************************************
* Constructor for queen piece
*
* @param player
* @param model
**********************************************************************/
public Queen(Player player, ChessModel model) {
super(player, model);
setStrategicValue(9);
}
/**********************************************************************
* @return piece type
**********************************************************************/
public String type() {
return "Queen";
}
/**********************************************************************
* set first move
*
* @param first
**********************************************************************/
public void setFirstMove(boolean first){
firstMove = first;
}//end setFirstMove
/**********************************************************************
* copies piece
**********************************************************************/
@Override
public IChessPiece copy(){
Queen copy = new Queen(player(), model);
copy.setFirstMove(firstMove);
return copy;
}
/**********************************************************************
* checks if a proposed move is valid
*
* @param move
* @param board
* @return true if move valid, else false
**********************************************************************/
public boolean isValidMove(Move move, IChessPiece[][] board) {
// makes sure the move is within the confines of the board
if(!isInBoard(move)) return false;
Bishop move1 = new Bishop(board[move.fromRow][move.fromColumn].player(),model);
Rook move2 = new Rook(board[move.fromRow][move.fromColumn].player(),model);
return (move1.isValidMove(move, board) || move2.isValidMove(move, board));
}
}