game_mode.h

説明を見る。
00001 // -*-c++-*-
00002 
00008 /*
00009  *Copyright:
00010 
00011  Copyright (C) Hidehisa AKIYAMA
00012 
00013  This code is free software; you can redistribute it and/or
00014  modify it under the terms of the GNU Lesser General Public
00015  License as published by the Free Software Foundation; either
00016  version 2.1 of the License, or (at your option) any later version.
00017 
00018  This library is distributed in the hope that it will be useful,
00019  but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00021  Lesser General Public License for more details.
00022 
00023  You should have received a copy of the GNU Lesser General Public
00024  License along with this library; if not, write to the Free Software
00025  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026 
00027  *EndCopyright:
00028  */
00029 
00031 
00032 #ifndef RCSC_GAME_MODE_H
00033 #define RCSC_GAME_MODE_H
00034 
00035 #include <rcsc/game_time.h>
00036 #include <rcsc/types.h>
00037 
00038 #include <string>
00039 #include <map>
00040 #include <utility>
00041 
00042 namespace rcsc {
00043 
00051 class GameMode {
00052 public:
00053 
00057     enum Type {
00058         BeforeKickOff,
00059         TimeOver,
00060         PlayOn,
00061         KickOff_,    // Left | Right
00062         KickIn_,     // Left | Right
00063         FreeKick_,   // Left | Right
00064         CornerKick_, // Left | Right
00065         GoalKick_,   // Left | Right
00066         AfterGoal_,  // Left | Right
00067         //Drop_Ball,   // Left | Right
00068         OffSide_,    // Left | Right
00069         PenaltyKick_,         // Left | Right
00070         FirstHalfOver,
00071         Pause,
00072         Human,
00073         FoulCharge_, // Left | Right
00074         FoulPush_,   // Left | Right
00075         FoulMultipleAttacker_, // Left | Right
00076         FoulBallOut_,    // Left | Right
00077         BackPass_,       // Left | Right
00078         FreeKickFault_, // Left | Right
00079 
00080         CatchFault_, // Left | Right
00081         IndFreeKick_, // Left | Right
00082 
00083         PenaltySetup_, // Left | Right
00084         PenaltyReady_, // Left | Right
00085         PenaltyTaken_, // Left | Right
00086         PenaltyMiss_, // Left | Right
00087         PenaltyScore_, // Left | Right
00088 
00089         // these are not a real playmode
00090         PenaltyOnfield_, // next real playmode is PenaltySetup_
00091         PenaltyFoul_,    // next real playmode is PenaltyMiss_ or PenaltyScore_
00092         //PenaltyWinner_,  // next real playmode is TimeOver
00093         //PenaltyDraw,     // next real playmode is TimeOver
00094 
00095         GoalieCatch_, // Left | Right
00096         ExtendHalf,
00097         MODE_MAX
00098     };
00099 
00100 
00101     /*
00102     // normal playmode string
00103 
00104     "before_kick_off"
00105     "time_over"
00106     "play_on"
00107     "kick_off_l"
00108     "kick_off_r"
00109     "kick_in_l"
00110     "kick_in_r"
00111     "free_kick_l"
00112     "free_kick_r"
00113     "corner_kick_l"
00114     "corner_kick_r"
00115     "goal_kick_l"
00116     "goal_kick_r"
00117     "goal_l"
00118     "goal_r"
00119     "drop_ball"
00120     "offside_l"
00121     "offside_r"
00122     "penalty_kick_l"
00123     "penalty_kick_r"
00124     "first_half_over"
00125     "pause"
00126     "human_judge"
00127     "foul_charge_l"
00128     "foul_charge_r"
00129     "foul_push_l"
00130     "foul_push_r"
00131     "foul_multiple_attack_l"
00132     "foul_multiple_attack_r"
00133     "foul_ballout_l"
00134     "foul_ballout_r"
00135     "back_pass_l"
00136     "back_pass_r"
00137     "free_kick_fault_l"
00138     "free_kick_fault_r"
00139     "catch_fault_l",
00140     "catch_fault_r",
00141     "indirect_free_kick_l",
00142     "indirect_free_kick_r",
00143     "penalty_setup_l",
00144     "penalty_setup_r",
00145     "penalty_ready_l",
00146     "penalty_ready_r",
00147     "penalty_taken_l",
00148     "penalty_taken_r",
00149     "penalty_miss_l",
00150     "penalty_miss_r",
00151     "penalty_score_l",
00152     "penalty_score_r"
00153 
00154     // extend playmode
00155 
00156     "goal_l_<SCORE>"
00157     "goal_r_<SCORE>"
00158     "half_time"
00159     "time_extended"
00160     "time_up_without_a_team"
00161     "time_up"
00162     "foul_l" // set by monitor only
00163     "foul_r" // set by monitor only
00164     "goalie_catch_ball_l"
00165     "goalie_catch_ball_r"
00166 
00167     "penalty_onfield_{l|r}"
00168     "penalty_foul_{l|r}"
00169     "penalty_winner_{l|r}"
00170     "penalty_draw"
00171     */
00172 
00173     typedef std::pair< Type, rcsc::SideID > Pair;
00174 
00175 private:
00176 
00178     GameTime M_time;
00179 
00181     Type M_type;
00183     SideID M_side;
00184 
00186     int M_score_left;
00188     int M_score_right;
00189 public:
00193     GameMode();
00194 
00202     bool update( const std::string & mode_str,
00203                  const GameTime & current );
00204 
00205 private:
00211     Pair parse( const std::string & mode_str );
00212 
00213 public:
00214 
00219     const
00220     GameTime & time() const
00221       {
00222           return M_time;
00223       }
00224 
00229     Type type() const
00230       {
00231           return M_type;
00232       }
00233 
00238     SideID side() const
00239       {
00240           return M_side;
00241       }
00242 
00247     int scoreLeft() const
00248       {
00249           return M_score_left;
00250       }
00251 
00256     int scoreRight() const
00257       {
00258           return M_score_right;
00259       }
00260 
00265     bool isServerCycleStoppedMode() const;
00266 
00271     bool isGameEndMode() const;
00272 
00277     bool isPenaltyKickMode() const;
00278 
00284     bool isOurSetPlay( const SideID ourside ) const;
00285 
00290     PlayMode getServerPlayMode() const;
00291 
00297     std::ostream & print( std::ostream & os ) const;
00298 };
00299 
00300 }
00301 
00302 #endif

librcscに対してThu May 1 15:41:20 2008に生成されました。  doxygen 1.5.0