-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClass_Player.pde
57 lines (49 loc) · 1.5 KB
/
Class_Player.pde
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
import java.util.ArrayList;
class Player
{
int[] resourceCounts = new int[5];
int longestRoad;
int victoryPoints;
ArrayList<DevelopmentCard> ownedDevCards = new ArrayList<DevelopmentCard>();
ArrayList<PointStruct> builtPointStructs = new ArrayList<PointStruct>();
ArrayList<Road> builtRoads = new ArrayList<Road>();
color playerColor;
Player(color playerColor)
{
this.playerColor = playerColor;
}
void updateLongestRoad()
{
//TODO: add implementation that checks the length of this player's longest road, updates it, compares that to the length of the player
//that owns the longest road (5 if null). This method should be invoked on the player who builds a road whenever they build it, and
//on any players with roads next to a settlement that has just been built (in case it cuts a road apart) aside from the player that
//built the settlement.
}
void buildRoad(Segment buildOn)
{
boolean sufficientResources = true;
for(int i = 0; i < roadCost.length; i++)
{
if(roadCost[i] < resourceCounts[i])
{
sufficientResources = false;
}
}
if(sufficientResources)
{
if(buildOn.placeRoad(new Road(this, buildOn)))
{
builtRoads.add(buildOn.getStructure());
for(int i = 0; i < roadCost.length; i++)
{
resourceCounts[i] -= roadCost[i];
}
updateLongestRoad();
}
}
else
{
println("insufficient resources");
}
}
}