OregonCore  revision fb2a440-git
Your Favourite TBC server
ArenaTeam.h
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore Project. See AUTHORS file for Copyright information
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the
6  * Free Software Foundation; either version 2 of the License, or (at your
7  * option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef OREGONCORE_ARENATEAM_H
19 #define OREGONCORE_ARENATEAM_H
20 
22 {
27 };
28 
30 {
47 };
48 
50 {
51  ERR_ARENA_TEAM_JOIN_SS = 3, // player name + arena team name
52  ERR_ARENA_TEAM_LEAVE_SS = 4, // player name + arena team name
53  ERR_ARENA_TEAM_REMOVE_SSS = 5, // player name + arena team name + captain name
54  ERR_ARENA_TEAM_LEADER_IS_SS = 6, // player name + arena team name
55  ERR_ARENA_TEAM_LEADER_CHANGED_SSS = 7, // old captain + new captain + arena team name
56  ERR_ARENA_TEAM_DISBANDED_S = 8 // captain name + arena team name
57 };
58 
59 /*
60 need info how to send these ones:
61 ERR_ARENA_TEAM_YOU_JOIN_S - client show it automatically when accept invite
62 ERR_ARENA_TEAM_TARGET_TOO_LOW_S
63 ERR_ARENA_TEAM_TOO_MANY_MEMBERS_S
64 ERR_ARENA_TEAM_LEVEL_TOO_LOW_I
65 */
66 
68 {
75 };
76 
78 {
82 };
83 
84 #define ARENA_NEW_TEAM_RATING 1500
85 #define ARENA_NEW_PERSONAL_RATING 1500
86 
88 {
90  std::string name;
97 
98  void ModifyPersonalRating(Player* plr, int32 mod, uint32 slot);
99 };
100 
102 {
109 };
110 
111 #define MAX_ARENA_SLOT 3 // 0..2 slots
112 
114 {
115  public:
116  ArenaTeam();
117  ~ArenaTeam();
118 
119  bool Create(uint64 captainGuid, uint32 type, std::string arenaTeamName);
120  void Disband(WorldSession* session);
121 
122  typedef std::list<ArenaTeamMember> MemberList;
123 
124  uint32 GetId() const
125  {
126  return m_TeamId;
127  }
128  uint32 GetType() const
129  {
130  return m_Type;
131  }
132  uint8 GetSlot() const
133  {
134  return GetSlotByType(GetType());
135  }
136  static uint8 GetSlotByType(uint32 type);
137  const uint64& GetCaptain() const
138  {
139  return m_CaptainGuid;
140  }
141  std::string GetName() const
142  {
143  return m_Name;
144  }
145  const ArenaTeamStats& GetStats() const
146  {
147  return m_stats;
148  }
149  void SetStats(uint32 stat_type, uint32 value);
151  {
152  return m_stats.rating;
153  }
154 
156  {
157  return m_EmblemStyle;
158  }
160  {
161  return m_EmblemColor;
162  }
164  {
165  return m_BorderStyle;
166  }
168  {
169  return m_BorderColor;
170  }
172  {
173  return m_BackgroundColor;
174  }
175 
176  void SetCaptain(const uint64& guid);
177  bool AddMember(const uint64& playerGuid);
178  void DelMember(uint64 guid);
179 
180  void SetEmblem(uint32 backgroundColor, uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor);
181 
182  size_t GetMembersSize() const
183  {
184  return m_members.size();
185  }
186  bool Empty() const
187  {
188  return m_members.empty();
189  }
190  MemberList::iterator m_membersBegin()
191  {
192  return m_members.begin();
193  }
194  MemberList::iterator m_membersEnd()
195  {
196  return m_members.end();
197  }
198  bool HaveMember(const uint64& guid) const;
199 
201  {
202  for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
203  if (itr->guid == guid)
204  return &(*itr);
205 
206  return NULL;
207  }
208 
209  ArenaTeamMember* GetMember(const std::string& name)
210  {
211  for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
212  if (itr->name == name)
213  return &(*itr);
214 
215  return NULL;
216  }
217 
218  bool IsFighting() const;
219 
220  bool LoadArenaTeamFromDB(QueryResult_AutoPtr arenaTeamDataResult);
221  bool LoadMembersFromDB(QueryResult_AutoPtr arenaTeamMembersResult);
222  void LoadStatsFromDB(uint32 ArenaTeamId);
223 
224  void SaveToDB();
225 
226  void BroadcastPacket(WorldPacket* packet);
227 
228  void BroadcastEvent(ArenaTeamEvents event, uint64 guid, char const* str1 = NULL, char const* str2 = NULL, char const* str3 = NULL);
229  void BroadcastEvent(ArenaTeamEvents event, char const* str1 = NULL, char const* str2 = NULL, char const* str3 = NULL)
230  {
231  BroadcastEvent(event, 0, str1, str2, str3);
232  }
233 
234  void Roster(WorldSession* session);
235  void Query(WorldSession* session);
236  void Stats(WorldSession* session);
237  void InspectStats(WorldSession* session, uint64 guid);
238 
239  uint32 GetPoints(uint32 MemberRating);
240  float GetChanceAgainst(uint32 own_rating, uint32 enemy_rating);
241  int32 WonAgainst(uint32 againstRating);
242  void MemberWon(Player* plr, uint32 againstRating);
243  int32 LostAgainst(uint32 againstRating);
244  void MemberLost(Player* plr, uint32 againstRating);
245  void OfflineMemberLost(uint64 guid, uint32 againstRating);
246 
247  void UpdateArenaPointsHelper(std::map<uint32, uint32>& PlayerPoints);
248 
249  void NotifyStatsChanged();
250 
251  void FinishWeek();
252  void FinishGame(int32 mod);
253 
254  protected:
255 
258  std::string m_Name;
260 
261  uint32 m_BackgroundColor; // ARGB format
262  uint32 m_EmblemStyle; // icon id
263  uint32 m_EmblemColor; // ARGB format
264  uint32 m_BorderStyle; // border image id
265  uint32 m_BorderColor; // ARGB format
266 
267  MemberList m_members;
269 };
270 #endif
271 
ArenaTeamEvents
Definition: ArenaTeam.h:49
size_t GetMembersSize() const
Definition: ArenaTeam.h:182
uint32 GetBorderStyle() const
Definition: ArenaTeam.h:163
uint32 games_season
Definition: ArenaTeam.h:106
MemberList::iterator m_membersBegin()
Definition: ArenaTeam.h:190
ArenaTeamMember * GetMember(const std::string &name)
Definition: ArenaTeam.h:209
uint32 GetType() const
Definition: ArenaTeam.h:128
uint32 m_EmblemColor
Definition: ArenaTeam.h:263
uint64 m_CaptainGuid
Definition: ArenaTeam.h:259
uint32 GetBackgroundColor() const
Definition: ArenaTeam.h:171
uint32 rating
Definition: ArenaTeam.h:103
ArenaTeamStats m_stats
Definition: ArenaTeam.h:268
ACE_INT32 int32
Definition: Define.h:67
uint32 GetBorderColor() const
Definition: ArenaTeam.h:167
ArenaTeamMember * GetMember(const uint64 &guid)
Definition: ArenaTeam.h:200
void BroadcastEvent(ArenaTeamEvents event, char const *str1=NULL, char const *str2=NULL, char const *str3=NULL)
Definition: ArenaTeam.h:229
uint32 wins_week
Definition: ArenaTeam.h:105
ArenaTeamCommandTypes
Definition: ArenaTeam.h:21
std::list< ArenaTeamMember > MemberList
Definition: ArenaTeam.h:122
const ArenaTeamStats & GetStats() const
Definition: ArenaTeam.h:145
uint32 m_BorderColor
Definition: ArenaTeam.h:265
uint32 GetRating() const
Definition: ArenaTeam.h:150
uint32 games_season
Definition: ArenaTeam.h:94
void ModifyPersonalRating(Player *plr, int32 mod, uint32 slot)
Definition: ArenaTeam.cpp:23
ArenaTeamCommandErrors
Definition: ArenaTeam.h:29
std::string m_Name
Definition: ArenaTeam.h:258
ACE_UINT8 uint8
Definition: Define.h:73
uint32 m_TeamId
Definition: ArenaTeam.h:256
uint32 m_BorderStyle
Definition: ArenaTeam.h:264
ArenaTeamTypes
Definition: ArenaTeam.h:77
Stats
uint32 GetId() const
Definition: ArenaTeam.h:124
bool Empty() const
Definition: ArenaTeam.h:186
etc mysql my cnf *Then change max_allowed_packet to a bigger value
uint32 games_week
Definition: ArenaTeam.h:104
uint32 GetEmblemStyle() const
Definition: ArenaTeam.h:155
uint32 GetEmblemColor() const
Definition: ArenaTeam.h:159
uint32 wins_season
Definition: ArenaTeam.h:95
uint32 wins_week
Definition: ArenaTeam.h:93
ACE_UINT64 uint64
Definition: Define.h:70
std::string GetName() const
Definition: ArenaTeam.h:141
uint32 m_BackgroundColor
Definition: ArenaTeam.h:261
ArenaTeamStatTypes
Definition: ArenaTeam.h:67
uint32 personal_rating
Definition: ArenaTeam.h:96
MemberList m_members
Definition: ArenaTeam.h:267
uint32 wins_season
Definition: ArenaTeam.h:107
ACE_Refcounted_Auto_Ptr< QueryResult, ACE_Null_Mutex > QueryResult_AutoPtr
Definition: QueryResult.h:113
const uint64 & GetCaptain() const
Definition: ArenaTeam.h:137
uint8 GetSlot() const
Definition: ArenaTeam.h:132
uint32 games_week
Definition: ArenaTeam.h:92
uint32 m_Type
Definition: ArenaTeam.h:257
std::string name
Definition: ArenaTeam.h:90
ACE_UINT32 uint32
Definition: Define.h:71
Definition: Player.h:922
MemberList::iterator m_membersEnd()
Definition: ArenaTeam.h:194
uint32 m_EmblemStyle
Definition: ArenaTeam.h:262