Player.hh
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef PLAYER_HH_
00018 # define PLAYER_HH_
00019
00020 # include "Constants.hh"
00021 # include "rules/PacketHandler.hh"
00022
00025 const int MAX_MOVE = 16;
00026
00029 const int MAX_SKILL = 16;
00030
00037 DECLARE_PACKET(MSG_ACTION, MsgAction)
00038 int player_id;
00039 int action;
00040 END_PACKET;
00041
00048 DECLARE_PACKET(MSG_EFFORT, MsgEffort)
00049 int player_id;
00050 int effort;
00051 struct {
00052 int row;
00053 int col;
00054 } target;
00055 END_PACKET;
00056
00063 DECLARE_PACKET(MSG_MOVE, MsgMove)
00064 int player_id;
00065 int nb_move;
00066 struct {
00067 int row;
00068 int col;
00069 } moves[MAX_MOVE];
00070 END_PACKET;
00071
00078 DECLARE_PACKET(MSG_STANDUP, MsgStandUp)
00079 int player_id;
00080 END_PACKET;
00081
00088 DECLARE_PACKET(MSG_FOUL, MsgFoul)
00089 int player_id;
00090 int opponent_id;
00091 END_PACKET;
00092
00099 DECLARE_PACKET(MSG_HANDOFF, MsgHandOff)
00100 int player_id;
00101 int target_id;
00102 int target_team_id;
00103 END_PACKET;
00104
00111 DECLARE_PACKET(MSG_BLOCK, MsgBlock)
00112 int player_id;
00113 int opponent_id;
00114 END_PACKET;
00115
00122 DECLARE_PACKET(MSG_BLOCKPUSH, MsgBlockPush)
00123 int target_row;
00124 int target_col;
00125 int nb_squares;
00126 struct {
00127 int row;
00128 int col;
00129 } squares[3];
00130 int chosen_square;
00131 END_PACKET;
00132
00139 DECLARE_PACKET(MSG_MULTIBLOCK, MsgMultiBlock)
00140 int player_id;
00141 int first_opponent_id;
00142 int second_opponent_id;
00143 END_PACKET;
00144
00151 DECLARE_PACKET(MSG_PASS, MsgPass)
00152 int player_id;
00153 int dest_row;
00154 int dest_col;
00155 END_PACKET;
00156
00163 DECLARE_PACKET(MSG_PLAYERCREATE, MsgPlayerCreate)
00164 int player_id;
00165 int ma;
00166 int st;
00167 int ag;
00168 int av;
00169 int skill[MAX_SKILL];
00170 int skill_nb;
00171 int name[8];
00172 int position_name[8];
00173 int player_shift;
00174 int player_img[8];
00175 END_PACKET;
00176
00183 DECLARE_PACKET(MSG_PLAYERCOORD, MsgPlayerCoord)
00184 int player_id;
00185 int old_row;
00186 int old_col;
00187 int row;
00188 int col;
00189 END_PACKET;
00190
00197 DECLARE_PACKET(MSG_PLAYERKNOCKED, MsgPlayerKnocked);
00198 int player_id;
00199 END_PACKET;
00200
00207 DECLARE_PACKET(MSG_PLAYERSTATUS, MsgPlayerStatus);
00208 int player_id;
00209 int old_status;
00210 int status;
00211 END_PACKET;
00212
00219 DECLARE_PACKET(MSG_PLAYERMAREMAIN, MsgPlayerMaRemain);
00220 int player_id;
00221 int old_ma_remain;
00222 int new_ma_remain;
00223 END_PACKET;
00224
00231 DECLARE_PACKET(MSG_RESULT, MsgResult)
00232 int player_id;
00233 int roll_type;
00234 int reroll;
00235
00236 int skill;
00237 int result;
00238 int modifier;
00239 int required;
00240 END_PACKET;
00241
00248 DECLARE_PACKET(MSG_BLOCKRESULT, MsgBlockResult)
00249 int player_id;
00250 int opponent_id;
00251 bool reroll;
00252 int dice_chooser_id;
00253 int nb_dices;
00254 int results[3];
00255 END_PACKET;
00256
00263 DECLARE_PACKET(MSG_BLOCKDICE, MsgBlockDice)
00264 int dice;
00265 END_PACKET;
00266
00273 DECLARE_PACKET(MSG_FOLLOW, MsgFollow)
00278 int follow;
00279 END_PACKET;
00280
00287 DECLARE_PACKET(MSG_SKILL, MsgSkill)
00288 int player_id;
00289 int skill;
00290
00291
00292
00293
00294
00295 int choice;
00296 END_PACKET;
00297
00302 class Player
00303 {
00304 public:
00305 typedef std::vector<enum eSkill> SkillList;
00306
00307 Player(const MsgPlayerCreate* m);
00308 virtual ~Player();
00309
00310 int getId() const;
00311 int getTeamId() const;
00312 const Coordinates& getCoordinates() const;
00313 const std::string& getName() const;
00314 const std::string& getPositionName() const;
00315
00317 int getMa() const;
00319 int getMaRemain() const;
00321 int getSt() const;
00323 int getAg() const;
00325 int getAv() const;
00326
00329 enum eStatus getStatus() const;
00330
00332 bool hasPlayed() const;
00334 void setHasPlayed();
00336 bool hasBlocked() const;
00338 void setHasBlocked();
00339
00341 enum eAction getAction() const;
00343 void setAction(enum eAction action);
00344
00347 bool hasSkill(enum eSkill skill) const;
00350 const SkillList& getSkillList() const;
00353 bool hasUsedSkill(enum eSkill skill) const;
00355 void useSkill(enum eSkill skill);
00356
00358 bool hasTackleZone() const;
00361 void lostTackleZone();
00363 void resetTackleZone();
00364
00366 virtual void resetTurn();
00367
00369 static const char* stringify(enum eStatus status);
00371 static const char* stringify(enum eAction action);
00373 static const char* stringify(enum eEffort effort);
00375 static const char* stringify(enum eSkill skill);
00376
00377 friend std::ostream& operator<< (std::ostream& os, const Player& p);
00378
00379 protected:
00380 virtual void printDebug(std::ostream& os) const;
00381
00382 int id_;
00383 int team_id_;
00384 Coordinates coord_;
00385 std::string name_;
00386 std::string position_name_;
00387 enum eStatus status_;
00388
00389 int ma_;
00390 int st_;
00391 int ag_;
00392 int av_;
00393
00394 int ma_remain_;
00395 bool has_blocked_;
00396 bool has_played_;
00397 enum eAction action_;
00398 bool will_prone_;
00399
00400 bool has_tackle_zone_;
00401
00402 private:
00403 SkillList skill_list_;
00404 SkillList used_skill_list_;
00405
00406 private:
00408 Player(const Player&)
00409 {
00410 ERR("Unexpected call to Player copy constructor.");
00411 }
00413 Player& operator=(const Player&)
00414 {
00415 ERR("Unexpected Player assignment.");
00416 return *this;
00417 }
00418 };
00419
00420 # include "Player.hxx"
00421
00422 #endif