LIBRCSC Docs
Documentation for HELIOS's BASE LIBRCSC library for RoboCup 2D Simulation League.
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
game_mode.h
Go to the documentation of this file.
1// -*-c++-*-
2
8/*
9 *Copyright:
10
11 Copyright (C) Hidehisa AKIYAMA
12
13 This code is free software; you can redistribute it and/or
14 modify it under the terms of the GNU Lesser General Public
15 License as published by the Free Software Foundation; either
16 version 3 of the License, or (at your option) any later version.
17
18 This library is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 Lesser General Public License for more details.
22
23 You should have received a copy of the GNU Lesser General Public
24 License along with this library; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27 *EndCopyright:
28 */
29
31
32#ifndef RCSC_GAME_MODE_H
33#define RCSC_GAME_MODE_H
34
35#include <rcsc/game_time.h>
36#include <rcsc/types.h>
37
38#include <string>
39#include <utility>
40
41namespace rcsc {
42
50class GameMode {
51public:
52
56 enum Type {
57 BeforeKickOff,
58 TimeOver,
59 PlayOn,
60 KickOff_, // Left | Right
61 KickIn_, // Left | Right
62 FreeKick_, // Left | Right
63 CornerKick_, // Left | Right
64 GoalKick_, // Left | Right
65 AfterGoal_, // Left | Right
66 //Drop_Ball, // Left | Right
67 OffSide_, // Left | Right
68 PenaltyKick_, // Left | Right
69 FirstHalfOver,
70 Pause,
71 Human,
72 FoulCharge_, // Left | Right
73 FoulPush_, // Left | Right
74 FoulMultipleAttacker_, // Left | Right
75 FoulBallOut_, // Left | Right
76 BackPass_, // Left | Right
77 FreeKickFault_, // Left | Right
78
79 CatchFault_, // Left | Right
80 IndFreeKick_, // Left | Right
81
82 PenaltySetup_, // Left | Right
83 PenaltyReady_, // Left | Right
84 PenaltyTaken_, // Left | Right
85 PenaltyMiss_, // Left | Right
86 PenaltyScore_, // Left | Right
87
88 IllegalDefense_, // Left | Right
89
90 // not a real playmode
91 PenaltyOnfield_, // next real playmode is PenaltySetup_
92 PenaltyFoul_, // next real playmode is PenaltyMiss_ or PenaltyScore_
93 //PenaltyWinner_, // next real playmode is TimeOver
94 //PenaltyDraw, // next real playmode is TimeOver
95
96 GoalieCatch_, // Left | Right
97 ExtendHalf,
98 MODE_MAX
99 };
100
101
102 /*
103 // normal playmode string
104
105 "before_kick_off"
106 "time_over"
107 "play_on"
108 "kick_off_l"
109 "kick_off_r"
110 "kick_in_l"
111 "kick_in_r"
112 "free_kick_l"
113 "free_kick_r"
114 "corner_kick_l"
115 "corner_kick_r"
116 "goal_kick_l"
117 "goal_kick_r"
118 "goal_l"
119 "goal_r"
120 "drop_ball"
121 "offside_l"
122 "offside_r"
123 "penalty_kick_l"
124 "penalty_kick_r"
125 "first_half_over"
126 "pause"
127 "human_judge"
128 "foul_charge_l"
129 "foul_charge_r"
130 "foul_push_l"
131 "foul_push_r"
132 "foul_multiple_attack_l"
133 "foul_multiple_attack_r"
134 "foul_ballout_l"
135 "foul_ballout_r"
136 "back_pass_l"
137 "back_pass_r"
138 "free_kick_fault_l"
139 "free_kick_fault_r"
140 "catch_fault_l",
141 "catch_fault_r",
142 "indirect_free_kick_l",
143 "indirect_free_kick_r",
144 "penalty_setup_l",
145 "penalty_setup_r",
146 "penalty_ready_l",
147 "penalty_ready_r",
148 "penalty_taken_l",
149 "penalty_taken_r",
150 "penalty_miss_l",
151 "penalty_miss_r",
152 "penalty_score_l",
153 "penalty_score_r"
154
155 // extend playmode
156
157 "goal_l_<SCORE>"
158 "goal_r_<SCORE>"
159 "half_time"
160 "time_extended"
161 "time_up_without_a_team"
162 "time_up"
163 "foul_l" // set by monitor only
164 "foul_r" // set by monitor only
165 "goalie_catch_ball_l"
166 "goalie_catch_ball_r"
167
168 "penalty_onfield_{l|r}"
169 "penalty_foul_{l|r}"
170 "penalty_winner_{l|r}"
171 "penalty_draw"
172
173 // other notification
174
175 "yellow_card_SIDE_UNUM"
176 "red_card_SIDE_UNUM"
177 */
178
179 typedef std::pair< Type, SideID > Pair;
180
181private:
182
184 GameTime M_time;
185
187 Type M_type;
189 SideID M_side;
190
192 int M_score_left;
194 int M_score_right;
195public:
200
205 SideID side,
206 const GameTime & time,
207 int score_left,
208 int score_right );
209
217 bool update( const std::string & mode_str,
218 const GameTime & current );
219
225 void setScore( const int score_l,
226 const int score_r );
227
228private:
234 Pair parse( const std::string & mode_str );
235
236public:
237
242 const GameTime & time() const
243 {
244 return M_time;
245 }
246
251 Type type() const
252 {
253 return M_type;
254 }
255
260 SideID side() const
261 {
262 return M_side;
263 }
264
269 int scoreLeft() const
270 {
271 return M_score_left;
272 }
273
278 int scoreRight() const
279 {
280 return M_score_right;
281 }
282
288
293 bool isGameEndMode() const;
294
299 bool isPenaltyKickMode() const;
300
306 bool isTeamsSetPlay( const SideID team_side ) const;
307
313 bool isOurSetPlay( const SideID our_side ) const
314 {
315 return isTeamsSetPlay( our_side );
316 }
317
323 bool isTheirSetPlay( const SideID our_side ) const
324 {
325 return isTeamsSetPlay( our_side == LEFT
326 ? RIGHT
327 : our_side == RIGHT
328 ? LEFT
329 : NEUTRAL );
330 }
331
337
342 const char * toCString() const;
343
349 std::ostream & print( std::ostream & os ) const;
350};
351
352}
353
354#endif
playmode(referee info) wrapper class
Definition: game_mode.h:50
bool update(const std::string &mode_str, const GameTime &current)
analyze playmode string and update internal status
bool isTheirSetPlay(const SideID our_side) const
check if current mode is their setplay
Definition: game_mode.h:323
void setScore(const int score_l, const int score_r)
set scores directly.
PlayMode getServerPlayMode() const
get rcssserver playmode
bool isOurSetPlay(const SideID our_side) const
check if current mode is our setplay
Definition: game_mode.h:313
std::ostream & print(std::ostream &os) const
print current playmode string to stream
bool isTeamsSetPlay(const SideID team_side) const
check if current mode is team's setplay
Type type() const
get current playmode type
Definition: game_mode.h:251
const GameTime & time() const
get last update time
Definition: game_mode.h:242
const char * toCString() const
get playmode string
int scoreLeft() const
get current left score
Definition: game_mode.h:269
bool isPenaltyKickMode() const
check if current playmode is one of penalty kick mode.
std::pair< Type, SideID > Pair
alias of the pair of playmode type and side type
Definition: game_mode.h:179
bool isGameEndMode() const
check if current playmode is game end type.
bool isServerCycleStoppedMode() const
check if current playmode is one of server cycle stopped type.
Type
playmode type Id
Definition: game_mode.h:56
int scoreRight() const
get current right score
Definition: game_mode.h:278
GameMode()
init member variables
GameMode(Type type, SideID side, const GameTime &time, int score_left, int score_right)
init member variables with arguments
SideID side() const
get current playmode side
Definition: game_mode.h:260
game time object
Definition: game_time.h:43
game time depending on RCSSServer2D Header File
the type definition set for the RCSSServer2D
SideID
side type definition
Definition: types.h:47
PlayMode
playmode types defined in rcssserver/src/types.h
Definition: types.h:130