project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/Teamlist.java
changeset 7485 0481bd74267c
parent 7476 2fb781bbdd51
--- a/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/Teamlist.java	Sun Aug 12 22:37:57 2012 +0200
+++ b/project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/Teamlist.java	Sun Aug 12 22:46:23 2012 +0200
@@ -1,6 +1,9 @@
 package org.hedgewars.hedgeroid.netplay;
 
+import java.util.Collection;
+
 import org.hedgewars.hedgeroid.Datastructures.TeamInGame;
+import org.hedgewars.hedgeroid.Datastructures.TeamIngameAttributes;
 
 import android.util.Pair;
 
@@ -10,4 +13,15 @@
 	public void addTeamWithNewId(TeamInGame team) {
 		put(team.team.name, Pair.create(team, nextId++));
 	}
+	
+	public int getUnusedOrRandomColorIndex() {
+		Collection<Pair<TeamInGame, Long>> teams = getMap().values();
+		int[] illegalColors = new int[teams.size()];
+		int i=0;
+		for(Pair<TeamInGame, Long> item : teams) {
+			illegalColors[i] = item.first.ingameAttribs.colorIndex;
+			i++;
+		}
+		return TeamIngameAttributes.randomColorIndex(illegalColors);
+	}
 }