-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
41 lines (35 loc) · 965 Bytes
/
Player.java
File metadata and controls
41 lines (35 loc) · 965 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
32
33
34
35
36
37
38
39
40
41
import java.util.ArrayList;
public class Player {
private String _side;
private String _name;
private ArrayList<Piece> _mypieces;
private ArrayList<Move> _mymoves;
public Player( String side, String name, ArrayList<Piece> pieces ){
_side = side;
_name = name;
_mypieces = pieces;
_mymoves = new ArrayList<Move>();
genMoves();
}
public void genMoves(){
_mymoves.clear();
for (int i = 0; i < _mypieces.size(); i++){
Piece temp = _mypieces.get(i);
Coordinate origin = temp.getPosition();
if (temp.hasMoves()){
for (Coordinate destination: temp.getMoves()){
_mymoves.add(new Move(origin, destination));
}
}
}
}
public static void main( String[] args ){
Board setup = new Board();
setup.toBoard();
ArrayList<Piece> hispieces = setup.getPieces("red");
Player Matthew = new Player( "red", "Matthew", hispieces);
for (Move i: Matthew._mymoves){
System.out.println(i);
}
}
}