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=base]+classtype[@name=abstract] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=base]+classtype[@name=abstract] END
15      
16   		/**
17           *  
18              				Abstract definition of the GameBots2004 message MYINV.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		An object in the observed player's inventory.
25      
26           */
27   	public abstract class MyInventory   
28    				extends 
29    				InfoMessage
30    						implements IWorldEvent, IWorldChangeEvent, ICompositeWorldObject
31    						
32  	    {
33   	
34      	/** Example how the message looks like - used during parser tests. */
35      	public static final String PROTOTYPE =
36      		"MYINV {Id unreal_id}  {CurrentAmmo 0}  {CurrentAltAmmo 0}  {Amount 0}  {Type xWeapons.FlakCannonPickup} ";
37      
38      	
39      	
40      	/**
41      	 * Parameter-less contructor for the message.
42      	 */
43  		public MyInventory()
44  		{
45  		}
46  	
47  				// abstract message, it does not have any more constructors				
48  			
49  	   		
50  			protected long SimTime;
51  				
52  			/**
53  			 * Simulation time in MILLI SECONDS !!!
54  			 */	
55  			@Override
56  			public long getSimTime() {
57  				return SimTime;
58  			}
59  						
60  			/**
61  			 * Used by Yylex to slip correct time of the object or programmatically.
62  			 */
63  			protected void setSimTime(long SimTime) {
64  				this.SimTime = SimTime;
65  			}
66  	   	
67   		/**
68           * 
69  			Unique Id of the item. This Id represents the item in the inventory.
70  		 
71           */
72          public abstract UnrealId getId()
73   	;
74  		    			
75   		/**
76           * 
77  			If this item is a weapon, this holds the amount of primary ammo.
78  		 
79           */
80          public abstract int getCurrentAmmo()
81   	;
82  		    			
83   		/**
84           * 
85  			If this item is a weapon, this holds the amount of secondary ammo.
86  		 
87           */
88          public abstract int getCurrentAltAmmo()
89   	;
90  		    			
91   		/**
92           * 
93  			If this item is ammo or armor, this holds the amount of the item the player has.
94  		 
95           */
96          public abstract int getAmount()
97   	;
98  		    			
99   		/**
100          * 
101 			Class of the item (e.g. xWeapons.FlakCannonPickup).
102 		 
103          */
104         public abstract ItemType getType()
105  	;
106 		    			
107  		/**
108          * 
109 			Descriptor of the item - according the ItemType you may cast this to various XYZDescriptor.
110 		 
111          */
112         public abstract ItemDescriptor getDescriptor()
113  	;
114 		    			
115     	
116     	public static class MyInventoryUpdate
117      extends GBObjectUpdate implements ICompositeWorldObjectUpdatedEvent, IGBWorldObjectEvent {	
118 			private MyInventory object;
119 			private long time;
120 			private ITeamId teamId;
121 			
122 			public MyInventoryUpdate
123     (MyInventory source, long eventTime, ITeamId teamId) {
124 				this.object = source;
125 				this.time = eventTime;
126 				this.teamId = teamId;
127 			}
128 			
129 			/**
130 			 * Simulation time in MILLI SECONDS !!!
131 			 */ 
132 			@Override
133 			public long getSimTime() {
134 				return time;
135 			}
136 	
137 			@Override
138 			public IWorldObject getObject() {
139 				return object;
140 			}
141 	
142 			@Override
143 			public WorldObjectId getId() {
144 				return object.getId();
145 			}
146 	
147 			@Override
148 			public ILocalWorldObjectUpdatedEvent getLocalEvent() {
149 				return new MyInventoryLocalImpl.MyInventoryLocalUpdate
150     ((MyInventoryLocal)object.getLocal(), time);
151 			}
152 	
153 			@Override
154 			public ISharedWorldObjectUpdatedEvent getSharedEvent() {
155 				return new MyInventorySharedImpl.MyInventorySharedUpdate
156     ((MyInventoryShared)object.getShared(), time, teamId);
157 			}
158 	
159 			@Override
160 			public IStaticWorldObjectUpdatedEvent getStaticEvent() {
161 				return new MyInventoryStaticImpl.MyInventoryStaticUpdate
162     ((MyInventoryStatic)object.getStatic(), time);
163 			}
164 			
165 		}
166     
167  		
168  	    public String toString() {
169             return
170             	super.toString() + "[" +
171             	
172 		              			"Id = " + String.valueOf(getId()
173  	) + " | " + 
174 		              		
175 		              			"CurrentAmmo = " + String.valueOf(getCurrentAmmo()
176  	) + " | " + 
177 		              		
178 		              			"CurrentAltAmmo = " + String.valueOf(getCurrentAltAmmo()
179  	) + " | " + 
180 		              		
181 		              			"Amount = " + String.valueOf(getAmount()
182  	) + " | " + 
183 		              		
184 		              			"Type = " + String.valueOf(getType()
185  	) + " | " + 
186 		              		
187 				"]";           		
188         }
189  	
190  		
191  		public String toHtmlString() {
192  			return super.toString() + "[<br/>" +
193             	
194 		              			"<b>Id</b> = " + String.valueOf(getId()
195  	) + " <br/> " + 
196 		              		
197 		              			"<b>CurrentAmmo</b> = " + String.valueOf(getCurrentAmmo()
198  	) + " <br/> " + 
199 		              		
200 		              			"<b>CurrentAltAmmo</b> = " + String.valueOf(getCurrentAltAmmo()
201  	) + " <br/> " + 
202 		              		
203 		              			"<b>Amount</b> = " + String.valueOf(getAmount()
204  	) + " <br/> " + 
205 		              		
206 		              			"<b>Type</b> = " + String.valueOf(getType()
207  	) + " <br/> " + 
208 		              		
209 				"<br/>]";     
210 		}
211  	 
212  	    public String toJsonLiteral() {
213             return "MyInventory(null, "
214             		
215                    + ")";
216         }
217  	
218  		
219  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
220         	
221 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
222 		
223 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---
224 	        
225 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---        	            	
226  	
227 		}
228