-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer.java
More file actions
129 lines (107 loc) · 3.11 KB
/
Copy pathPlayer.java
File metadata and controls
129 lines (107 loc) · 3.11 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
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
120
121
122
123
124
125
126
127
128
129
import java.util.ArrayList;
/**
* A class that represents a player containing their name and player they choose
*
* @Team MAGA
* @Author Gajun Young - 16440714
* @Author Royal Thomas - 16326926
* @Author Richard Otroshchenko - 16353416
*/
public class Player {
private String name; //Name of player
private int choice; //player's choice
private Token token;
private String imagePath; //tokens image
private ArrayList<Card> cards = new ArrayList<>(); //Cards that a player has
private NoteBook note; //A players notebook
private Boolean alive = true; // Ensure that a player that made a bad accusation doesn't play again.
//Constructor
public Player(String name, int choice) {
this.name = name;
this.choice = choice;
this.token = null;
this.note = null;
}
//Accessor of player name
public String getName() {
return name;
}
//Returns the player's choice
public int getChoice() {
return choice;
}
//Sets the player's token
public void setToken(Token token) {
this.token = token;
}
//Return the player's token
public Token getToken() {
return token;
}
//Sets the path of the token image
public void setImagePath(String path) {
this.imagePath = path;
}
//Returns the tokens image
public String getImagePath() {
return imagePath;
}
//Returns true if matching token
public boolean hasName(String name) {
return this.name.toLowerCase().equals(name.toLowerCase().trim());
}
//Returns true if matching choice
public boolean hasChoice(int choice) {
return !(this.choice == choice);
}
//Checks if two tokens are on the same tile
public boolean hasTile(Tile tile) {
return this.token.getPosition().equals(tile);
}
//Gives a card to the player
public void giveCard(Card card) {
this.cards.add(card);
}
//Getter for cards of a player
public ArrayList<Card> getCards() {
return cards;
}
//Boolean check if player has a card
public Boolean hasCard(String y) {
for (Card x : cards) {
if (x.toString().equalsIgnoreCase(y)) {
return true;
}
}
return false;
}
//Returns card, see if user has that same exact card
public Card getCard(String name) {
for(Card x: cards) {
if(x.toString().replaceAll("\\s+","").equalsIgnoreCase(name)) {
return x;
}
}
return null;
}
//Sets notebook
public void setNoteBook(ArrayList<Card> undealt) {
this.note = new NoteBook(undealt, cards);
}
//Get notebook
public NoteBook getNoteBook() {
return note;
}
//Displays player's note
public void displayNote() {
note.showNotes();
}
//Kills the player if he/she makes a wrong accusation
public void killPlayer() {
alive = false;
}
//Checks if player is alive
public Boolean isAlive() {
return alive;
}
}