Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * enums.cpp - World Info Transceiver Enums 00004 * 00005 * Created: Wed Apr 09 17:05:15 2008 00006 * Copyright 2006-2008 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #include <netcomm/worldinfo/enums.h> 00025 00026 #define CASE_STRING(x) case x: return #x 00027 00028 namespace fawkes { 00029 00030 /** Convert MSL gamestate to a string. 00031 * @param gamestate game state to translate into a string 00032 * @return string representation of the given state. 00033 */ 00034 const char * 00035 worldinfo_msl_gamestate_tostring(worldinfo_msl_gamestate_t gamestate) 00036 { 00037 switch (gamestate) { 00038 CASE_STRING(GS_FROZEN); 00039 CASE_STRING(GS_PLAY); 00040 CASE_STRING(GS_KICK_OFF); 00041 CASE_STRING(GS_DROP_BALL); 00042 CASE_STRING(GS_PENALTY); 00043 CASE_STRING(GS_CORNER_KICK); 00044 CASE_STRING(GS_THROW_IN); 00045 CASE_STRING(GS_FREE_KICK); 00046 CASE_STRING(GS_GOAL_KICK); 00047 CASE_STRING(GS_HALF_TIME); 00048 default: return "Unknown MSL Gamestate"; 00049 } 00050 } 00051 00052 /** Convert MSL gamestate to a string. 00053 * @param gamestate game state to translate into a string 00054 * @return string representation of the given state. 00055 */ 00056 const char * 00057 worldinfo_spl_gamestate_tostring(worldinfo_spl_gamestate_t gamestate) 00058 { 00059 switch (gamestate) { 00060 CASE_STRING(GS_SPL_INITIAL); 00061 CASE_STRING(GS_SPL_READY); 00062 CASE_STRING(GS_SPL_SET); 00063 CASE_STRING(GS_SPL_PLAY); 00064 CASE_STRING(GS_SPL_FINISHED); 00065 default: return "Unknown SPL Gamestate"; 00066 } 00067 } 00068 00069 00070 /** Convert gamestate team to a string. 00071 * @param team game state team to translate into a string 00072 * @return string representation of the given team. 00073 */ 00074 const char * 00075 worldinfo_gamestate_team_tostring(worldinfo_gamestate_team_t team) 00076 { 00077 switch (team) { 00078 CASE_STRING(TEAM_CYAN); 00079 CASE_STRING(TEAM_MAGENTA); 00080 CASE_STRING(TEAM_NONE); 00081 CASE_STRING(TEAM_BOTH); 00082 default: return "Unknown Team"; 00083 } 00084 } 00085 00086 00087 /** Convert goal color to a string. 00088 * @param goal_color goal color 00089 * @return string representation of the given goal color. 00090 */ 00091 const char * 00092 worldinfo_gamestate_goalcolor_tostring(worldinfo_gamestate_goalcolor_t goal_color) 00093 { 00094 switch (goal_color) { 00095 CASE_STRING(GOAL_BLUE); 00096 CASE_STRING(GOAL_YELLOW); 00097 default: return "Unknown Goal Color"; 00098 } 00099 00100 } 00101 00102 00103 /** Convert half time to a string. 00104 * @param half half time 00105 * @return string representation of the given half time. 00106 */ 00107 const char * 00108 worldinfo_gamestate_half_tostring(worldinfo_gamestate_half_t half) 00109 { 00110 switch (half) { 00111 CASE_STRING(HALF_FIRST); 00112 CASE_STRING(HALF_SECOND); 00113 default: return "Unknown Half"; 00114 } 00115 } 00116 00117 00118 /** Convert penalty to a string. 00119 * @param penalty penalty to translate into a string 00120 * @return string representation of the penalty 00121 */ 00122 const char * 00123 worldinfo_penalty_tostring(worldinfo_penalty_t penalty) 00124 { 00125 switch (penalty) { 00126 CASE_STRING(PENALTY_NONE); 00127 CASE_STRING(PENALTY_BALL_HOLDING); 00128 CASE_STRING(PENALTY_GOALIE_PUSHING); 00129 CASE_STRING(PENALTY_PLAYER_PUSHING); 00130 CASE_STRING(PENALTY_ILLEGAL_DEFENDER); 00131 CASE_STRING(PENALTY_ILLEGAL_DEFENSE); 00132 CASE_STRING(PENALTY_OBSTRUCTION); 00133 CASE_STRING(PENALTY_REQ_FOR_PICKUP); 00134 CASE_STRING(PENALTY_LEAVING); 00135 CASE_STRING(PENALTY_DAMAGE); 00136 CASE_STRING(PENALTY_MANUAL); 00137 default: return "Unknown Penalty"; 00138 } 00139 } 00140 00141 } // end namespace fawkes