-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGuild.java
51 lines (37 loc) · 1.23 KB
/
Guild.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
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.stream.Collectors;
public class Guild {
private ArrayList<Character> members;
public Guild(){
members = new ArrayList<Character>();
}
public void addMember(Character character){
members.add(character);
}
public Collection<Character> getMembers(){
return members;
}
public Team getTeam(Team enemyTeam){
ArrayList<Character> newTeamMembers = (ArrayList<Character>)members.stream()
.sorted(Comparator.comparing(Character::getPowerPoints))
.collect(Collectors.toList());
Team team = null ;
if(enemyTeam instanceof StudentTeam){
team = new MonsterTeam("");
}
else if(enemyTeam instanceof MonsterTeam){
team = new StudentTeam("");
}
for(int i = newTeamMembers.size() - 1; i >= 0; i++){
if(newTeamMembers.get(i).isAlive()){
team.addMember(newTeamMembers.get(i));
}
if(team.getMembersCount() >= 5){
break;
}
}
return team;
}
}