diff -r ed1d52c5aa94 -r 763d3961400b project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/TeamInGame.java --- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/TeamInGame.java Sat Aug 18 00:22:33 2012 +0200 +++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/TeamInGame.java Sat Aug 18 00:47:51 2012 +0200 @@ -1,5 +1,8 @@ package org.hedgewars.hedgeroid.Datastructures; +import java.util.Collection; +import java.util.Comparator; + /** * A team with per-game configuration. This is similar to the frontlib "team" structure, * except that it does not include weaponset and initial health, which are handled on a @@ -17,4 +20,20 @@ public TeamInGame withAttribs(TeamIngameAttributes attribs) { return new TeamInGame(team, attribs); } + + public static int getUnusedOrRandomColorIndex(Collection teams) { + int[] illegalColors = new int[teams.size()]; + int i=0; + for(TeamInGame team : teams) { + illegalColors[i] = team.ingameAttribs.colorIndex; + i++; + } + return TeamIngameAttributes.randomColorIndex(illegalColors); + } + + public static Comparator NAME_ORDER = new Comparator() { + public int compare(TeamInGame lhs, TeamInGame rhs) { + return Team.NAME_ORDER.compare(lhs.team, rhs.team); + } + }; }