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 GIVERES.
19           		
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Aynchronous message. Response to GIVE command. Here we get the information about the result of our GIVE command. 
25  	
26           */
27   	public class GiveItemResult 
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      		"GIVERES {TargetId unreal_id}  {ItemId unreal_id}  {ItemType text}  {Result False}  {Reason text} ";
36      
37      	
38      	
39      	/**
40      	 * Parameter-less contructor for the message.
41      	 */
42  		public GiveItemResult()
43  		{
44  		}
45  	
46      	
47      	
48      	
49      	/**
50  		 * Creates new instance of the message GiveItemResult.
51  		 * 
52  		Aynchronous message. Response to GIVE command. Here we get the information about the result of our GIVE command. 
53  	
54  		 * Corresponding GameBots message
55  		 *   
56  		 *   is
57  		 *   GIVERES.
58  		 * 
59   	  	 * 
60  		 *   
61  		 *     @param TargetId 
62  			An Id of the bot we tried to send item to.
63  		
64  		 *   
65  		 * 
66  		 *   
67  		 *     @param ItemId 
68  			If the command was a success then here we receive Id of the item that was given to bot.
69  		
70  		 *   
71  		 * 
72  		 *   
73  		 *     @param ItemType 
74  			Class of the item we wanted to give to the bot.
75  		
76  		 *   
77  		 * 
78  		 *   
79  		 *     @param Result 
80  		Boolean result containing whether the give command was successful.			
81  		
82  		 *   
83  		 * 
84  		 *   
85  		 *     @param Reason 
86  			String reason why the give command was or wasn't successful. Can be BOT_NOT_FOUND_OR_BOT_PAWN_NONE, MAX_DISTANCE_EXCEEDED, WRONG_ITEM_TYPE and SUCCESS.
87  		
88  		 *   
89  		 * 
90  		 */
91  		public GiveItemResult(
92  			UnrealId TargetId,  UnrealId ItemId,  String ItemType,  Boolean Result,  String Reason
93  		) {
94  			
95  					this.TargetId = TargetId;
96  				
97  					this.ItemId = ItemId;
98  				
99  					this.ItemType = ItemType;
100 				
101 					this.Result = Result;
102 				
103 					this.Reason = Reason;
104 				
105 		}
106     
107     	/**
108 		 * Cloning constructor from the full message.
109 		 *
110 		 * @param original
111 		 */
112 		public GiveItemResult(GiveItemResult original) {		
113 			
114 					this.TargetId = original.getTargetId()
115  	;
116 				
117 					this.ItemId = original.getItemId()
118  	;
119 				
120 					this.ItemType = original.getItemType()
121  	;
122 				
123 					this.Result = original.isResult()
124  	;
125 				
126 					this.Reason = original.getReason()
127  	;
128 				
129 			this.SimTime = original.getSimTime();			
130 		}
131 		
132 	   		
133 			protected long SimTime;
134 				
135 			/**
136 			 * Simulation time in MILLI SECONDS !!!
137 			 */	
138 			@Override
139 			public long getSimTime() {
140 				return SimTime;
141 			}
142 						
143 			/**
144 			 * Used by Yylex to slip correct time of the object or programmatically.
145 			 */
146 			protected void setSimTime(long SimTime) {
147 				this.SimTime = SimTime;
148 			}
149 	   	
150     	
151 	    /**
152          * 
153 			An Id of the bot we tried to send item to.
154 		 
155          */
156         protected
157          UnrealId TargetId =
158        	null;
159 	
160  		/**
161          * 
162 			An Id of the bot we tried to send item to.
163 		 
164          */
165         public  UnrealId getTargetId()
166  	 {
167     					return TargetId;
168     				}
169     			
170     	
171 	    /**
172          * 
173 			If the command was a success then here we receive Id of the item that was given to bot.
174 		 
175          */
176         protected
177          UnrealId ItemId =
178        	null;
179 	
180  		/**
181          * 
182 			If the command was a success then here we receive Id of the item that was given to bot.
183 		 
184          */
185         public  UnrealId getItemId()
186  	 {
187     					return ItemId;
188     				}
189     			
190     	
191 	    /**
192          * 
193 			Class of the item we wanted to give to the bot.
194 		 
195          */
196         protected
197          String ItemType =
198        	null;
199 	
200  		/**
201          * 
202 			Class of the item we wanted to give to the bot.
203 		 
204          */
205         public  String getItemType()
206  	 {
207     					return ItemType;
208     				}
209     			
210     	
211 	    /**
212          * 
213 		Boolean result containing whether the give command was successful.			
214 		 
215          */
216         protected
217          Boolean Result =
218        	null;
219 	
220  		/**
221          * 
222 		Boolean result containing whether the give command was successful.			
223 		 
224          */
225         public  Boolean isResult()
226  	 {
227     					return Result;
228     				}
229     			
230     	
231 	    /**
232          * 
233 			String reason why the give command was or wasn't successful. Can be BOT_NOT_FOUND_OR_BOT_PAWN_NONE, MAX_DISTANCE_EXCEEDED, WRONG_ITEM_TYPE and SUCCESS.
234 		 
235          */
236         protected
237          String Reason =
238        	null;
239 	
240  		/**
241          * 
242 			String reason why the give command was or wasn't successful. Can be BOT_NOT_FOUND_OR_BOT_PAWN_NONE, MAX_DISTANCE_EXCEEDED, WRONG_ITEM_TYPE and SUCCESS.
243 		 
244          */
245         public  String getReason()
246  	 {
247     					return Reason;
248     				}
249     			
250  		
251  	    public String toString() {
252             return
253             	super.toString() + "[" +
254             	
255 		              			"TargetId = " + String.valueOf(getTargetId()
256  	) + " | " + 
257 		              		
258 		              			"ItemId = " + String.valueOf(getItemId()
259  	) + " | " + 
260 		              		
261 		              			"ItemType = " + String.valueOf(getItemType()
262  	) + " | " + 
263 		              		
264 		              			"Result = " + String.valueOf(isResult()
265  	) + " | " + 
266 		              		
267 		              			"Reason = " + String.valueOf(getReason()
268  	) + " | " + 
269 		              		
270 				"]";           		
271         }
272  	
273  		
274  		public String toHtmlString() {
275  			return super.toString() + "[<br/>" +
276             	
277 		              			"<b>TargetId</b> = " + String.valueOf(getTargetId()
278  	) + " <br/> " + 
279 		              		
280 		              			"<b>ItemId</b> = " + String.valueOf(getItemId()
281  	) + " <br/> " + 
282 		              		
283 		              			"<b>ItemType</b> = " + String.valueOf(getItemType()
284  	) + " <br/> " + 
285 		              		
286 		              			"<b>Result</b> = " + String.valueOf(isResult()
287  	) + " <br/> " + 
288 		              		
289 		              			"<b>Reason</b> = " + String.valueOf(getReason()
290  	) + " <br/> " + 
291 		              		
292 				"<br/>]";     
293 		}
294  	 
295  	    public String toJsonLiteral() {
296             return "GiveItemResult(null, "
297             		
298                    + ")";
299         }
300  	
301  		
302  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
303         	
304 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
305 		
306 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
307 	        
308 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---        	            	
309  	
310 		}
311