1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package nl.tudelft.goal.ut2004.visualizer.data;
18
19 import java.util.LinkedList;
20
21 import nl.tudelft.goal.ut2004.visualizer.util.ObservingCollection;
22
23 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.MapList;
24 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
25 import cz.cuni.amis.pogamut.ut2004.communication.worldview.map.Waypoint;
26 import cz.cuni.amis.pogamut.ut2004.server.IUT2004Server;
27 import cz.cuni.amis.utils.collections.ObservableCollection;
28
29
30
31
32
33
34
35
36 public class GameData extends AbstractData {
37
38 private final ObservingCollection<Player> players;
39 private final ObservableCollection<Waypoint> waypoints;
40 private final ObservableCollection<MapList> maps;
41
42 public GameData() {
43 players = new ObservingCollection<Player>();
44 waypoints = new ObservableCollection<Waypoint>(
45 new LinkedList<Waypoint>());
46 maps = new ObservableCollection<MapList>(new LinkedList<MapList>());
47
48 }
49
50 @Override
51 public void serverChanged(IUT2004Server server) {
52 players.removeObserved();
53 waypoints.clear();
54 maps.clear();
55 if (server != null) {
56 players.setObserved(server.getPlayers());
57 waypoints.addAll(server.getMap().vertexSet());
58 maps.addAll(server.getAvailableMaps());
59 }
60 }
61
62 public ObservableCollection<MapList> getAvailableMaps() {
63 return maps;
64 }
65
66 public ObservableCollection<Player> getPlayers() {
67 return players;
68 }
69
70 public ObservableCollection<Waypoint> getWaypoints() {
71 return waypoints;
72 }
73
74 }