-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChessPiece.java
More file actions
77 lines (64 loc) · 2.59 KB
/
ChessPiece.java
File metadata and controls
77 lines (64 loc) · 2.59 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package chessprj;
/**********************************************************************
* Data Structure for chess pieces
**********************************************************************/
public abstract class ChessPiece implements IChessPiece {
/** instance variables */
private Player owner;
private int strategicValue;
protected static ChessModel model;
boolean firstMove = true;
/**********************************************************************
* Constructor for ChessPiece
*
* @param player
* @param model
**********************************************************************/
protected ChessPiece(Player player, ChessModel model) {
this.owner = player;
this.model = model;
}
/**********************************************************************
* @return current player
**********************************************************************/
public Player player() {
return owner;
}
/**********************************************************************
* Getter for strategic value
*
* @return IChessPiece
**********************************************************************/
public IChessPiece copy(){
return this;
}//end copy
/**********************************************************************
* Setter for strategic value
*
* @param s
**********************************************************************/
public void setStrategicValue(int s) {
strategicValue = s;
}
/**********************************************************************
* Getter for strategic value
*
* @return strategic value
**********************************************************************/
public int strategicValue(){
return this.strategicValue;
}
/**********************************************************************
* Checks if move stays in confines of board
*
* @return true if in board, else false
**********************************************************************/
protected boolean isInBoard(Move move){
if(move.toRow < 0 || move.toRow > 7 || move.toColumn < 0 || move.toColumn > 7) return false;
return true;
}
// abstracted due to the uniqueness of this method for each piece
public abstract String type();
// abstracted due to the uniqueness of this method for each piece
public abstract boolean isValidMove(Move move, IChessPiece[][] board);
}