View Javadoc

1   package javabot;
2   
3   import java.lang.reflect.Method;
4   
5   /**
6    * Caches all methods inside JBot for an easier retrieval for reflection.
7    * 
8    * @author Radek 'Black_Hand' Pibil
9    * 
10   */
11  public class JBotMethodsRepository {
12  
13  	private static Method getDefcon;
14  	private static Method getGameTime;
15  	private static Method getGameTick;
16  	private static Method getGameSpeed;
17  	private static Method getVictoryTimer;
18  	private static Method isVictoryTimerActive;
19  	private static Method getOptionValue;
20  	private static Method getCityIds;
21  	private static Method getCityPopulation;
22  	private static Method getRemainingPopulation;
23  	private static Method isValidTerritory;
24  	private static Method isBorder;
25  	private static Method getTerritoryId;
26  	private static Method getOwnTeamId;
27  	private static Method getTeamIds;
28  	private static Method getTeamTerritoriesCount;
29  	private static Method getTeamTerritories;
30  	private static Method getAllianceId;
31  	private static Method getDesiredGameSpeed;
32  	private static Method getEnemyKills;
33  	private static Method getFriendlyDeaths;
34  	private static Method getCollateralDamage;
35  	private static Method getTeamName;
36  	private static Method isSharingRadar;
37  	private static Method isCeaseFire;
38  	private static Method requestAlliance;
39  	private static Method requestCeaseFire;
40  	private static Method requestShareRadar;
41  	private static Method requestGameSpeed;
42  	private static Method getAllUnits;
43  	private static Method getOwnUnits;
44  	private static Method getTeamUnits;
45  	private static Method getAllUnitData;
46  	private static Method getType;
47  	private static Method getTeamId;
48  	private static Method getOwnFleets;
49  	private static Method getFleets;
50  	private static Method getFleetMembers;
51  	private static Method getFleetId;
52  	private static Method getCurrentState;
53  	private static Method getStateCount;
54  	private static Method getStateTimer;
55  	private static Method getActionQueue;
56  	private static Method getCurrentTargetId;
57  	private static Method getMovementTargetLocation;
58  	private static Method getNukeSupply;
59  	private static Method getBomberNukeTarget;
60  	private static Method isRetaliating;
61  	private static Method isVisible;
62  	private static Method setState;
63  	private static Method setMovementTarget;
64  	private static Method setActionTarget;
65  	private static Method setLandingTarget;
66  	private static Method getLongitude;
67  	private static Method getLatitude;
68  	private static Method getVelocity;
69  	private static Method getRange;
70  	private static Method getRemainingUnits;
71  	private static Method isValidPlacementLocation;
72  	private static Method getFleetMemberOffset;
73  	private static Method placeStructure;
74  	private static Method placeFleet;
75  	private static Method getUnitCredits;
76  	private static Method getUnitValue;
77  	private static Method sendVote;
78  	private static Method sendChatMessage;
79  	private static Method getDistance;
80  	private static Method getSailDistance;
81  	private static Method debugLog0;
82  	private static Method debugLog1;
83  	private static Method debugLog2;
84  	private static Method debugLog3;
85  	private static Method debugLog4;
86  	private static Method debugIsReplayingGame;
87  	private static Method whiteboardDraw;
88  	private static Method whiteboardClear;
89  	private static Method getSuccessfulCommands;
90  	private static Method writeToConsole;
91  
92  	static {
93  		try {
94  			getDefcon = JBot.class.getDeclaredMethod("GetDefcon");
95  			getGameTime = JBot.class.getDeclaredMethod("GetGameTime");
96  			getGameTick = JBot.class.getDeclaredMethod("GetGameTick");
97  			getGameSpeed = JBot.class.getDeclaredMethod("GetGameSpeed");
98  			getVictoryTimer = JBot.class.getDeclaredMethod("GetVictoryTimer");
99  			isVictoryTimerActive = JBot.class
100 					.getDeclaredMethod("IsVictoryTimerActive");
101 			getOptionValue = JBot.class.getDeclaredMethod(
102 					"GetOptionValue",
103 					String.class);
104 			getCityIds = JBot.class.getDeclaredMethod("GetCityIds");
105 			getCityPopulation = JBot.class
106 					.getDeclaredMethod("GetCityPopulation", int.class);
107 			getRemainingPopulation = JBot.class.getDeclaredMethod(
108 					"GetRemainingPopulation",
109 					int.class);
110 			isValidTerritory = JBot.class.getDeclaredMethod("IsValidTerritory",
111 					int.class, float.class, float.class, boolean.class);
112 			isBorder = JBot.class.getDeclaredMethod(
113 					"IsBorder",
114 					float.class,
115 					float.class);
116 			getTerritoryId = JBot.class.getDeclaredMethod("GetTerritoryId",
117 					float.class,
118 					float.class);
119 			getOwnTeamId = JBot.class.getDeclaredMethod("GetOwnTeamId");
120 			getTeamIds = JBot.class.getDeclaredMethod("GetTeamIds");
121 			getTeamTerritoriesCount = JBot.class.getDeclaredMethod(
122 					"GetTeamTerritoriesCount",
123 					int.class);
124 			getTeamTerritories = JBot.class.getDeclaredMethod(
125 					"GetTeamTerritories",
126 					int.class);
127 			getAllianceId = JBot.class.getDeclaredMethod("GetAllianceId",
128 					int.class);
129 			getDesiredGameSpeed = JBot.class.getDeclaredMethod(
130 					"GetDesiredGameSpeed",
131 					int.class);
132 			getEnemyKills = JBot.class.getDeclaredMethod(
133 					"GetEnemyKills",
134 					int.class);
135 			getFriendlyDeaths = JBot.class.getDeclaredMethod(
136 					"GetFriendlyDeaths",
137 					int.class);
138 			getCollateralDamage = JBot.class.getDeclaredMethod(
139 					"GetCollateralDamage",
140 					int.class);
141 			getTeamName = JBot.class.getDeclaredMethod("GetTeamName",
142 					int.class);
143 			isSharingRadar = JBot.class.getDeclaredMethod("IsSharingRadar",
144 					int.class,
145 					int.class);
146 			isCeaseFire = JBot.class.getDeclaredMethod("IsCeaseFire",
147 					int.class,
148 					int.class);
149 			requestAlliance = JBot.class.getDeclaredMethod("RequestAlliance",
150 					int.class);
151 			requestCeaseFire = JBot.class.getDeclaredMethod("RequestCeaseFire",
152 					int.class);
153 			requestShareRadar = JBot.class.getDeclaredMethod(
154 					"RequestShareRadar",
155 					int.class);
156 			requestGameSpeed = JBot.class.getDeclaredMethod("RequestGameSpeed",
157 					int.class);
158 			getAllUnits = JBot.class.getDeclaredMethod("GetAllUnits");
159 			getOwnUnits = JBot.class.getDeclaredMethod("GetOwnUnits");
160 			getTeamUnits = JBot.class.getDeclaredMethod(
161 					"GetTeamUnits",
162 					int.class);
163 			getAllUnitData = JBot.class.getDeclaredMethod("GetAllUnitData");
164 			getType = JBot.class.getDeclaredMethod("GetType", int.class);
165 			getTeamId = JBot.class
166 					.getDeclaredMethod("GetTeamId", int.class);
167 			getOwnFleets = JBot.class.getDeclaredMethod("GetOwnFleets");
168 			getFleets = JBot.class.getDeclaredMethod("GetFleets",
169 					int.class);
170 			getFleetMembers = JBot.class.getDeclaredMethod("GetFleetMembers",
171 					int.class);
172 			getFleetId = JBot.class.getDeclaredMethod("GetFleetId",
173 					int.class);
174 			getCurrentState = JBot.class.getDeclaredMethod("GetCurrentState",
175 					int.class);
176 			getStateCount = JBot.class.getDeclaredMethod("GetStateCount",
177 					int.class,
178 					int.class);
179 			getStateTimer = JBot.class.getDeclaredMethod("GetStateTimer",
180 					int.class);
181 			getActionQueue = JBot.class.getDeclaredMethod("GetActionQueue",
182 					int.class);
183 			getCurrentTargetId = JBot.class.getDeclaredMethod(
184 					"GetCurrentTargetId",
185 					int.class);
186 			getMovementTargetLocation = JBot.class.getDeclaredMethod(
187 					"GetMovementTargetLocation",
188 					int.class);
189 			getNukeSupply = JBot.class.getDeclaredMethod("GetNukeSupply",
190 					int.class);
191 			getBomberNukeTarget = JBot.class.getDeclaredMethod(
192 					"GetBomberNukeTarget",
193 					int.class);
194 			isRetaliating = JBot.class.getDeclaredMethod("IsRetaliating",
195 					int.class);
196 			isVisible = JBot.class.getDeclaredMethod("IsVisible",
197 					int.class, int.class);
198 			setState = JBot.class.getDeclaredMethod("SetState",
199 					int.class, int.class);
200 			setMovementTarget = JBot.class.getDeclaredMethod(
201 					"SetMovementTarget",
202 					int.class,
203 					float.class,
204 					float.class);
205 			setActionTarget = JBot.class.getDeclaredMethod("SetActionTarget",
206 					int.class,
207 					int.class,
208 					float.class,
209 					float.class);
210 			setLandingTarget = JBot.class.getDeclaredMethod("SetLandingTarget",
211 					int.class,
212 					int.class);
213 			getLongitude = JBot.class.getDeclaredMethod("GetLongitude",
214 					int.class);
215 			getLatitude = JBot.class.getDeclaredMethod("GetLatitude",
216 					int.class);
217 			getVelocity = JBot.class.getDeclaredMethod("GetVelocity",
218 					int.class);
219 			getRange = JBot.class.getDeclaredMethod("GetRange",
220 					int.class);
221 			getRemainingUnits = JBot.class.getDeclaredMethod(
222 					"GetRemainingUnits",
223 					int.class);
224 
225 			isValidPlacementLocation = JBot.class.getDeclaredMethod(
226 					"IsValidPlacementLocation",
227 					float.class,
228 					float.class,
229 					int.class);
230 
231 			/*
232 			 * isValidPlacementLocation = GameInfo.class.getDeclaredMethod(
233 			 * "isValidPlacementLocationWorker", float.class, float.class,
234 			 * UnitType.class);
235 			 */
236 			getFleetMemberOffset = JBot.class.getDeclaredMethod(
237 					"GetFleetMemberOffset",
238 					int.class,
239 					int.class);
240 			placeStructure = JBot.class.getDeclaredMethod("PlaceStructure",
241 					int.class,
242 					float.class,
243 					float.class);
244 			placeFleet = JBot.class.getDeclaredMethod("PlaceFleet",
245 					float.class,
246 					float.class,
247 					int[].class);
248 			getUnitCredits = JBot.class.getDeclaredMethod("GetUnitCredits");
249 			getUnitValue = JBot.class.getDeclaredMethod("GetUnitValue",
250 					int.class);
251 			sendVote = JBot.class.getDeclaredMethod(
252 					"SendVote",
253 					int.class,
254 					int.class);
255 			sendChatMessage = JBot.class.getDeclaredMethod("SendChatMessage",
256 					String.class,
257 					int.class);
258 			getDistance = JBot.class.getDeclaredMethod("GetDistance",
259 					float.class,
260 					float.class,
261 					float.class,
262 					float.class);
263 			getSailDistance = JBot.class.getDeclaredMethod("GetSailDistance",
264 					float.class,
265 					float.class,
266 					float.class,
267 					float.class);
268 			debugLog0 = JBot.class.getDeclaredMethod("DebugLog", String.class);
269 			debugLog1 = JBot.class.getDeclaredMethod("DebugLog", String.class,
270 					int.class);
271 			debugLog2 = JBot.class.getDeclaredMethod(
272 					"DebugLog",
273 					String.class,
274 					int.class,
275 					String.class);
276 			debugLog3 = JBot.class.getDeclaredMethod("DebugLog",
277 					String.class,
278 					int.class,
279 					String.class,
280 					int.class,
281 					int.class,
282 					int.class);
283 			debugLog4 = JBot.class.getDeclaredMethod("DebugLog",
284 					String.class,
285 					int.class,
286 					String.class,
287 					int.class,
288 					int.class,
289 					int.class,
290 					int.class);
291 			debugIsReplayingGame = JBot.class
292 					.getDeclaredMethod("DebugIsReplayingGame");
293 			whiteboardDraw = JBot.class.getDeclaredMethod("WhiteboardDraw",
294 					float.class,
295 					float.class,
296 					float.class,
297 					float.class);
298 			whiteboardClear = JBot.class.getDeclaredMethod("WhiteboardClear");
299 			getSuccessfulCommands = JBot.class
300 					.getDeclaredMethod("GetSuccessfulCommands");
301 			writeToConsole = JBot.class.getDeclaredMethod("WriteToConsole",
302 					String.class);
303 		} catch (SecurityException e) {
304 			// TODO Auto-generated catch block
305 			e.printStackTrace();
306 		} catch (NoSuchMethodException e) {
307 			// TODO Auto-generated catch block
308 			e.printStackTrace();
309 		}
310 	}
311 
312 	public static final Method GetDefcon() {
313 		return getDefcon;
314 	}
315 
316 	public static final Method GetGameTime() {
317 		return getGameTime;
318 	}
319 
320 	public static final Method GetGameTick() {
321 		return getGameTick;
322 	}
323 
324 	public static final Method GetGameSpeed() {
325 		return getGameSpeed;
326 	}
327 
328 	public static final Method GetVictoryTimer() {
329 		return getVictoryTimer;
330 	}
331 
332 	public static final Method IsVictoryTimerActive() {
333 		return isVictoryTimerActive;
334 	}
335 
336 	public static final Method GetOptionValue() {
337 		return getOptionValue;
338 	}
339 
340 	public static final Method GetCityIds() {
341 		return getCityIds;
342 	}
343 
344 	public static final Method GetCityPopulation() {
345 		return getCityPopulation;
346 	}
347 
348 	public static final Method GetRemainingPopulation() {
349 		return getRemainingPopulation;
350 	}
351 
352 	public static final Method IsValidTerritory() {
353 		return isValidTerritory;
354 	}
355 
356 	public static final Method IsBorder() {
357 		return isBorder;
358 	}
359 
360 	public static final Method GetTerritoryId() {
361 		return getTerritoryId;
362 	}
363 
364 	public static final Method GetOwnTeamId() {
365 		return getOwnTeamId;
366 	}
367 
368 	public static final Method GetTeamIds() {
369 		return getTeamIds;
370 	}
371 
372 	public static final Method GetTeamTerritoriesCount() {
373 		return getTeamTerritoriesCount;
374 	}
375 
376 	public static final Method GetTeamTerritories() {
377 		return getTeamTerritories;
378 	}
379 
380 	public static final Method GetAllianceId() {
381 		return getAllianceId;
382 	}
383 
384 	public static final Method GetDesiredGameSpeed() {
385 		return getDesiredGameSpeed;
386 	}
387 
388 	public static final Method GetEnemyKills() {
389 		return getEnemyKills;
390 	}
391 
392 	public static final Method GetFriendlyDeaths() {
393 		return getFriendlyDeaths;
394 	}
395 
396 	public static final Method GetCollateralDamage() {
397 		return getCollateralDamage;
398 	}
399 
400 	public static final Method GetTeamName() {
401 		return getTeamName;
402 	}
403 
404 	public static final Method IsSharingRadar() {
405 		return isSharingRadar;
406 	}
407 
408 	public static final Method IsCeaseFire() {
409 		return isCeaseFire;
410 	}
411 
412 	public static final Method RequestAlliance() {
413 		return requestAlliance;
414 	}
415 
416 	public static final Method RequestCeaseFire() {
417 		return requestCeaseFire;
418 	}
419 
420 	public static final Method RequestShareRadar() {
421 		return requestShareRadar;
422 	}
423 
424 	public static final Method RequestGameSpeed() {
425 		return requestGameSpeed;
426 	}
427 
428 	public static final Method GetAllUnits() {
429 		return getAllUnits;
430 	}
431 
432 	public static final Method GetOwnUnits() {
433 		return getOwnUnits;
434 	}
435 
436 	public static final Method GetTeamUnits() {
437 		return getTeamUnits;
438 	}
439 
440 	public static final Method GetAllUnitData() {
441 		return getAllUnitData;
442 	}
443 
444 	public static final Method GetType() {
445 		return getType;
446 	}
447 
448 	public static final Method GetTeamId() {
449 		return getTeamId;
450 	}
451 
452 	public static final Method GetOwnFleets() {
453 		return getOwnFleets;
454 	}
455 
456 	public static final Method GetFleets() {
457 		return getFleets;
458 	}
459 
460 	public static final Method GetFleetMembers() {
461 		return getFleetMembers;
462 	}
463 
464 	public static final Method GetFleetId() {
465 		return getFleetId;
466 	}
467 
468 	public static final Method GetCurrentState() {
469 		return getCurrentState;
470 	}
471 
472 	public static final Method GetStateCount() {
473 		return getStateCount;
474 	}
475 
476 	public static final Method GetStateTimer() {
477 		return getStateTimer;
478 	}
479 
480 	public static final Method GetActionQueue() {
481 		return getActionQueue;
482 	}
483 
484 	public static final Method GetCurrentTargetId() {
485 		return getCurrentTargetId;
486 	}
487 
488 	public static final Method GetMovementTargetLocation() {
489 		return getMovementTargetLocation;
490 	}
491 
492 	public static final Method GetNukeSupply() {
493 		return getNukeSupply;
494 	}
495 
496 	public static final Method GetBomberNukeTarget() {
497 		return getBomberNukeTarget;
498 	}
499 
500 	public static final Method IsRetaliating() {
501 		return isRetaliating;
502 	}
503 
504 	public static final Method IsVisible() {
505 		return isVisible;
506 	}
507 
508 	public static final Method SetState() {
509 		return setState;
510 	}
511 
512 	public static final Method SetMovementTarget() {
513 		return setMovementTarget;
514 	}
515 
516 	public static final Method SetActionTarget() {
517 		return setActionTarget;
518 	}
519 
520 	public static final Method SetLandingTarget() {
521 		return setLandingTarget;
522 	}
523 
524 	public static final Method GetLongitude() {
525 		return getLongitude;
526 	}
527 
528 	public static final Method GetLatitude() {
529 		return getLatitude;
530 	}
531 
532 	public static final Method GetVelocity() {
533 		return getVelocity;
534 	}
535 
536 	public static final Method GetRange() {
537 		return getRange;
538 	}
539 
540 	public static final Method GetRemainingUnits() {
541 		return getRemainingUnits;
542 	}
543 
544 	public static final Method IsValidPlacementLocation() {
545 		return isValidPlacementLocation;
546 	}
547 
548 	public static final Method GetFleetMemberOffset() {
549 		return getFleetMemberOffset;
550 	}
551 
552 	public static final Method PlaceStructure() {
553 		return placeStructure;
554 	}
555 
556 	public static final Method PlaceFleet() {
557 		return placeFleet;
558 	}
559 
560 	public static final Method GetUnitCredits() {
561 		return getUnitCredits;
562 	}
563 
564 	public static final Method GetUnitValue() {
565 		return getUnitValue;
566 	}
567 
568 	public static final Method SendVote() {
569 		return sendVote;
570 	}
571 
572 	public static final Method SendChatMessage() {
573 		return sendChatMessage;
574 	}
575 
576 	public static final Method GetDistance() {
577 		return getDistance;
578 	}
579 
580 	public static final Method GetSailDistance() {
581 		return getSailDistance;
582 	}
583 
584 	public static final Method DebugLog0() {
585 		return debugLog0;
586 	}
587 
588 	public static final Method DebugLog1() {
589 		return debugLog1;
590 	}
591 
592 	public static final Method DebugLog2() {
593 		return debugLog2;
594 	}
595 
596 	public static final Method DebugLog3() {
597 		return debugLog3;
598 	}
599 
600 	public static final Method DebugLog4() {
601 		return debugLog4;
602 	}
603 
604 	public static final Method DebugIsReplayingGame() {
605 		return debugIsReplayingGame;
606 	}
607 
608 	public static final Method WhiteboardDraw() {
609 		return whiteboardDraw;
610 	}
611 
612 	public static final Method WhiteboardClear() {
613 		return whiteboardClear;
614 	}
615 
616 	public static final Method GetSuccessfulCommands() {
617 		return getSuccessfulCommands;
618 	}
619 
620 	public static final Method WriteToConsole() {
621 		return writeToConsole;
622 	}
623 }