-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlayer.java
119 lines (99 loc) · 2.63 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package monopoly;
import java.awt.Color;
import java.util.ArrayList;
import javax.swing.JOptionPane;
public class Player extends GamePiece{
private String name;
private Color color;
private int playerNumber;
private int spaceNumber;
private boolean jail;
private int jailCountdown;
public Player(int number, int x, int y, int width, int height, String name, ArrayList<Color> colorsLeft){
super(number, x, y, width, height);
this.name = name;
jail = false;
jailCountdown = 0;
spaceNumber = 0;
String[] colors = new String[colorsLeft.size()];
playerNumber = number;
for(int i = 0; i < colorsLeft.size(); i++){
if(colorsLeft.get(i) == Color.RED){
colors[i] = "Red";
}else if(colorsLeft.get(i) == Color.ORANGE){
colors[i] = "Orange";
}else if(colorsLeft.get(i) == Color.YELLOW){
colors[i] = "Yellow";
}else if(colorsLeft.get(i) == Color.GREEN){
colors[i] = "Green";
}else if(colorsLeft.get(i) == Color.BLUE){
colors[i] = "Blue";
}else if(colorsLeft.get(i) == Color.CYAN){
colors[i] = "Cyan";
}else if(colorsLeft.get(i) == Color.MAGENTA){
colors[i] = "Magenta";
}else if(colorsLeft.get(i) == Color.PINK){
colors[i] = "Pink";
}
}
String c = (String) JOptionPane.showInputDialog(null, "What color would you like to be?", "Player Color", JOptionPane.QUESTION_MESSAGE, null, colors, colors[0]);
if(c.equals("Red")){
colorsLeft.remove(Color.RED);
color = Color.RED;
}else if(c.equals("Orange")){
colorsLeft.remove(Color.ORANGE);
color = Color.ORANGE;
}else if(c.equals("Yellow")){
colorsLeft.remove(Color.YELLOW);
color = Color.YELLOW;
}else if(c.equals("Green")){
colorsLeft.remove(Color.GREEN);
color = Color.GREEN;
}else if(c.equals("Blue")){
colorsLeft.remove(Color.BLUE);
color = Color.BLUE;
}else if(c.equals("Cyan")){
colorsLeft.remove(Color.CYAN);
color = Color.CYAN;
}else if(c.equals("Magenta")){
colorsLeft.remove(Color.MAGENTA);
color = Color.MAGENTA;
}else if(c.equals("Pink")){
colorsLeft.remove(Color.PINK);
color = Color.PINK;
}
}
public Color getColor() {
return color;
}
public String getName(){
return name;
}
public int getPlayerNumber(){
return playerNumber;
}
public void changeSpaceNumber(int x) {
spaceNumber = x;
}
public int getSpaceNumber() {
return spaceNumber;
}
public boolean checkIfInJail() {
if(jail = true){
jailCountdown--;
}
return jail;
}
public void changeJail() {
if(jail == true){
jail = false;
jailCountdown = 0;
}else{
jail = true;
jailCountdown = 3;
}
}
public int getJailCountdown() {
return jailCountdown;
}
}