View Javadoc

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=static]+classtype[@name=impl] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=static]+classtype[@name=impl] END
15      
16   		/**
17           *  
18              				Implementation of the static part of the GameBots2004 message TES.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Synchronous message. Contains the info about team score.
25  	
26           */
27   	public class TeamScoreStaticImpl 
28    						extends
29    						TeamScoreStatic
30  	    {
31   	
32      	
33      	
34      	/**
35      	 * Parameter-less contructor for the message.
36      	 */
37  		public TeamScoreStaticImpl()
38  		{
39  		}
40  	
41      	
42      	
43      	
44      	/**
45  		 * Creates new instance of the message TeamScore.
46  		 * 
47  		Synchronous message. Contains the info about team score.
48  	
49  		 * Corresponding GameBots message
50  		 *   (static part)
51  		 *   is
52  		 *   TES.
53  		 * 
54   	  	 * 
55  		 *   
56  		 *     @param Id Message identifier.
57  		 *   
58  		 * 
59  		 *   
60  		 * 
61  		 *   
62  		 * 
63  		 */
64  		public TeamScoreStaticImpl(
65  			UnrealId Id
66  		) {
67  			
68  					this.Id = Id;
69  				
70  		}
71      
72      	/**
73  		 * Cloning constructor from the full message.
74  		 *
75  		 * @param original
76  		 */
77  		public TeamScoreStaticImpl(TeamScore original) {		
78  			
79  					this.Id = original.getId()
80   	;
81  				
82  			this.SimTime = original.getSimTime();			
83  		}
84  		
85  		/**
86  		 * Cloning constructor from the full message.
87  		 *
88  		 * @param original
89  		 */
90  		public TeamScoreStaticImpl(TeamScoreStaticImpl original) {		
91  			
92  					this.Id = original.getId()
93   	;
94  				
95  			this.SimTime = original.getSimTime();
96  		}
97  		
98  			/**
99  			 * Cloning constructor from the message part.
100 			 *
101 			 * @param original
102 			 */
103 			public TeamScoreStaticImpl(TeamScoreStatic original) {
104 				
105 						this.Id = original.getId()
106  	;
107 					
108 			}
109 		
110    				
111    				@Override
112    				public void setSimTime(long SimTime) {
113 					super.setSimTime(SimTime);
114 				}
115    			
116 	    				@Override
117 	    				public 
118 	    				TeamScoreStaticImpl clone() {
119 	    					return new 
120 	    					TeamScoreStaticImpl(this);
121 	    				}
122 	    				
123 	    				
124     	
125 	    /**
126          * Message identifier. 
127          */
128         protected
129          UnrealId Id =
130        	null;
131 	
132  		/**
133          * Message identifier. 
134          */
135         public  UnrealId getId()
136  	 {
137 				    					return Id;
138 				    				}
139 				    			
140     	
141     	
142     	public static class TeamScoreStaticUpdate
143      implements IStaticWorldObjectUpdatedEvent
144 		{
145 			
146 			private TeamScoreStatic data;
147 			private long time;
148 			
149 			public TeamScoreStaticUpdate
150     (TeamScoreStatic source, long time)
151 			{
152 				this.data = source;
153 				this.time = time;
154 			}
155 			
156 			/**
157 			 * Simulation time in MILLI SECONDS !!!
158 			 */
159 			@Override
160 			public long getSimTime() {
161 				return time;
162 			}
163 	
164 			@Override
165 			public WorldObjectId getId() {
166 				return data.getId();
167 			}
168 			
169 			@Override
170 			public IWorldObjectUpdateResult<IStaticWorldObject> update(
171 					IStaticWorldObject object) {
172 				if ( object == null)
173 				{
174 					data = new TeamScoreStaticImpl(data);
175 					return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.CREATED, data);
176 				}
177 				//since static objects can't be updated, we'll just check that the object stays the same
178 				if ( object instanceof TeamScoreStaticImpl)
179 				{
180 					TeamScoreStaticImpl orig = (TeamScoreStaticImpl)object;
181 					//since these errors usually mean error in gamebots, we will just print an error message
182 					if ( data.isDifferentFrom(orig) )
183 					{
184 						//data.isDifferentFrom(orig);
185 						//throw new PogamutException("Trying to modify static object " + this.data.getId().toString() , this);
186 						System.out.println("!!!!!ERROR!!!!!! in static object modification. Object class : TeamScoreStaticImpl to see which property was different see !!!!PROPERTY UPDATE ERROR!!!!");
187 					}
188 					return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.SAME, data);
189 				}				
190 				throw new PogamutException("Unexpected object type for update, TeamScoreStaticImpl expected not class " + object.getClass().getSimpleName() + ".", this);
191 			}
192 		}
193 	
194     
195  		
196  		@Override
197  		public boolean isDifferentFrom(IStaticWorldObject other)
198  		{
199  			if (other == null) //early fail
200  			{
201  				return true;
202  			}
203  			else if (other == this) //early out
204  			{
205  				return false;
206  			}
207  			else
208  			{
209  				TeamScoreStatic obj = (TeamScoreStatic) other;
210 
211  				
212  						if ( !(
213  	 			AdvancedEquals.equalsOrNull(this.getId()
214  	, obj.getId()
215  	)
216  	 		) )
217 						{
218 							System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Id on object class TeamScoreStatic");
219 							return true;
220 						}
221  					
222  			}
223  			return false;
224  		}
225  	 
226  		
227  	    public String toString() {
228             return
229             	super.toString() + "[" +
230             	
231 		              			"Id = " + String.valueOf(getId()
232  	) + " | " + 
233 		              		
234 				"]";           		
235         }
236  	
237  		
238  		public String toHtmlString() {
239  			return super.toString() + "[<br/>" +
240             	
241 		              			"<b>Id</b> = " + String.valueOf(getId()
242  	) + " <br/> " + 
243 		              		
244 				"<br/>]";     
245 		}
246  	
247  		
248  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
249         	
250 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
251 		
252 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=static+classtype[@name=impl]) ---
253 	        
254 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=static+classtype[@name=impl]) ---        	            	
255  	
256 		}
257