00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 template <typename T>
00018 inline Team<T>::Team(int team_id)
00019 : team_id_(team_id),
00020 score_(0),
00021 reroll_(0),
00022 reroll_used_(false)
00023 {
00024 for (int i = 0; i < MAX_PLAYER; i++)
00025 player_[i] = NULL;
00026 }
00027
00028 template <typename T>
00029 inline Team<T>::~Team()
00030 {
00031 for (int i = 0; i < MAX_PLAYER; i++)
00032 delete player_[i];
00033 }
00034
00035 template <typename T>
00036 inline void Team<T>::resetTurn()
00037 {
00038 blitz_done_ = false;
00039 pass_done_ = false;
00040 reroll_used_ = false;
00041 for (int i = 0; i < MAX_PLAYER; i++)
00042 if (player_[i] != NULL)
00043 player_[i]->resetTurn();
00044 }
00045
00046 template <typename T>
00047 inline int Team<T>::getTeamId() const
00048 {
00049 return team_id_;
00050 }
00051
00052 template <typename T>
00053 inline int Team<T>::getNbPlayer() const
00054 {
00055 int count = 0;
00056
00057 for (int i = 0; i < MAX_PLAYER; i++)
00058 if (player_[i] != NULL)
00059 count += 1;
00060 return count;
00061 }
00062
00063 template <typename T>
00064 inline T* Team<T>::getPlayer(int id)
00065 {
00066 if (id >= 0 && id < MAX_PLAYER)
00067 return player_[id];
00068
00069 LOG2("Wrong player_id: %1 (team: %2)", id, team_id_);
00070 return NULL;
00071 }
00072
00073 template <typename T>
00074 inline const std::string& Team<T>::getTeamName() const
00075 {
00076 return team_name_;
00077 }
00078
00079 template <typename T>
00080 inline const std::string& Team<T>::getCoachName() const
00081 {
00082 return coach_name_;
00083 }
00084
00085 template <typename T>
00086 inline int Team<T>::getScore() const
00087 {
00088 return score_;
00089 }
00090
00091 template <typename T>
00092 inline int Team<T>::getReroll() const
00093 {
00094 return reroll_;
00095 }
00096
00097 template <typename T>
00098 inline int Team<T>::getRemainingReroll() const
00099 {
00100 return reroll_remain_;
00101 }
00102
00103 template <typename T>
00104 inline bool Team<T>::canUseReroll() const
00105 {
00106 return (reroll_remain_ > 0 && !reroll_used_);
00107 }
00108
00109 template <typename T>
00110 inline void Team<T>::useReroll()
00111 {
00112 reroll_remain_ --;
00113 reroll_used_ = true;
00114 }
00115
00116 template <typename T>
00117 inline void Team<T>::initReroll()
00118 {
00119 reroll_remain_ = reroll_;
00120 }
00121
00122 template <typename T>
00123 inline bool Team<T>::hasDoneBlitz() const
00124 {
00125 return blitz_done_;
00126 }
00127
00128 template <typename T>
00129 inline bool Team<T>::hasDonePass() const
00130 {
00131 return pass_done_;
00132 }
00133
00134 template <typename T>
00135 inline bool Team<T>::isPlacementValid() const
00136 {
00137 int reserve = 0;
00138 int injured_KO = 0;
00139
00140 for (int i = 0; i < MAX_PLAYER; i++)
00141 if (player_[i] != NULL)
00142 {
00143 enum eStatus status = player_[i]->getStatus();
00144 if (status == STA_INJURED||status == STA_KO)
00145 injured_KO += 1;
00146 if (status == STA_RESERVE)
00147 reserve += 1;
00148 }
00149
00150 int on_field = getNbPlayer() - (reserve + injured_KO);
00151
00152 return (on_field == 11 || reserve == 0);
00153 }
00154
00155 template <typename T>
00156 inline void Team<T>::incrementScore()
00157 {
00158 score_++;
00159 }