CRules.hh

00001 /*
00002 ** TowBowlTactics, an adaptation of the tabletop game Blood Bowl.
00003 ** 
00004 ** Copyright (C) 2006, 2007 The TBT Team.
00005 ** 
00006 ** This program is free software; you can redistribute it and/or
00007 ** modify it under the terms of the GNU General Public License
00008 ** as published by the Free Software Foundation; either version 2
00009 ** of the License, or (at your option) any later version.
00010 ** 
00011 ** The complete GNU General Public Licence Notice can be found as the
00012 ** `NOTICE' file in the root directory.
00013 ** 
00014 ** The TBT Team consists of people listed in the `AUTHORS' file.
00015 */
00016 
00017 #ifndef CRULES_HH_
00018 # define CRULES_HH_
00019 
00020 # include "BaseCRules.hh"
00021 # include "BaseApi.hh"
00022 # include "Constants.hh"
00023 # include "Weather.hh"
00024 # include "CTeam.hh"
00025 # include "CPlayer.hh"
00026 # include "CBall.hh"
00027 # include "CField.hh"
00028 
00029 // Mostly a big hack, to have BaseCRules::onEvent(int) working.
00030 DECLARE_EMPTY_PACKET(CUSTOM_EVENT, CustomEvent);
00031 
00032 namespace xml { class XMLConfig; }
00033 class Api;
00034 class Weather;
00035 class CTeamMsg;
00036 class CPlayerMsg;
00037 
00040 enum eSelTeam {
00041   TEAM1 = 0,    
00042   TEAM2,        
00043   US,           
00044   THEM          
00045 };
00046 
00051 class CRules : public BaseCRules
00052 {
00053   friend class Api;
00054   
00055 public:
00056   CRules(const xml::XMLConfig& cfg);
00057   virtual ~CRules();
00058 
00059   CField* getField();
00060 
00061   // FIXME: see later.
00062   virtual void serialize(std::ostream& os) const;
00063   virtual void unserialize(std::istream& is);
00064 
00066   virtual Api* getApi();
00067 
00068   void switchToTeamState(int state);
00069   void restoreGameState();
00070 
00071 private:
00072 
00073   virtual const char* tokenToString(unsigned token) const;
00074 
00075   // Methods to catch server response.
00076   void msgIllegal(const MsgIllegal* m);
00077   void msgInitGame(const MsgInitGame* m);
00078   void msgInitHalf(const MsgInitHalf* m);
00079   void msgDrawKicker(const MsgDrawKicker* m);
00080   void msgInitKickoff(const MsgInitKickoff* m);
00081   void msgGiveBall(const MsgGiveBall* m);
00082   void msgPlayTurn(const MsgNewTurn* m);
00083   void msgEndGame(const MsgEndGame* m);
00084   void msgTimer(const MsgTimer* m);
00085   void msgTurnOver(const MsgTurnOver* m);
00086   void msgChatMessage(const MsgChat* m);
00087   void msgMoveTurnMarker(const MsgMoveTurnMarker* m);
00088   void msgCustomEvent(const CustomEvent* m);
00089   void msgResult(const MsgResult* m);
00090   void msgBlockResult(const MsgBlockResult* m);
00091   void msgBlockDice(const MsgBlockDice* m);
00092   void msgFollow(const MsgFollow* m);
00093   void msgBlockPush(const MsgBlockPush* m);
00094 
00095   const xml::XMLConfig& cfg_;
00096   Api*                  api_;
00097   Timer         timer_;
00098 
00099   int       saved_game_state_;
00100   int       cur_turn_;
00101   int       cur_half_;
00102   Weather*  weather_;
00103   CBall*    ball_;
00104   CField*   field_;
00105   CTeam*    our_team_;
00106   CTeam*    other_team_;
00107   CTeamMsg* team_msg_;
00108   CPlayerMsg* player_msg_;
00109 };
00110 
00111 # include "CRules.hxx"
00112 
00113 #endif /* !CRULES_HH_ */

Generated on Sat Jun 23 16:07:23 2007 for Stechec/TBT by  doxygen 1.4.7