project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/Datastructures/TeamInGame.java
changeset 7508 763d3961400b
parent 7485 0481bd74267c
child 7584 7831c84cc644
--- 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<TeamInGame> 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<TeamInGame> NAME_ORDER = new Comparator<TeamInGame>() {
+		public int compare(TeamInGame lhs, TeamInGame rhs) {
+			return Team.NAME_ORDER.compare(lhs.team, rhs.team);
+		}
+	};
 }