project_files/Android-build/SDL-android-project/src/org/hedgewars/hedgeroid/netplay/RoomPlayerlist.java
equal
deleted
inserted
replaced
1 package org.hedgewars.hedgeroid.netplay; |
|
2 |
|
3 import org.hedgewars.hedgeroid.Datastructures.Player; |
|
4 import org.hedgewars.hedgeroid.netplay.RoomPlayerlist.PlayerInRoom; |
|
5 |
|
6 import android.util.Log; |
|
7 |
|
8 public class RoomPlayerlist extends ObservableTreeMap<String, PlayerInRoom> { |
|
9 private long nextId = 1; |
|
10 |
|
11 public void addPlayerWithNewId(String name) { |
|
12 put(name, new PlayerInRoom(new Player(name), nextId++, false)); |
|
13 } |
|
14 |
|
15 public void setReady(String name, boolean ready) { |
|
16 PlayerInRoom oldEntry = get(name); |
|
17 if(oldEntry==null) { |
|
18 Log.e("RoomPlayerlist", "Setting readystate for unknown player "+name); |
|
19 } else { |
|
20 put(name, new PlayerInRoom(oldEntry.player, oldEntry.id, ready)); |
|
21 } |
|
22 } |
|
23 |
|
24 // Immutable |
|
25 public static class PlayerInRoom { |
|
26 public final Player player; |
|
27 public final long id; |
|
28 public final boolean ready; |
|
29 |
|
30 public PlayerInRoom(Player player, long id, boolean ready) { |
|
31 this.player = player; |
|
32 this.id = id; |
|
33 this.ready = ready; |
|
34 } |
|
35 } |
|
36 } |
|