common/Player.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 PLAYER_HH_
00018 # define PLAYER_HH_
00019 
00020 # include "Constants.hh"
00021 # include "Field.hh"
00022 # include "PacketHandler.hh"
00023 
00026 const int MAX_MOVE = 16;
00027 
00030 const int MAX_SKILL = 16;
00031 
00038 DECLARE_PACKET(MSG_DECLARE, MsgDeclare)
00039   int player_id; 
00040   int action;    
00041 END_PACKET;
00042 
00049 DECLARE_PACKET(MSG_MOVE, MsgMove)
00050   int player_id; 
00051   int nb_move;   
00052   struct {
00053     int row;
00054     int col;
00055   } moves[MAX_MOVE];
00056 END_PACKET;
00057 
00064 DECLARE_PACKET(MSG_STANDUP, MsgStandUp)
00065   int player_id; 
00066 END_PACKET;
00067 
00074 DECLARE_PACKET(MSG_BLOCK, MsgBlock)
00075   int player_id;    
00076   int opponent_id;  
00077 END_PACKET;
00078 
00085 DECLARE_PACKET(MSG_BLOCKPUSH, MsgBlockPush)
00086   int target_row;
00087   int target_col;
00088   int nb_choice;
00089   struct {
00090     int row;
00091     int col;
00092   } choice[3];
00093   int square_chosen;
00094 END_PACKET;
00095 
00102 DECLARE_PACKET(MSG_MULTIBLOCK, MsgMultiBlock)
00103   int player_id;
00104   int first_opponent_id;
00105   int second_opponent_id;
00106 END_PACKET;
00107 
00114 DECLARE_PACKET(MSG_PASS, MsgPass)
00115   int player_id;
00116   int dest_row;
00117   int dest_col;
00118 END_PACKET;
00119 
00126 DECLARE_PACKET(MSG_PLAYERCREATE, MsgPlayerCreate)
00127   int player_id;
00128   int ma;
00129   int st;
00130   int ag;
00131   int av;
00132   int skill[MAX_SKILL]; 
00133   int skill_nb;
00134   int name[8];
00135   int position_name[8]; 
00136   int player_position;  
00137   int player_img[8];    
00138 END_PACKET;
00139 
00146 DECLARE_PACKET(MSG_PLAYERPOS, MsgPlayerPos)
00147   int player_id;  
00148   int row;
00149   int col;
00150 END_PACKET;
00151 
00158 DECLARE_PACKET(MSG_PLAYERKNOCKED, MsgPlayerKnocked);
00159   int player_id;  
00160 END_PACKET;
00161 
00168 DECLARE_PACKET(MSG_PLAYERSTATUS, MsgPlayerStatus);
00169   int player_id;  
00170   int status;     
00171 END_PACKET;
00172 
00179 DECLARE_PACKET(MSG_PLAYERKO, MsgPlayerKO);
00180   int player_id;  
00181   int dice;       
00182 END_PACKET;
00183 
00190 DECLARE_PACKET(MSG_RESULT, MsgResult)
00191   int player_id;  
00192   int roll_type;  
00193   int reroll;     
00194 
00195   int skill;      
00196   int result;     
00197   int modifier;   
00198   int required;   
00199 END_PACKET;
00200 
00207 DECLARE_PACKET(MSG_BLOCKRESULT, MsgBlockResult)
00208   int player_id;          
00209   int opponent_id;        
00210   bool reroll;            
00211   int strongest_team_id;  
00212   int nb_dice;            
00213   int results[3];         
00214 END_PACKET;
00215 
00222 DECLARE_PACKET(MSG_BLOCKDICE, MsgBlockDice)
00223   int dice; 
00224 END_PACKET;
00225 
00232 DECLARE_PACKET(MSG_FOLLOW, MsgFollow)
00237   int follow;
00238 END_PACKET;
00239 
00246 DECLARE_PACKET(MSG_SKILL, MsgSkill)
00247   int player_id; 
00248   int skill;  
00249 
00250 
00251 
00252 
00253 
00254   int choice;
00255 END_PACKET;
00256 
00261 class Player
00262 {
00263 public:
00264   typedef std::vector<enum eSkill> SkillList;
00265   
00266   Player(const MsgPlayerCreate* m);
00267   virtual ~Player();
00268 
00269   int getId() const;
00270   int getTeamId() const;
00271   const Position& getPosition() const;
00272   const std::string& getName() const;
00273   const std::string& getPositionName() const;
00274 
00276   int getMa() const;
00278   int getMaRemain() const;
00280   int getSt() const;
00282   int getAg() const;
00284   int getAv() const;
00285 
00288   enum eStatus getStatus() const;
00289 
00291   bool hasPlayed() const;
00293   void setHasPlayed();
00295   bool hasBlocked() const;
00297   void setHasBlocked();
00298 
00300   enum eDeclaredAction getAction() const;
00302   void setAction(enum eDeclaredAction action);
00303 
00306   bool hasSkill(enum eSkill skill) const;
00309   const SkillList& getSkillList() const;
00312   bool hasUsedSkill(enum eSkill skill) const;
00314   void useSkill(enum eSkill skill);
00315 
00317   void resetTurn();
00318 
00319   static const char* stringify(enum eStatus status);
00320   static const char* stringify(enum eDeclaredAction action);
00321   static const char* stringify(enum eRealAction action);
00322   static const char* stringify(enum eSkill skill);
00323 
00324   friend std::ostream& operator<< (std::ostream& os, const Player& p);
00325 
00326 protected:
00327   int       id_;      
00328   int       team_id_; 
00329   Position  pos_;     
00330   std::string   name_;    
00331   std::string   position_name_; 
00332   enum eStatus  status_;  
00333 
00334   int ma_;
00335   int st_;
00336   int ag_;
00337   int av_;
00338 
00339   int ma_remain_;
00340   bool has_blocked_;
00341   bool has_played_;
00342   enum eDeclaredAction action_;
00343   bool will_prone_;
00344 
00345 private:
00346   SkillList skill_list_; 
00347   SkillList used_skill_list_; 
00348 };
00349 
00350 # include "Player.hxx"
00351 
00352 #endif /* !PLAYER_HH_ */

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