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