-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeam.java
More file actions
67 lines (60 loc) · 1.5 KB
/
Team.java
File metadata and controls
67 lines (60 loc) · 1.5 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
import java.util.*;
/*
* Team class handles player in a team and sets its attributes
*/
public class Team {
private int teamId;
private int maxTeamSize = Const.MAX_TEAM_SIZE;
private int teamSize;
private ArrayList<Player> team;
private HashSet<Agent> agentsSelected;
private int role; // 0 - defenders, 1 - attackers
private int points;
Team(int teamNum){
this.teamId = teamNum;
this.teamSize = 0;
this.team = new ArrayList<>();
this.agentsSelected = new HashSet<>();
this.points = 0;
}
public boolean addAgent(Agent agent){
if(agentsSelected.contains(agent)){
return false;
}
agentsSelected.add(agent);
return true;
}
public boolean addPlayer(Player player){
if(this.teamSize < this.maxTeamSize){
team.add(player);
teamSize++;
return true;
}
return false;
}
public void removePlayer(Player player){
team.remove(player);
teamSize--;
}
public void addPoint(){
this.points++;
}
public int getTeamNum(){
return this.teamId;
}
public int getTeamSize(){
return this.teamSize;
}
public ArrayList<Player> getTeam(){
return this.team;
}
public int getRole(){
return this.role;
}
public Player getPlayer(int index){
return this.team.get(index);
}
public void setRole(int roleNum){
this.role = roleNum;
}
}