forked from SeanWalsh95/Ticket-To-Ride
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.java
63 lines (59 loc) · 1.77 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
import java.util.*;
import java.awt.*;
/**
* Write a description of class Player here.
*
* @author group 3
* @version 0.1
*/
public class Player {
protected String name = "";
protected int id = 0;
protected int drawCount = 2;
protected Color color = Color.BLACK;
protected int trainPieces = 0;
protected int score = 0;
protected int completedDestCards = 0;
protected int longestRoute = 0;
protected ArrayList<Card> heldDestinationCards = new ArrayList<Card>();
protected ArrayList<Card> heldTrainCards = new ArrayList<Card>();
protected ArrayList<Card> heldTechCards = new ArrayList<Card>();
protected boolean startedWithDeck = false;
/**
* Constructor for Player class
*
* @param playerID A number ID for the player
* @param playerName The player's name
* @param playerColor The player's chosen color
*/
public Player(int playerID, String playerName, Color playerColor) {
this.id = playerID;
this.name = playerName;
this.color = playerColor;
trainPieces = 35;
}
/**
* To String method for player class
*
* @return The string representation of a player object
*/
public String toString() {
return name + " ID:" + id;
}
/**
* Removes a train card from the player's hand that is
* the same as the given card
*
* @param tr The train you want to remove
*
* @return The train you removed
*/
public Card removeTrainCard(Card tr){
for(int i = 0; i < heldTrainCards.size(); i++){
if(tr.equals(heldTrainCards.get(i))){
return heldTrainCards.remove(i);
}
}
return null;
}
}