Game.hh

00001 /*
00002 ** TowBowlTactics, a turn-based strategy football game.
00003 **
00004 ** Copyright (C) 2006-2010 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 "Event.hh"
00021 # include "Sprite.hh"
00022 # include "tools.hh"
00023 
00024 # include <SDL.h>
00025 
00026 // All forward decl. Avoid recompilation of all sdlvisu when a header
00027 // is modified.
00028 class Api;
00029 class App;
00030 class SDLWindow;
00031 class Input;
00032 class TextSurface;
00033 class InputTextSurface;
00034 class VirtualSurface;
00035 
00036 BEGIN_NS(sdlvisu);
00037 
00038 class Map;
00039 class Panel;
00040 class InfoBar;
00041 class VisuPlayer;
00042 class ActionPopup;
00043 class DialogHandler;
00044 class RulesCrutch;
00045 class CmdButton;
00046 
00052 enum eVisuGameState {
00053   VGS_PAUSE = 0,            
00054   VGS_SHOWDLGBOX = 10,      
00055   VGS_WAITINPUT,            
00056   VGS_WAITINIT = 20,        
00057   VGS_SHOWACTIONPOPUP = 40, 
00058   VGS_MAKEEFFORT = 50,      
00059   VGS_INPLAY = 60,          
00060   VGS_NOTHING = 70          
00061 };
00062 
00068 enum eGameScreenChildsZ {
00069   GSCZ_ACTIONPOPUP = 1,
00070   GSCZ_INFOBAR,
00071   GSCZ_TEXTBOX,
00072   GSCZ_DIALOGBOX,
00073   GSCZ_PAUSE
00074 };
00075 
00081 enum eVisuGameCommand {
00082   VGC_CHAT = 0,
00083   VGC_DEBUG,
00084   VGC_END,
00085   VGC_FORMATION,
00086   VGC_PAUSE,
00087   VGC_QUIT,
00088 
00089   VGC_LAST = VGC_QUIT,
00090 };
00091 
00097 class Game : public Event
00098 {
00099 public:
00100   Game(SDLWindow& win, Api* api, App* app);
00101   ~Game();
00102 
00103   Api*                  getApi() const;
00104   const RulesCrutch&    getRulesCrutch() const; // only Game can modify it.
00105 
00106   Input&                getInput() const; // do not modify input.
00107   VirtualSurface&       getScreen() const;
00108 
00109   const InfoBar&        getInfoBar() const; // only Game can modify it.
00110   Map&                  getMap() const;
00111   Panel&                getPanel() const;
00112 
00115   bool isStateSet(enum eVisuGameState s) const;
00116 
00118   void setState(enum eVisuGameState s);
00119 
00121   void unsetState(enum eVisuGameState s);
00122 
00123   static const char* stringify(enum eVisuGameState s);
00124   static const char* stringify(enum eVisuGameCommand c);
00125 
00128   bool hasMoreSteps();
00129 
00132   int gameStep();
00133 
00134 private:
00135 
00136   /*
00137   ** All Events.
00138   */
00139 
00140   virtual void evIllegal(int team_id, int was_token, enum eError error);
00141   virtual void evChat(int coach_id, const std::string& msg);
00142 
00143   virtual void evInitGame();
00144   virtual void evCelebration();
00145   virtual void evEndGame();
00146   virtual void evCancelGame(int team_id);
00147 
00148   virtual void evHalf(int half);
00149   virtual void evDrawKicker(int team_id, bool is_a_question);
00150   virtual void evPlaceTeam(int team_id);
00151   virtual void evKickOff(int team_id);
00152   virtual void evTouchBack(int team_id);
00153   virtual void evNewTurn(int team_id, int cur_half, int cur_turn);
00154   virtual void evEndTurn(int team_id);
00155   virtual void evMoveTurnMarker();
00156   virtual void evTurnOver(enum eTurnOverMotive motive);
00157   virtual void evTouchdooown(int team_id, int player_id);
00158 
00159   virtual void evBallCoord(const Coordinates& old_coord, const Coordinates& new_coord);
00160   virtual void evBallOwner(int old_team_id, int old_player_id,
00161                            int team_id, int player_id);
00162 
00163   virtual void evPlayerCreate(int team_id, int player_id);
00164   virtual void evPlayerStatus(int team_id, int player_id, enum eStatus, enum eStatus);
00165   virtual void evPlayerCoord(int team_id, int player_id,
00166                              const Coordinates& old_coord,
00167                              const Coordinates& new_coord);
00168   virtual void evPlayerKnocked(int team_id, int player_id);
00169 
00170   virtual void evAction(int team_id, int player_id, enum eAction action);
00171   virtual void evEffort(int team_id, int player_id, enum eEffort effort,
00172                             const Coordinates& to);
00173   virtual void evRequestProcessed(int team_id);
00174   virtual void evResult(int team_id, int player_id, enum eRoll roll_type, int result, 
00175                         int modifier, int required, bool reroll, enum eSkill skill);
00176   virtual void evBlockResult(int team_id, int player_id, int opponent_player_id, 
00177                              int nb_dice, enum eBlockDiceFace result[3],
00178                              int dice_chooser_id, bool reroll);
00179   virtual void evBlockDice(int team_id, int dice);
00180   virtual void evBlockPush(int team_id, const Coordinates& coord, int nb_squares, const Coordinates squares[], int chosen_square);
00181   virtual void evFollow(int team_id, int follow);
00182 
00183   virtual void evReroll(int team_id, bool reroll);
00184   virtual void evSkill(int team_id, int player_id, enum eSkill skill, int choice);
00185 
00186   SDLWindow&            win_;    
00187   Api*                  api_;    
00188   App*                  app_;    
00189   RulesCrutch*          rules_crutch_; 
00190 
00191   ActionPopup*          action_popup_;  
00192   Surface*              ib_shadow_;     
00193   InfoBar*              info_bar_;      
00194   Map*                  map_;           
00195   Panel*                panel_;         
00196   CmdButton*            commands_[VGC_LAST + 1];
00197 
00198   VisuPlayer*           vplayers_[2][MAX_PLAYER]; 
00199   Sprite                block_push_[3];   
00200   InputTextSurface*     chat_;
00201 
00202   std::set<enum eVisuGameState> state_list_;  
00203   DialogHandler*        dlg_handler_; 
00204   Surface*              pause_bg_; 
00205   TextSurface*          pause_text_; 
00206 };
00207 
00208 END_NS(sdlvisu);
00209 
00210 #endif /* !GAME_HH_ */
Generated on Mon Apr 5 21:17:12 2010 for Stechec/TBT by  doxygen 1.6.3