author | Medo <smaxein@googlemail.com> |
Thu, 23 Aug 2012 18:28:33 +0200 | |
changeset 7588 | 27e5857da6af |
parent 7584 | 7831c84cc644 |
child 10017 | de822cd3df3a |
permissions | -rw-r--r-- |
7582
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1 |
/* |
7584
7831c84cc644
License change: With the agreement of Xeli, I changed the Hedgeroid license to
Medo <smaxein@googlemail.com>
parents:
7582
diff
changeset
|
2 |
* Hedgewars for Android. An Android port of Hedgewars, a free turn based strategy game |
7582
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
3 |
* Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com> |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
4 |
* |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
6 |
* modify it under the terms of the GNU General Public License |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
7 |
* as published by the Free Software Foundation; either version 2 |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
8 |
* of the License, or (at your option) any later version. |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
9 |
* |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
14 |
* |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
18 |
*/ |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
19 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
20 |
package org.hedgewars.hedgeroid; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
21 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
22 |
import static org.hedgewars.hedgeroid.util.ObjectUtils.equal; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
23 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
24 |
import java.util.Collections; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
25 |
import java.util.LinkedList; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
26 |
import java.util.List; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
27 |
import java.util.Map; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
28 |
import java.util.TreeMap; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
29 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
30 |
import org.hedgewars.hedgeroid.RoomStateManager; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
31 |
import org.hedgewars.hedgeroid.Datastructures.MapRecipe; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
32 |
import org.hedgewars.hedgeroid.Datastructures.Scheme; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
33 |
import org.hedgewars.hedgeroid.Datastructures.TeamInGame; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
34 |
import org.hedgewars.hedgeroid.Datastructures.Weaponset; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
35 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
36 |
/** |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
37 |
* Common base implementation for a roomstate that will call listeners on every |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
38 |
* change. The derived classes have to coordinate how state is changed to |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
39 |
* complete the implementation of the RoomStateManager interface. |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
40 |
* |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
41 |
* See {@link RoomStateManager} for a description of what this is for. |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
42 |
*/ |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
43 |
public abstract class BasicRoomState implements RoomStateManager { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
44 |
private final List<RoomStateManager.Listener> observers = new LinkedList<RoomStateManager.Listener>(); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
45 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
46 |
private boolean chief; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
47 |
private String gameStyle; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
48 |
private Scheme scheme; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
49 |
private MapRecipe map; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
50 |
private Weaponset weaponset; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
51 |
private Map<String, TeamInGame> teams = Collections.emptyMap(); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
52 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
53 |
public final MapRecipe getMapRecipe() { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
54 |
return map; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
55 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
56 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
57 |
public final boolean getChiefStatus() { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
58 |
return chief; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
59 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
60 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
61 |
public final Scheme getScheme() { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
62 |
return scheme; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
63 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
64 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
65 |
public final String getGameStyle() { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
66 |
return gameStyle; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
67 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
68 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
69 |
public final Weaponset getWeaponset() { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
70 |
return weaponset; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
71 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
72 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
73 |
public final Map<String, TeamInGame> getTeams() { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
74 |
return teams; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
75 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
76 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
77 |
public final void setWeaponset(Weaponset weaponset) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
78 |
if(!equal(weaponset, this.weaponset)) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
79 |
this.weaponset = weaponset; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
80 |
for(RoomStateManager.Listener observer : observers) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
81 |
observer.onWeaponsetChanged(weaponset); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
82 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
83 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
84 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
85 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
86 |
public final void setMapRecipe(MapRecipe map) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
87 |
if(!equal(map, this.map)) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
88 |
this.map = map; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
89 |
for(RoomStateManager.Listener observer : observers) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
90 |
observer.onMapChanged(map); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
91 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
92 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
93 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
94 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
95 |
public final void setGameStyle(String gameStyle) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
96 |
if(!equal(gameStyle, this.gameStyle)) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
97 |
this.gameStyle = gameStyle; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
98 |
for(RoomStateManager.Listener observer : observers) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
99 |
observer.onGameStyleChanged(gameStyle); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
100 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
101 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
102 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
103 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
104 |
public final void setScheme(Scheme scheme) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
105 |
if(!equal(scheme, this.scheme)) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
106 |
this.scheme = scheme; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
107 |
for(RoomStateManager.Listener observer : observers) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
108 |
observer.onSchemeChanged(scheme); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
109 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
110 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
111 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
112 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
113 |
public final void setChief(boolean chief) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
114 |
if(chief != this.chief) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
115 |
this.chief = chief; |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
116 |
for(RoomStateManager.Listener observer : observers) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
117 |
observer.onChiefStatusChanged(chief); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
118 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
119 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
120 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
121 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
122 |
public final void putTeam(TeamInGame team) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
123 |
TeamInGame oldEntry = teams.get(team.team.name); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
124 |
if(!equal(team, oldEntry)) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
125 |
Map<String, TeamInGame> changedMap = new TreeMap<String, TeamInGame>(teams); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
126 |
changedMap.put(team.team.name, team); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
127 |
teams = Collections.unmodifiableMap(changedMap); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
128 |
for(RoomStateManager.Listener observer : observers) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
129 |
observer.onTeamsChanged(teams); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
130 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
131 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
132 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
133 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
134 |
public final void removeTeam(String teamname) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
135 |
if(teams.containsKey(teamname)) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
136 |
Map<String, TeamInGame> changedMap = new TreeMap<String, TeamInGame>(teams); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
137 |
changedMap.remove(teamname); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
138 |
teams = Collections.unmodifiableMap(changedMap); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
139 |
for(RoomStateManager.Listener observer : observers) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
140 |
observer.onTeamsChanged(teams); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
141 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
142 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
143 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
144 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
145 |
public final void setTeams(Map<String, TeamInGame> newTeams) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
146 |
if(!newTeams.equals(teams)) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
147 |
teams = Collections.unmodifiableMap(new TreeMap<String, TeamInGame>(newTeams)); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
148 |
for(RoomStateManager.Listener observer : observers) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
149 |
observer.onTeamsChanged(teams); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
150 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
151 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
152 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
153 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
154 |
public final void addListener(Listener observer) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
155 |
observers.add(observer); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
156 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
157 |
|
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
158 |
public final void removeListener(Listener observer) { |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
159 |
observers.remove(observer); |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
160 |
} |
714310efad8f
Hedgeroid: Final sprint to the deadline
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
161 |
} |