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=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 WUP.
19           		
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Asynchronous message. Send when the bot changed weapon. Here we will export
25          the status of the old weapon - of the weapon that was changed. So we can have
26          correct info about weapons in our inventory. This could be a problem without
27          this message because of synchronous batch delay.
28  	
29           */
30   	public class WeaponUpdate 
31    				extends InfoMessage
32      			implements IWorldEvent, IWorldChangeEvent
33      			
34  	    {
35   	
36      	/** Example how the message looks like - used during parser tests. */
37      	public static final String PROTOTYPE =
38      		"WUP {Id unreal_id}  {PrimaryAmmo 0}  {SecondaryAmmo 0}  {InventoryType text} ";
39      
40      	
41      	
42      	/**
43      	 * Parameter-less contructor for the message.
44      	 */
45  		public WeaponUpdate()
46  		{
47  		}
48  	
49      	
50      	
51      	
52      	/**
53  		 * Creates new instance of the message WeaponUpdate.
54  		 * 
55  		Asynchronous message. Send when the bot changed weapon. Here we will export
56          the status of the old weapon - of the weapon that was changed. So we can have
57          correct info about weapons in our inventory. This could be a problem without
58          this message because of synchronous batch delay.
59  	
60  		 * Corresponding GameBots message
61  		 *   
62  		 *   is
63  		 *   WUP.
64  		 * 
65   	  	 * 
66  		 *   
67  		 *     @param Id 
68  			Unique Id of the weapon, based on the inventory weapon's
69  			name (this is different from the Id of the weapon that can
70  			be picked up in the map).
71  		
72  		 *   
73  		 * 
74  		 *   
75  		 *     @param PrimaryAmmo 
76  			Holding primary ammo of the old weapon (that was changed).
77  		
78  		 *   
79  		 * 
80  		 *   
81  		 *     @param SecondaryAmmo 
82  			Holding secondary ammo of the old weapon (that was changed)
83  		
84  		 *   
85  		 * 
86  		 *   
87  		 *     @param InventoryType 
88  			Class of the weapon in the inventory. Matches InventoryType in the item class (ITC) message.
89  		
90  		 *   
91  		 * 
92  		 */
93  		public WeaponUpdate(
94  			UnrealId Id,  int PrimaryAmmo,  int SecondaryAmmo,  String InventoryType
95  		) {
96  			
97  					this.Id = Id;
98  				
99  					this.PrimaryAmmo = PrimaryAmmo;
100 				
101 					this.SecondaryAmmo = SecondaryAmmo;
102 				
103 					this.InventoryType = InventoryType;
104 				
105 		}
106     
107     	/**
108 		 * Cloning constructor from the full message.
109 		 *
110 		 * @param original
111 		 */
112 		public WeaponUpdate(WeaponUpdate original) {		
113 			
114 					this.Id = original.getId()
115  	;
116 				
117 					this.PrimaryAmmo = original.getPrimaryAmmo()
118  	;
119 				
120 					this.SecondaryAmmo = original.getSecondaryAmmo()
121  	;
122 				
123 					this.InventoryType = original.getInventoryType()
124  	;
125 				
126 			this.SimTime = original.getSimTime();			
127 		}
128 		
129 	   		
130 			protected long SimTime;
131 				
132 			/**
133 			 * Simulation time in MILLI SECONDS !!!
134 			 */	
135 			@Override
136 			public long getSimTime() {
137 				return SimTime;
138 			}
139 						
140 			/**
141 			 * Used by Yylex to slip correct time of the object or programmatically.
142 			 */
143 			protected void setSimTime(long SimTime) {
144 				this.SimTime = SimTime;
145 			}
146 	   	
147     	
148 	    /**
149          * 
150 			Unique Id of the weapon, based on the inventory weapon's
151 			name (this is different from the Id of the weapon that can
152 			be picked up in the map).
153 		 
154          */
155         protected
156          UnrealId Id =
157        	null;
158 	
159  		/**
160          * 
161 			Unique Id of the weapon, based on the inventory weapon's
162 			name (this is different from the Id of the weapon that can
163 			be picked up in the map).
164 		 
165          */
166         public  UnrealId getId()
167  	 {
168     					return Id;
169     				}
170     			
171     	
172 	    /**
173          * 
174 			Holding primary ammo of the old weapon (that was changed).
175 		 
176          */
177         protected
178          int PrimaryAmmo =
179        	0;
180 	
181  		/**
182          * 
183 			Holding primary ammo of the old weapon (that was changed).
184 		 
185          */
186         public  int getPrimaryAmmo()
187  	 {
188     					return PrimaryAmmo;
189     				}
190     			
191     	
192 	    /**
193          * 
194 			Holding secondary ammo of the old weapon (that was changed)
195 		 
196          */
197         protected
198          int SecondaryAmmo =
199        	0;
200 	
201  		/**
202          * 
203 			Holding secondary ammo of the old weapon (that was changed)
204 		 
205          */
206         public  int getSecondaryAmmo()
207  	 {
208     					return SecondaryAmmo;
209     				}
210     			
211     	
212 	    /**
213          * 
214 			Class of the weapon in the inventory. Matches InventoryType in the item class (ITC) message.
215 		 
216          */
217         protected
218          String InventoryType =
219        	null;
220 	
221  		/**
222          * 
223 			Class of the weapon in the inventory. Matches InventoryType in the item class (ITC) message.
224 		 
225          */
226         public  String getInventoryType()
227  	 {
228     					return InventoryType;
229     				}
230     			
231  		
232  	    public String toString() {
233             return
234             	super.toString() + "[" +
235             	
236 		              			"Id = " + String.valueOf(getId()
237  	) + " | " + 
238 		              		
239 		              			"PrimaryAmmo = " + String.valueOf(getPrimaryAmmo()
240  	) + " | " + 
241 		              		
242 		              			"SecondaryAmmo = " + String.valueOf(getSecondaryAmmo()
243  	) + " | " + 
244 		              		
245 		              			"InventoryType = " + String.valueOf(getInventoryType()
246  	) + " | " + 
247 		              		
248 				"]";           		
249         }
250  	
251  		
252  		public String toHtmlString() {
253  			return super.toString() + "[<br/>" +
254             	
255 		              			"<b>Id</b> = " + String.valueOf(getId()
256  	) + " <br/> " + 
257 		              		
258 		              			"<b>PrimaryAmmo</b> = " + String.valueOf(getPrimaryAmmo()
259  	) + " <br/> " + 
260 		              		
261 		              			"<b>SecondaryAmmo</b> = " + String.valueOf(getSecondaryAmmo()
262  	) + " <br/> " + 
263 		              		
264 		              			"<b>InventoryType</b> = " + String.valueOf(getInventoryType()
265  	) + " <br/> " + 
266 		              		
267 				"<br/>]";     
268 		}
269  	 
270  	    public String toJsonLiteral() {
271             return "WeaponUpdate(null, "
272             		
273                    + ")";
274         }
275  	
276  		
277  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
278         	
279 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
280 		
281 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
282 	        
283 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---        	            	
284  	
285 		}
286