1 package cz.cuni.amis.pogamut.ut2004.bot.command;
2
3 import java.util.logging.Logger;
4
5 import cz.cuni.amis.pogamut.ut2004.agent.module.sensomotoric.Weaponry;
6 import cz.cuni.amis.pogamut.ut2004.bot.IUT2004BotController;
7 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
8
9 /**
10 * Creates and wraps all available command modules. These command modules
11 * contains documented methods that wraps Pogamut commands. For example simple
12 * locomotion provides methods for basic bot movement in the environment.
13 * <p><p>
14 * It is designed to be initialized inside {@link IUT2004BotController#prepareBot(UT2004Bot)} method call
15 * and may be used since since the first {@link IUT2004BotController#botFirstSpawn(cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GameInfo, ConfigChange, InitedMessage, Self)}
16 * is called.
17 *
18 * @author Knight
19 */
20 public class CompleteBotCommandsWrapper {
21
22 // Pointers to command modules, will be initialized in the constructor.
23
24 Action action;
25
26 AdvancedLocomotion locomotion;
27
28 AdvancedShooting shooting;
29
30 ImprovedShooting improvedShooting;
31
32 Communication communication;
33
34 ConfigureCommands configureCommands;
35
36 SimpleRayCasting simpleRayCasting;
37
38 Logger log;
39
40 /**
41 * Returns {@link cz.cuni.amis.pogamut.ut2004.bot.commands.Action} command
42 * module.
43 *
44 * @return action command module
45 */
46 public Action getAction() {
47 return action;
48 }
49
50 /**
51 * Returns
52 * {@link cz.cuni.amis.pogamut.ut2004.bot.commands.AdvancedLocomotion}
53 * command module.
54 *
55 * @return advanced locomotion command module
56 */
57 public AdvancedLocomotion getLocomotion() {
58 return locomotion;
59 }
60
61 /**
62 * Returns {@link cz.cuni.amis.pogamut.ut2004.bot.commands.AdvancedShooting}
63 * command module.
64 *
65 * @return advanced shooting command module
66 */
67 public AdvancedShooting getShooting() {
68 return shooting;
69 }
70
71 /**
72 * Returns {@link cz.cuni.amis.pogamut.ut2004.bot.commands.Communication}
73 * command module.
74 *
75 * @return communication command module
76 */
77 public Communication getCommunication() {
78 return communication;
79 }
80
81 /**
82 * Returns
83 * {@link cz.cuni.amis.pogamut.ut2004.bot.commands.ConfigureCommands}
84 * command module.
85 *
86 * @return configure commands command module
87 */
88 public ConfigureCommands getConfigureCommands() {
89 return configureCommands;
90 }
91
92 /**
93 * Returns {@link cz.cuni.amis.pogamut.ut2004.bot.commands.SimpleRayCasting}
94 * command module.
95 *
96 * @return simple ray casting command module
97 */
98 public SimpleRayCasting getSimpleRayCasting() {
99 return simpleRayCasting;
100 }
101
102 /**
103 * Constructor. Setups the command module based on given agent.
104 *
105 * @param agent
106 * AbstractUT2004Bot we will send commands for
107 */
108 public CompleteBotCommandsWrapper(UT2004Bot agent) {
109 this(agent, new Weaponry(agent), null);
110 }
111
112 /**
113 * Constructor. Setups the command module based on given agent and logger.
114 *
115 * @param agent
116 * AbstractUT2004Bot we will send commands for
117 * @param log
118 * Logger to be used for logging runtime/debug info.
119 */
120 public CompleteBotCommandsWrapper(UT2004Bot agent, Weaponry weaponry, Logger log) {
121
122 // initialize command modules
123 this.log = log;
124 if (this.log == null) {
125 this.log = agent.getLogger().getCategory("Commands");
126 }
127 action = new Action(agent, log);
128 locomotion = new AdvancedLocomotion(agent, log);
129 shooting = new AdvancedShooting(agent, log);
130 improvedShooting = new ImprovedShooting(weaponry, agent, log);
131 communication = new Communication(agent, log);
132 configureCommands = new ConfigureCommands(agent, log);
133 simpleRayCasting = new SimpleRayCasting(agent, log);
134 }
135
136 public Logger getLog() {
137 return log;
138 }
139
140 /**
141 * Returns {@link ImprovedShooting}.
142 * @return
143 */
144 public ImprovedShooting getImprovedShooting() {
145 return improvedShooting;
146 }
147 }