author | Medo <smaxein@googlemail.com> |
Sun, 12 Aug 2012 23:20:34 +0200 | |
changeset 7491 | d954c1a36e51 |
parent 7485 | 0481bd74267c |
permissions | -rw-r--r-- |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1 |
package org.hedgewars.hedgeroid.netplay; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
2 |
|
7485 | 3 |
import java.util.Collection; |
4 |
||
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
5 |
import org.hedgewars.hedgeroid.Datastructures.TeamInGame; |
7485 | 6 |
import org.hedgewars.hedgeroid.Datastructures.TeamIngameAttributes; |
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
7 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
8 |
import android.util.Pair; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
9 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
10 |
public class Teamlist extends ObservableTreeMap<String, Pair<TeamInGame, Long>> { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
11 |
private long nextId = 1; |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
12 |
|
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
13 |
public void addTeamWithNewId(TeamInGame team) { |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
14 |
put(team.team.name, Pair.create(team, nextId++)); |
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
15 |
} |
7485 | 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 |
} |
|
7476
2fb781bbdd51
Hedgeroid: Start using the frontlib for more operations
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
27 |
} |