View Javadoc

1   
2               /**
3               IMPORTANT !!!
4   
5               DO NOT EDIT THIS FILE. IT IS GENERATED FROM approriate xml file in xmlresources/gbinfomessages BY
6               THE JavaClassesGenerator.xslt. MODIFY THESE FILES INSTEAD OF THIS ONE.
7   
8               IMPORTANT END !!!
9               */
10              package
11              cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages;
12  	    		import java.util.*;
13      import javax.vecmath.*;
14      import cz.cuni.amis.pogamut.base.communication.messages.*;
15      import cz.cuni.amis.pogamut.base.communication.worldview.*;
16      import cz.cuni.amis.pogamut.base.communication.worldview.event.*;
17      import cz.cuni.amis.pogamut.base.communication.worldview.object.*;
18      import cz.cuni.amis.pogamut.base.communication.translator.event.*;
19      import cz.cuni.amis.pogamut.base3d.worldview.object.*;
20      import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;
21      import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
22      import cz.cuni.amis.pogamut.udk.communication.messages.*;
23      import cz.cuni.amis.pogamut.udk.communication.worldview.objects.*;
24      import cz.cuni.amis.pogamut.udk.communication.translator.itemdescriptor.*;
25      import cz.cuni.amis.pogamut.udk.communication.messages.ItemType.Category;
26      import cz.cuni.amis.utils.exception.*;
27      import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;
28      import cz.cuni.amis.utils.SafeEquals;
29      import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;
30      
31              
32              /**
33                
34  		Synchronous message. Contains the info about team score.
35  	
36                            Corresponding GameBots message is
37                            TES.
38                        
39               */
40              
41              public class
42              TeamScore
43                      extends GBObjectUpdate
44                  
45  	            	implements IGBWorldObjectEvent, IWorldObject
46  
47              {
48              
49              /**
50                Creates new instance of command TeamScore.
51                
52  		Synchronous message. Contains the info about team score.
53  	Corresponding GameBots message for this command is
54                .
55                    @param Id Message identifier.
56                    @param Team Team identifier.
57                    @param Score 
58  			The score of the team (can be some special measurement that
59  			differs from game type to game type - number of stolen flags
60  			in CTF game, number of team frags in TeamGame, etc.)
61  		
62                */
63               public TeamScore(
64                  UnrealId Id,  int Team,  int Score) {
65                      
66                      this.Id = Id;
67                  
68                      this.Team = Team;
69                  
70                      this.Score = Score;
71                  
72                  }
73  
74              
75      	/** Example how the message looks like - used during parser tests. */
76      	public static final String PROTOTYPE =
77      		"TES {Id unreal_id} {Team 0} {Score 0}";
78      
79  
80              /////// Properties BEGIN
81              
82          /**
83          Message identifier. */
84          protected
85           UnrealId Id =
86          	null;
87  
88          
89          /**
90          Message identifier. */
91          public
92          UnrealId getId() {
93              return
94           Id;
95          }
96          
97  
98          
99          /**
100         Team identifier. */
101         protected
102          int Team =
103         	0;
104 
105         
106         /**
107         Team identifier. */
108         public
109         int getTeam() {
110             return
111          Team;
112         }
113         
114 
115         
116         /**
117         
118 			The score of the team (can be some special measurement that
119 			differs from game type to game type - number of stolen flags
120 			in CTF game, number of team frags in TeamGame, etc.)
121 		 */
122         protected
123          int Score =
124         	0;
125 
126         
127         /**
128         
129 			The score of the team (can be some special measurement that
130 			differs from game type to game type - number of stolen flags
131 			in CTF game, number of team frags in TeamGame, etc.)
132 		 */
133         public
134         int getScore() {
135             return
136          Score;
137         }
138         
139 
140         
141             /////// Properties END
142 
143             /////// Extra Java code BEGIN
144 
145             	/////// Additional code from xslt BEGIN
146             		
147        							protected double Time = 0;
148 
149        							protected double getTime() {
150        								return Time;
151        							}
152 
153        							protected void setTime(double time) {
154        								this.Time = time;
155        							}
156 
157        							public double getLastSeenTime() {
158        								return Time;
159        							}
160        						
161        					
162        					public ILocalWorldObject getLocal() {
163        						return null;
164        					}
165        					
166        					public ISharedWorldObject getShared() {
167        						return null;
168        					}
169        					
170        					public IStaticWorldObject getStatic() {
171        						return null;
172        					}
173        					
174        					@Override
175        					public long getSimTime() {
176        						return (long)getLastSeenTime();
177        					}
178 
179        					public boolean equals(Object obj) {
180 	                      if (!(obj instanceof TeamScore)) return false;
181 	                      TeamScore cast = (TeamScore)obj;
182 	                      if (this.getId() != null) return this.getId().equals(cast.getId());
183 	                      else return cast.getId() == null;
184 	                    }
185 
186 	                    public int hashCode() {
187 	                      if (getId() != null) return getId().hashCode();
188 	                      return 0;
189 	                    }
190 
191             		
192 
193 
194             	/////// Additional code from xslt END
195 
196 	            /////// Extra Java from XML BEGIN
197             						
198 			
199             	/////// Extra Java from XML END
200 
201             /////// Extra Java code END
202 
203             
204 
205             /**
206               * Cloning constructor.
207               */
208              public TeamScore(TeamScore original) {
209                 
210                      this.Id=original.Id;
211                 
212                      this.Team=original.Team;
213                 
214                      this.Score=original.Score;
215                 
216              }
217 
218              
219                  /**
220                   * Used by Yylex to create empty message then to fill it's protected fields (Yylex is in the same package).
221                   */
222 	             public TeamScore() {
223 	             }
224              
225 
226 	    		/**
227 	    		 * Here we save the original object for which this object is an update.
228 	    		 */
229 	    		private IWorldObject orig = null;
230 
231 	            public IWorldObjectUpdateResult update(IWorldObject obj) {
232 		            if(obj == null) {
233 		               orig = this;
234 		               return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.CREATED, this);
235 		            }
236 		            orig = obj;
237 		            // typecast
238 		            TeamScore  o = (TeamScore)obj;
239 
240 		            boolean updated = false;
241 
242 		            
243 		    					if (o.Score != Score) {
244 		    					    o.Score=Score;
245 		    						updated = true;
246 		    					}
247 		    				
248 								o.Time = Time;
249 							
250 
251 		            if (updated) {
252 		                return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.UPDATED, o);
253 		            } else {
254 		            	return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.SAME, o);
255 		            }
256 		        }
257 
258 	            /**
259 	             * Returns original object (if method update() has already been called, for bot-programmer that is always true
260 	             * as the original object is updated and then the event is propagated).
261 	             */
262 		        public IWorldObject getObject() {
263 		            if (orig == null) return this;
264 		            return orig;
265 		        }
266 	        
267 
268                  
269             public String toString() {
270                 return
271                 
272                 		super.toString() + " | " +
273                 		
274 				               "Id = " +
275 				               String.valueOf(Id) + " | " +
276 				            
277 				               "Team = " +
278 				               String.valueOf(Team) + " | " +
279 				            
280 				               "Score = " +
281 				               String.valueOf(Score) + " | " +
282 				             "";
283                 	
284              }
285 
286              public String toHtmlString() {
287                 return super.toString() +
288             
289             "<b>Id</b> : " +
290             String.valueOf(Id) +
291             " <br/> " +
292             
293             "<b>Team</b> : " +
294             String.valueOf(Team) +
295             " <br/> " +
296             
297             "<b>Score</b> : " +
298             String.valueOf(Score) +
299             " <br/> " +
300              "";
301              }
302 
303              
304              
305              }
306 
307