Phoenix2D-Library  0.10
Command.cpp
Go to the documentation of this file.
1 /*
2  * Phoenix2D (RoboCup Soccer Simulation 2D League)
3  * Copyright (c) 2013 Ivan Gonzalez
4  *
5  * This file is part of Phoenix2D.
6  *
7  * Phoenix2D is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * Phoenix2D is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Phoenix2D. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include "Command.h"
22 #include "Game.h"
23 #include <iostream>
24 namespace Phoenix
25 {
27  command = "(error)";
28  weight = 1;
29  type = EMPTY;
30  double_arg_0 = 0.0;
31  double_arg_1 = 0.0;
32  string_arg_0 = "";
33  string_arg_1 = "";
34  bool_arg_0 = "";
35  bool_arg_1 = "";
36  status = ERROR;
37  simulation_time = 0;
38 }
39 
40 Command::Command(std::string command, int weight, COMMAND_TYPE type) { //, void* ... args) {
41  this->command = command;
42  this->weight = weight;
43  this->type = type;
44  double_arg_0 = 0.0;
45  double_arg_1 = 0.0;
46  string_arg_0 = "";
47  string_arg_1 = "";
48  bool_arg_0 = false;
49  bool_arg_1 = false;
50  status = CREATED;
52 }
53 
55 
56 }
57 
58 void Command::setArgs(void* arg0, void* arg1, void* arg2) {
59  switch(type) {
60  case MOVE:
61  case DASH:
62  case KICK:
63  case POINT:
64  if (arg0) double_arg_0 = *((double *)arg0);
65  if (arg1) double_arg_1 = *((double *)arg1);
66  break;
67  case TURN:
68  case CATCH:
69  case TURN_NECK:
70  if (arg0) double_arg_0 = *((double *)arg0);
71  break;
72  case SAY:
73  case CHANGE_VIEW:
74  if (arg0) string_arg_0 = *((std::string *)arg0);
75  break;
76  case TACKLE:
77  if (arg0) double_arg_0 = *((double *)arg0);
78  if (arg1) bool_arg_1 = *((bool *)arg1);
79  break;
80  default:
81  break;
82  }
83 }
84 
85 std::string Command::getCommand() {
86  return command;
87 }
88 
90  return weight;
91 }
92 
94  return type;
95 }
96 
98  return double_arg_0;
99 }
100 
102  return double_arg_1;
103 }
104 
106  return double_arg_0;
107 }
108 
110  return double_arg_0;
111 }
112 
114  return double_arg_1;
115 }
116 
117 std::string Command::getSayMessage() {
118  return string_arg_0;
119 }
120 
122  return double_arg_0;
123 }
124 
126  return double_arg_0;
127 }
128 
130  return double_arg_1;
131 }
132 
134  return double_arg_0;
135 }
136 
138  return bool_arg_1;
139 }
140 
142  return double_arg_0;
143 }
144 
146  return double_arg_0;
147 }
148 
150  return double_arg_1;
151 }
152 
154  return string_arg_0;
155 }
156 
158  this->status = status;
159 }
160 
162  return status;
163 }
164 
166  return simulation_time;
167 }
168 }
Used by Player and Goalie.
Definition: Command.h:56
std::string string_arg_1
Definition: Command.h:78
COMMAND_STATUS status
Definition: Command.h:74
double getTurnMoment()
Definition: Command.cpp:105
double getKickPower()
Definition: Command.cpp:125
Used by Player and Goalie.
Definition: Command.h:53
Used by Player and Goalie.
Definition: Command.h:50
Used by Player and Goalie.
Definition: Command.h:52
COMMAND_TYPE
COMMAND_TYPE The Command type lorem Ipsum
Definition: Command.h:47
double getMoveY()
Definition: Command.cpp:113
double getMoveX()
Definition: Command.cpp:109
Used by Player and Goalie.
Definition: Command.h:57
double getKickDirection()
Definition: Command.cpp:129
double double_arg_0
Definition: Command.h:75
COMMAND_STATUS getCommandStatus()
Definition: Command.cpp:161
double double_arg_1
Definition: Command.h:76
std::string getChangeViewWidth()
Definition: Command.cpp:153
std::string string_arg_0
Definition: Command.h:77
int simulation_time
Definition: Command.h:81
double getTacklePower()
Definition: Command.cpp:133
Used by Player and Goalie.
Definition: Command.h:49
bool getTackleWillToFoul()
Definition: Command.cpp:137
double getDashPower()
Definition: Command.cpp:97
double getDashDirection()
Definition: Command.cpp:101
COMMAND_STATUS
COMMAND_STATUS The Command type lorem Ipsum
Definition: Command.h:36
Used by Player and Goalie.
Definition: Command.h:51
std::string getSayMessage()
Definition: Command.cpp:117
Used by Player and Goalie.
Definition: Command.h:48
void changeStatusTo(COMMAND_STATUS status)
Definition: Command.cpp:157
void setArgs(void *arg0, void *arg1=0, void *arg2=0)
Definition: Command.cpp:58
std::string command
Definition: Command.h:71
COMMAND_TYPE getCommandType()
Definition: Command.cpp:93
Used by Player and Goalie.
Definition: Command.h:55
double getCatchDirection()
Definition: Command.cpp:121
bool bool_arg_1
Definition: Command.h:80
bool bool_arg_0
Definition: Command.h:79
Used by Player and Goalie.
Definition: Command.h:58
Used by Player and Goalie.
Definition: Command.h:54
std::string getCommand()
Definition: Command.cpp:85
static unsigned int SIMULATION_TIME
Definition: Game.h:38
double getPointDirection()
Definition: Command.cpp:149
double getTurnNeckMoment()
Definition: Command.cpp:141
double getPointDistance()
Definition: Command.cpp:145
COMMAND_TYPE type
Definition: Command.h:73