project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/TeamInGame.java
equal
deleted
inserted
replaced
1 package org.hedgewars.hedgeroid.Datastructures; |
1 package org.hedgewars.hedgeroid.Datastructures; |
|
2 |
|
3 import java.util.Collection; |
|
4 import java.util.Comparator; |
2 |
5 |
3 /** |
6 /** |
4 * A team with per-game configuration. This is similar to the frontlib "team" structure, |
7 * A team with per-game configuration. This is similar to the frontlib "team" structure, |
5 * except that it does not include weaponset and initial health, which are handled on a |
8 * except that it does not include weaponset and initial health, which are handled on a |
6 * per-game basis in the UI, but per-hog in the frontlib. |
9 * per-game basis in the UI, but per-hog in the frontlib. |
15 } |
18 } |
16 |
19 |
17 public TeamInGame withAttribs(TeamIngameAttributes attribs) { |
20 public TeamInGame withAttribs(TeamIngameAttributes attribs) { |
18 return new TeamInGame(team, attribs); |
21 return new TeamInGame(team, attribs); |
19 } |
22 } |
|
23 |
|
24 public static int getUnusedOrRandomColorIndex(Collection<TeamInGame> teams) { |
|
25 int[] illegalColors = new int[teams.size()]; |
|
26 int i=0; |
|
27 for(TeamInGame team : teams) { |
|
28 illegalColors[i] = team.ingameAttribs.colorIndex; |
|
29 i++; |
|
30 } |
|
31 return TeamIngameAttributes.randomColorIndex(illegalColors); |
|
32 } |
|
33 |
|
34 public static Comparator<TeamInGame> NAME_ORDER = new Comparator<TeamInGame>() { |
|
35 public int compare(TeamInGame lhs, TeamInGame rhs) { |
|
36 return Team.NAME_ORDER.compare(lhs.team, rhs.team); |
|
37 } |
|
38 }; |
20 } |
39 } |