project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/Teamlist.java
changeset 7485 0481bd74267c
parent 7476 2fb781bbdd51
equal deleted inserted replaced
7482:d70a5b0d1190 7485:0481bd74267c
     1 package org.hedgewars.hedgeroid.netplay;
     1 package org.hedgewars.hedgeroid.netplay;
     2 
     2 
       
     3 import java.util.Collection;
       
     4 
     3 import org.hedgewars.hedgeroid.Datastructures.TeamInGame;
     5 import org.hedgewars.hedgeroid.Datastructures.TeamInGame;
       
     6 import org.hedgewars.hedgeroid.Datastructures.TeamIngameAttributes;
     4 
     7 
     5 import android.util.Pair;
     8 import android.util.Pair;
     6 
     9 
     7 public class Teamlist extends ObservableTreeMap<String, Pair<TeamInGame, Long>> {
    10 public class Teamlist extends ObservableTreeMap<String, Pair<TeamInGame, Long>> {
     8 	private long nextId = 1;
    11 	private long nextId = 1;
     9 	
    12 	
    10 	public void addTeamWithNewId(TeamInGame team) {
    13 	public void addTeamWithNewId(TeamInGame team) {
    11 		put(team.team.name, Pair.create(team, nextId++));
    14 		put(team.team.name, Pair.create(team, nextId++));
    12 	}
    15 	}
       
    16 	
       
    17 	public int getUnusedOrRandomColorIndex() {
       
    18 		Collection<Pair<TeamInGame, Long>> teams = getMap().values();
       
    19 		int[] illegalColors = new int[teams.size()];
       
    20 		int i=0;
       
    21 		for(Pair<TeamInGame, Long> item : teams) {
       
    22 			illegalColors[i] = item.first.ingameAttribs.colorIndex;
       
    23 			i++;
       
    24 		}
       
    25 		return TeamIngameAttributes.randomColorIndex(illegalColors);
       
    26 	}
    13 }
    27 }