58#ifndef GCGameState_DEFINED
59#define GCGameState_DEFINED
67#define SPL_NUM_PLAYERS 6
68#define SPL_NUM_TEAMS 2
70#define DEFAULT_PLAYER_NUMBER 2
72#define MIPAL_TEAM_NO 11
74#define kGSTeamHome "HomeTeam"
75#define kGSTeamAway "AwayTeam"
77#define kGSFirstHalf "FirstHalf"
78#define kGSSecondHalf "SecondHalf"
80#define kGSNormalGame "NormalGame"
81#define kGSMixedTeam "MixedTeams"
82#define kGSDropIn "Drop In"
84#define kGSPenaltyShots "PenaltyShots"
85#define kGSOverTime "OverTime"
86#define kGSTimeOut "TimeOut"
88#define kGSInitialReceived "InitialReceived"
89#define kGSReadyReceived "ReadyReceived"
90#define kGSSetReceived "SetReceived"
91#define kGSPlayingReceived "PlayingReceived"
92#define kGSFinishedReceived "FinishedReceived"
94#define kGSInitial "GSInitial"
95#define kGSReady "GSReady"
97#define kGSPlaying "GSPlaying"
98#define kGSFinished "GSFinished"
100#define kGSNoSetPlay "GSNoSetPlay"
101#define kGSGoalFreeKick "GSGoalFreeKick"
102#define kGSPushingFreeKick "GSPushingFreeKick"
103#define kGSCornerKick "GSCornerKick"
104#define kGSKickIn "GSKickIn"
107#define kGSNoPenalty "NoPenalty"
108#define kGSIllegalBallContact "IllegalBallContact"
109#define kGSPlayerPushing "PlayerPushing"
110#define kGSIllegalMotionInSet "IllegalMotionInSet"
111#define kGSInactivePlayer "InactivePlayer"
112#define kGSIllegalDefender "IllegalDefender"
113#define kGSLeavingTheField "LeavingTheField"
114#define kGSKickOffGoal "KickOffGoal"
115#define kGSRequestForPickup "RequestForPickup"
116#define kGSLocalGameStuck "LocalGameStuck"
117#define kGSIllegalPositioning "IllegalPositioning"
118#define kGSSubstitutionPenalty "SubstitutionPenalty"
119#define kGSManualPenalty "ManualPenalty"
122#define kNoGSsignal "NoGSsignal"
123#define kGSOurGoalSignalPushed "GSOurGoalSignalPushed"
124#define kGSTheirGoalSignalPushed "GSTheirGoalSignalPushed"
125#define kGSBlueKickOffSignalPushed "GSBlueKickOffSignalPushed"
126#define kGSRedKickOffSignalPushed "GSRedKickOffSignalPushed"
134 {
BLUE=0,
RED,
YELLOW,
BLACK,
WHITE,
GREEN,
ORANGE,
PURPLE,
BROWN,
GRAY,
NUM_JERSEY_COLORS };
138 {
"Blue",
"Red",
"Yellow",
"Black",
"White",
"Green",
"Orange",
"Purple",
"Brown",
"Gray" };
243 PROPERTY(
SetPlay, theGCSetPlayInProgress)
246 PROPERTY(
HomeAway, theGCTeamWithFreeKick)
249 PROPERTY(int16_t, secondsReminingInHalf )
264 int16_t secondsReminingInHalf =
Home,
267 _theGCHalf(theGCHalf),
268 _theGCCompetitionType(theGCCompetitionType),
269 _theGCCompetitionPhase(theGCCompetitionPhase),
270 _theGCGamePhase(theGCGamePhase),
271 _theGCGameState(theGCGameState),
272 _theGCSetPlayInProgress(theGCSetPlayInProgress),
273 _theGCTeamWithFreeKick(theGCTeamWithFreeKick),
274 _secondsReminingInHalf(secondsReminingInHalf),
287 GCGameState(
const std::string &names) { from_string(names); }
291 _theGCHalf(other._theGCHalf),
292 _theGCCompetitionType(other._theGCCompetitionType),
293 _theGCCompetitionPhase(other._theGCCompetitionPhase),
294 _theGCGamePhase(other._theGCGamePhase),
295 _theGCGameState(other._theGCGameState),
296 _theGCSetPlayInProgress(other._theGCSetPlayInProgress),
297 _theGCTeamWithFreeKick(other._theGCTeamWithFreeKick),
298 _secondsReminingInHalf(other._secondsReminingInHalf),
299 _homeaway(other._homeaway)
303 _RobotGCPenaltyState[i][j].
penalty = other._RobotGCPenaltyState[i][j].
penalty;
307 for (
int i=0; i<
SPL_NUM_TEAMS; i++) _score[i]=other._score[i];
311 const GCGameState &operator=(
const GCGameState &other) { memcpy(
this, &other,
sizeof(*
this));
return *
this; }
317 _RobotGCPenaltyState[i][j].
penalty=robotGCPenaltyState[i][j].penalty;
318 _RobotGCPenaltyState[i][j].
secsTillUnpenalised=robotGCPenaltyState[i][j].secsTillUnpenalised;
324 void setScore(int16_t goalsByHome, int16_t goalsByAway) {
325 _score[
Home] = goalsByHome;
326 _score[
Away] = goalsByAway;
330 int16_t getScoreHome() {
return _score[
Home]; }
333 int16_t getScoreAway() {
return _score[
Away]; }
336 int16_t getOurScore() {
return _score[_homeaway]; }
339 int16_t getTheirScore() {
340 if (
Home == _homeaway )
return getScoreAway();
341 else return getScoreHome();
349 return static_cast<RobotPenaltyState>(_RobotGCPenaltyState[_homeaway][PlayerNumber-1]);
366 bool amIPenalized(
int PlayerNumber)
368 if (
NoPenalty==myPenaltyIs(PlayerNumber))
374 void setMyPenalty(
int PlayerNumber,
PenaltyTypes thePenalty, uint8_t duration = 0) {
375 _RobotGCPenaltyState[_homeaway][PlayerNumber-1].
penalty=thePenalty;
380 std::string description() {
381 std::ostringstream ss;
383 switch(
int (_theGCSetPlayInProgress)) {
400 ss << _theGCSetPlayInProgress <<
",";
404 ss <<
"Next kick to: ";
409 switch(
int (_theGCGameState)) {
426 ss << _theGCGameState <<
",";
430 switch (_RobotGCPenaltyState[_homeaway][i].penalty ) {
483 ss << getScoreHome() <<
"," << getScoreAway() <<
",";
488 void from_string(
const std::string &str) {
489 std::istringstream iss(str);
491 getline(iss, token,
',');
#define kGSIllegalMotionInSet
#define kGSIllegalBallContact
#define kGSSubstitutionPenalty
#define kGSRequestForPickup
#define kGSInactivePlayer
#define kGSIllegalPositioning
#define kGSPushingFreeKick
#define kGSIllegalDefender
#define kGSLocalGameStuck
#define kGSLeavingTheField
WB Class to record game state received from the Game Controller.
PenaltyTypes
Penalty types.
GameContollerSignal
major game event signals (goals, kick-offs)
@ GSTheirGoalSignalPushed
@ GSRedKickOffSignalPushed
@ GSBlueKickOffSignalPushed
GameState
High level Game Controller states.
HomeAway
Used to nominate which team is home/away and to decouple game state from team specifics.
CompetitionType
Type of the competition.
CompetitionPhase
Phase of the competition.
GameHalf
Soccer games comprise of two halves.
BallOut
Who kicked the ball out.
GameControllerCommand
received command from the Game Controller
GamePhase
Phase of the game.
uint8_t secsTillUnpenalised