1 package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2
3 // --- IMPORTS FROM /messages/settings/javasettings/javaimport BEGIN
4 import java.util.*;import javax.vecmath.*;import cz.cuni.amis.pogamut.base.communication.messages.*;import cz.cuni.amis.pogamut.base.communication.worldview.*;import cz.cuni.amis.pogamut.base.communication.worldview.event.*;import cz.cuni.amis.pogamut.base.communication.worldview.object.*;import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;import cz.cuni.amis.pogamut.base.communication.translator.event.*;import cz.cuni.amis.pogamut.multi.communication.translator.event.*;import cz.cuni.amis.pogamut.base3d.worldview.object.*;import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.*;import cz.cuni.amis.pogamut.ut2004.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004.communication.translator.itemdescriptor.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType.Category;import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;import cz.cuni.amis.utils.exception.*;import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;import cz.cuni.amis.utils.SafeEquals;import cz.cuni.amis.pogamut.base.agent.*;import cz.cuni.amis.pogamut.multi.agent.*;import cz.cuni.amis.pogamut.multi.communication.worldview.property.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.property.*;import cz.cuni.amis.utils.token.*;import cz.cuni.amis.utils.*;
5 // --- IMPORTS FROM /messages/settings/javasettings/javaimport END
6
7
8 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] BEGIN
9
10 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] END
11
12 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] BEGIN
13
14 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] END
15
16 /**
17 *
18 Definition of the event TEAMCHANGE.
19
20 *
21 * <p></p><p></p>
22 * Complete message documentation:
23 *
24 Aynchronous message. Response of the CHANGETEAM command.
25
26 */
27 public class TeamChanged
28 extends InfoMessage
29 implements IWorldEvent, IWorldChangeEvent
30
31 {
32
33 /** Example how the message looks like - used during parser tests. */
34 public static final String PROTOTYPE =
35 "TEAMCHANGE {Id unreal_id} {Success False} {DesiredTeam 0} ";
36
37
38
39 /**
40 * Parameter-less contructor for the message.
41 */
42 public TeamChanged()
43 {
44 }
45
46
47
48
49 /**
50 * Creates new instance of the message TeamChanged.
51 *
52 Aynchronous message. Response of the CHANGETEAM command.
53
54 * Corresponding GameBots message
55 *
56 * is
57 * TEAMCHANGE.
58 *
59 *
60 *
61 * @param Id
62 Sent only for ControlServer connections, so they know which bot changed the team.
63
64 *
65 *
66 *
67 * @param Success
68 If true team change was succesfull (it won't be succesfull if
69 we are changing to a team we already are in).
70
71 *
72 *
73 *
74 * @param DesiredTeam
75 This is the team we wanted to change to (0 for red,1 for
76 blue, etc..).
77
78 *
79 *
80 */
81 public TeamChanged(
82 UnrealId Id, boolean Success, int DesiredTeam
83 ) {
84
85 this.Id = Id;
86
87 this.Success = Success;
88
89 this.DesiredTeam = DesiredTeam;
90
91 }
92
93 /**
94 * Cloning constructor from the full message.
95 *
96 * @param original
97 */
98 public TeamChanged(TeamChanged original) {
99
100 this.Id = original.getId()
101 ;
102
103 this.Success = original.isSuccess()
104 ;
105
106 this.DesiredTeam = original.getDesiredTeam()
107 ;
108
109 this.SimTime = original.getSimTime();
110 }
111
112
113 protected long SimTime;
114
115 /**
116 * Simulation time in MILLI SECONDS !!!
117 */
118 @Override
119 public long getSimTime() {
120 return SimTime;
121 }
122
123 /**
124 * Used by Yylex to slip correct time of the object or programmatically.
125 */
126 protected void setSimTime(long SimTime) {
127 this.SimTime = SimTime;
128 }
129
130
131 /**
132 *
133 Sent only for ControlServer connections, so they know which bot changed the team.
134
135 */
136 protected
137 UnrealId Id =
138 null;
139
140 /**
141 *
142 Sent only for ControlServer connections, so they know which bot changed the team.
143
144 */
145 public UnrealId getId()
146 {
147 return Id;
148 }
149
150
151 /**
152 *
153 If true team change was succesfull (it won't be succesfull if
154 we are changing to a team we already are in).
155
156 */
157 protected
158 boolean Success =
159 false;
160
161 /**
162 *
163 If true team change was succesfull (it won't be succesfull if
164 we are changing to a team we already are in).
165
166 */
167 public boolean isSuccess()
168 {
169 return Success;
170 }
171
172
173 /**
174 *
175 This is the team we wanted to change to (0 for red,1 for
176 blue, etc..).
177
178 */
179 protected
180 int DesiredTeam =
181 0;
182
183 /**
184 *
185 This is the team we wanted to change to (0 for red,1 for
186 blue, etc..).
187
188 */
189 public int getDesiredTeam()
190 {
191 return DesiredTeam;
192 }
193
194
195 public String toString() {
196 return
197 super.toString() + "[" +
198
199 "Id = " + String.valueOf(getId()
200 ) + " | " +
201
202 "Success = " + String.valueOf(isSuccess()
203 ) + " | " +
204
205 "DesiredTeam = " + String.valueOf(getDesiredTeam()
206 ) + " | " +
207
208 "]";
209 }
210
211
212 public String toHtmlString() {
213 return super.toString() + "[<br/>" +
214
215 "<b>Id</b> = " + String.valueOf(getId()
216 ) + " <br/> " +
217
218 "<b>Success</b> = " + String.valueOf(isSuccess()
219 ) + " <br/> " +
220
221 "<b>DesiredTeam</b> = " + String.valueOf(getDesiredTeam()
222 ) + " <br/> " +
223
224 "<br/>]";
225 }
226
227 public String toJsonLiteral() {
228 return "teamchanged( "
229 +
230 (getId()
231 == null ? "null" :
232 "\"" + getId()
233 .getStringId() + "\""
234 )
235 + ", " +
236 String.valueOf(isSuccess()
237 )
238 + ", " +
239 String.valueOf(getDesiredTeam()
240 )
241
242 + ")";
243 }
244
245
246 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
247
248 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
249
250 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
251
252 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
253
254 }
255