-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathPlayer.java
89 lines (70 loc) · 1.61 KB
/
Player.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
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
78
79
80
81
82
83
84
85
86
87
88
89
import java.util.Arrays;
public class Player {
public static final int EASY = 3, MEDIUM = 4, HARD = 5;
private Card[] cards;
private Board board;
private int color;
private boolean isComputer;
private int difficulty;
public Player(Card[] moves, int playerColor, int difficulty) {
this(moves, playerColor);
isComputer = true;
this.difficulty = difficulty;
}
public Player(Card[] moves, int playerColor) {
cards = moves;
color = playerColor;
difficulty = 0;
isComputer = false;
}
public Player(Player p) {
cards = Arrays.copyOf(p.getCards(),2);
board = p.getBoard();
color = p.getColor();
isComputer = p.isComputer();
difficulty = p.getDifficulty();
}
public int getDifficulty() {
return difficulty;
}
public void setDifficulty(int n) {
difficulty = n;
}
public boolean isComputer() {
return isComputer;
}
public void setBoard(Board b) {
if(board == null)
board = b;
else
board = new Board(b);
}
public Board getBoard() {
return board;
}
public void setCard(int index, Card card) {
cards[index] = new Card(card);
}
public Coordinate [] getMove() {
if(isComputer)
return getMax();
return null;
}
public Coordinate [] getMax() {
return new Coordinate[] {new Coordinate(0,0), new Coordinate(0,0)};
}
public Card[] getCards() {
return cards;
}
public int getColor() {
return color;
}
public String toString() {
return getColorString()+"\nCards: "+cards[0]+", "+cards[1]+"\nIs Computer: "+isComputer+"\nDifficulty: "+difficulty;
}
public String getColorString() {
String col = "Blue";
if(color == Board.red) col = "Red";
return col;
}
}