Game.hh

00001 /*
00002 ** TowBowlTactics, an adaptation of the tabletop game Blood Bowl.
00003 **
00004 ** Copyright (C) 2006 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 GAME_HH_
00018 # define GAME_HH_
00019 
00020 # include <SDL.h>
00021 
00022 # include "tools.hh"
00023 # include "Event.hh"
00024 # include "Sprite.hh"
00025 
00026 // All forward decl. Avoid recompilation of all sdlvisu when a header
00027 // is modified.
00028 namespace xml { class XMLConfig; }
00029 class Api;
00030 class ClientCx;
00031 class SDLWindow;
00032 class Input;
00033 class TextSurface;
00034 class VirtualSurface;
00035 
00036 BEGIN_NS(sdlvisu);
00037 
00038 class Panel;
00039 class VisuField;
00040 class VisuPlayer;
00041 class ActionPopup;
00042 class ActionDlg;
00043 
00049 enum eVisuGameState {
00050   VGS_PAUSE = 0,            
00051   VGS_SHOWDLGBOX = 10,      
00052   VGS_WAITINPUT,            
00053   VGS_WAITINIT = 20,        
00054   VGS_DOKICKOFF = 30,       
00055   VGS_DOTOUCHBACK,          
00056   VGS_DOPLACETEAM,          
00057   VGS_WAITKICKOFF,          
00058   VGS_WAITPLACETEAM,        
00059   VGS_DOBLOCKPUSHCHOICE,    
00060   VGS_SHOWACTIONPOPUP = 40, 
00061   VGS_DOACTION = 50,        
00062   VGS_DOPLAY = 60,          
00063   VGS_WAITPLAY,             
00064   VGS_NOTHING = 70          
00065 };
00066 
00072 class Game : public Event
00073 {
00074 public:
00075   Game(SDLWindow& win, xml::XMLConfig* xml, Api* api, ClientCx* ccx);
00076   ~Game();
00077 
00078   Api*                  getApi();
00079   Input&                getInput();
00080   VirtualSurface&       getScreen();
00081   Panel&                getPanel();
00082   VisuField&            getField();
00083 
00085   void unselectAllPlayer();
00086 
00089   bool isStateSet(enum eVisuGameState s) const;
00090 
00092   void setState(enum eVisuGameState s);
00093 
00095   void unsetState(enum eVisuGameState s);
00096 
00097   static const char* stringify(enum eVisuGameState s);
00098 
00099   int run();
00100 
00101 private:
00102 
00103   /*
00104   ** All Events.
00105   */
00106   virtual void evIllegal(int team_id, int was_token);
00107   virtual void evNewTurn(int player_id, int cur_half, int cur_turn);
00108   virtual void evEndGame();
00109   virtual void evMoveTurnMarker();
00110   virtual void evTurnOver(enum eTurnOverMotive motive);
00111   virtual void evTouchdooown(int team_id, int player_id);
00112   virtual void evPlayerKnocked(int team_id, int player_id);
00113   virtual void evDrawKicker(int team_id, bool is_a_question);
00114   virtual void evPlaceTeam(int team_id);
00115   virtual void evKickOff(int team_id);
00116   virtual void evChat(const std::string& msg);
00117   virtual void evPlayerCreate(int team_id, int player_id);
00118   virtual void evPlayerPos(int team_id, int player_id, const Point& pos);
00119   virtual void evPlayerMove(int team_id, int player_id, const Point& pos);
00120   virtual void evPlayerStatus(int team_id, int player_id, enum eStatus status);
00121   virtual void evBallPos(const Point& pos);
00122   virtual void evGiveBall(int team_id, int player_id);
00123   virtual void evResult(int team_id, int player_id, enum eRoll action_type, int result, 
00124                         int modifier, int required, bool reroll, enum eSkill skill);
00125   virtual void evBlockResult(int team_id, int player_id, int opponent_player_id, 
00126                              int nb_dice, enum eBlockDiceFace result[3],
00127                              int strongest_team_id, bool reroll);
00128   virtual void evSkill(int team_id, int player_id, enum eSkill skill, int choice);
00129   virtual void evFollow();
00130   virtual void evBlockPush(const Position& pos, int nb_choice, const Position choices[]);
00131   virtual void evDeclare(int team_id, int player_id, enum eDeclaredAction action);
00132 
00133   SDLWindow&            win_;    
00134   xml::XMLConfig*       xml_;    
00135   Api*                  api_;    
00136   ClientCx*             ccx_;    
00137 
00138   Panel*                panel_;  
00139   VisuField*            field_;  
00140   ActionPopup*          action_popup_;  
00141 
00142   VisuPlayer*           player_[2][16]; 
00143 
00144   std::set<enum eVisuGameState> state_list_;
00145   ActionDlg*            game_dlg_; 
00146 
00147   Sprite                block_push_[3];
00148 };
00149 
00150 END_NS(sdlvisu);
00151 
00152 #endif /* !GAME_HH_ */

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