TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ArenaTeam.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef TRINITYCORE_ARENATEAM_H
20 #define TRINITYCORE_ARENATEAM_H
21 
22 #include "Define.h"
23 #include "QueryResult.h"
24 #include "ObjectGuid.h"
25 #include <list>
26 #include <string>
27 #include <map>
28 
29 class WorldSession;
30 class WorldPacket;
31 class Player;
32 class Group;
33 
35 {
40 };
41 
43 {
65 };
66 
68 {
69  ERR_ARENA_TEAM_JOIN_SS = 4, // player name + arena team name
70  ERR_ARENA_TEAM_LEAVE_SS = 5, // player name + arena team name
71  ERR_ARENA_TEAM_REMOVE_SSS = 6, // player name + arena team name + captain name
72  ERR_ARENA_TEAM_LEADER_IS_SS = 7, // player name + arena team name
73  ERR_ARENA_TEAM_LEADER_CHANGED_SSS = 8, // old captain + new captain + arena team name
74  ERR_ARENA_TEAM_DISBANDED_S = 9 // captain name + arena team name
75 };
76 
78 {
82 };
83 
85 {
87  std::string Name;
95 
96  void ModifyPersonalRating(Player* player, int32 mod, uint32 type);
97  void ModifyMatchmakerRating(int32 mod, uint32 slot);
98 };
99 
101 {
108 };
109 
110 #define MAX_ARENA_SLOT 3 // 0..2 slots
111 
113 {
114  public:
115  ArenaTeam();
116  ~ArenaTeam();
117 
118  bool Create(ObjectGuid captainGuid, uint8 type, std::string const& teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor);
119  void Disband(WorldSession* session);
120  void Disband();
121 
122  typedef std::list<ArenaTeamMember> MemberList;
123 
124  uint32 GetId() const { return TeamId; }
125  uint32 GetType() const { return Type; }
126  uint8 GetSlot() const { return GetSlotByType(GetType()); }
127  static uint8 GetSlotByType(uint32 type);
128  static uint8 GetTypeBySlot(uint8 slot);
129  ObjectGuid GetCaptain() const { return CaptainGuid; }
130  std::string const& GetName() const { return TeamName; }
131  const ArenaTeamStats& GetStats() const { return Stats; }
132 
133  uint32 GetRating() const { return Stats.Rating; }
134  uint32 GetAverageMMR(Group* group) const;
135 
136  void SetCaptain(ObjectGuid guid);
137  bool SetName(std::string const& name);
138  bool AddMember(ObjectGuid PlayerGuid);
139  void DelMember(ObjectGuid guid, bool cleanDb);
140 
141  size_t GetMembersSize() const { return Members.size(); }
142  bool Empty() const { return Members.empty(); }
143  MemberList::iterator m_membersBegin() { return Members.begin(); }
144  MemberList::iterator m_membersEnd() { return Members.end(); }
145  bool IsMember(ObjectGuid guid) const;
146 
147  ArenaTeamMember* GetMember(ObjectGuid guid);
148  ArenaTeamMember* GetMember(std::string const& name);
149 
150  bool IsFighting() const;
151 
152  bool LoadArenaTeamFromDB(QueryResult arenaTeamDataResult);
153  bool LoadMembersFromDB(QueryResult arenaTeamMembersResult);
154  void LoadStatsFromDB(uint32 ArenaTeamId);
155  void SaveToDB();
156 
157  void BroadcastPacket(WorldPacket* packet);
158  void NotifyStatsChanged();
159 
160  void SendStats(WorldSession* session);
161  void Inspect(WorldSession* session, ObjectGuid guid);
162 
163  uint32 GetPoints(uint32 MemberRating);
164  int32 GetMatchmakerRatingMod(uint32 ownRating, uint32 opponentRating, bool won);
165  int32 GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won);
166  float GetChanceAgainst(uint32 ownRating, uint32 opponentRating);
167  int32 WonAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32& rating_change);
168  void MemberWon(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange);
169  int32 LostAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32& rating_change);
170  void MemberLost(Player* player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange = -12);
171  void OfflineMemberLost(ObjectGuid guid, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange = -12);
172 
173 
174 
175 
176  void FinishWeek();
177  void FinishGame(int32 mod);
178 
179  protected:
180 
183  std::string TeamName;
185 
186  uint32 BackgroundColor; // ARGB format
187  uint8 EmblemStyle; // icon id
188  uint32 EmblemColor; // ARGB format
189  uint8 BorderStyle; // border image id
190  uint32 BorderColor; // ARGB format
191 
192  MemberList Members;
194 };
195 #endif
196 
ArenaTeamEvents
Definition: ArenaTeam.h:67
size_t GetMembersSize() const
Definition: ArenaTeam.h:141
Definition: ArenaTeam.h:38
Definition: ArenaTeam.h:61
uint16 PersonalRating
Definition: ArenaTeam.h:93
uint16 Rating
Definition: ArenaTeam.h:102
uint8 EmblemStyle
Definition: ArenaTeam.h:187
uint8 Class
Definition: ArenaTeam.h:88
Definition: ArenaTeam.h:59
MemberList::iterator m_membersBegin()
Definition: ArenaTeam.h:143
Definition: ArenaTeam.h:49
uint32 GetType() const
Definition: ArenaTeam.h:125
Definition: ArenaTeam.h:64
uint16 MatchMakerRating
Definition: ArenaTeam.h:94
Definition: ArenaTeam.h:53
std::string const & GetName() const
Definition: ArenaTeam.h:130
Definition: ArenaTeam.h:71
Definition: ArenaTeam.h:52
Stats
Definition: SharedDefines.h:235
Definition: ArenaTeam.h:51
Definition: ArenaTeam.h:54
Definition: ArenaTeam.h:69
uint16 WeekWins
Definition: ArenaTeam.h:90
ArenaTeamCommandTypes
Definition: ArenaTeam.h:34
std::list< ArenaTeamMember > MemberList
Definition: ArenaTeam.h:122
Definition: ArenaTeam.h:80
uint16 WeekGames
Definition: ArenaTeam.h:89
ArenaTeamStats Stats
Definition: ArenaTeam.h:193
const ArenaTeamStats & GetStats() const
Definition: ArenaTeam.h:131
uint32 GetRating() const
Definition: ArenaTeam.h:133
uint8 Type
Definition: ArenaTeam.h:182
Definition: ArenaTeam.h:48
Definition: ArenaTeam.h:36
ArenaTeamCommandErrors
Definition: ArenaTeam.h:42
Definition: ArenaTeam.h:81
Definition: ArenaTeam.h:56
Definition: ArenaTeam.h:63
Definition: ArenaTeam.h:74
ObjectGuid CaptainGuid
Definition: ArenaTeam.h:184
uint8 BorderStyle
Definition: ArenaTeam.h:189
uint32 Rank
Definition: ArenaTeam.h:107
ArenaTeamTypes
Definition: ArenaTeam.h:77
uint16 SeasonWins
Definition: ArenaTeam.h:106
uint32 GetId() const
Definition: ArenaTeam.h:124
bool Empty() const
Definition: ArenaTeam.h:142
Definition: ArenaTeam.h:70
uint16 WeekGames
Definition: ArenaTeam.h:103
uint32 BorderColor
Definition: ArenaTeam.h:190
MemberList Members
Definition: ArenaTeam.h:192
Definition: ArenaTeam.h:45
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
uint16 SeasonGames
Definition: ArenaTeam.h:91
uint16_t uint16
Definition: Define.h:151
Definition: ArenaTeam.h:50
uint32 BackgroundColor
Definition: ArenaTeam.h:186
std::string TeamName
Definition: ArenaTeam.h:183
ObjectGuid Guid
Definition: ArenaTeam.h:86
TeamId
Definition: SharedDefines.h:990
uint16 WeekWins
Definition: ArenaTeam.h:104
uint16 SeasonGames
Definition: ArenaTeam.h:105
Definition: ArenaTeam.h:46
Definition: ArenaTeam.h:62
Definition: ArenaTeam.h:100
Definition: ArenaTeam.h:112
Definition: ArenaTeam.h:44
Definition: ArenaTeam.h:79
Definition: ArenaTeam.h:39
uint16 SeasonWins
Definition: ArenaTeam.h:92
#define TC_GAME_API
Definition: Define.h:134
Definition: ArenaTeam.h:47
Definition: ArenaTeam.h:55
uint8 GetSlot() const
Definition: ArenaTeam.h:126
uint8_t uint8
Definition: Define.h:152
Definition: ArenaTeam.h:57
uint32 EmblemColor
Definition: ArenaTeam.h:188
Definition: ArenaTeam.h:37
Definition: ArenaTeam.h:60
Player session in the World.
Definition: WorldSession.h:882
Definition: ObjectGuid.h:189
Definition: ArenaTeam.h:58
Definition: ArenaTeam.h:73
Type
Type of JSON value.
Definition: rapidjson.h:642
std::string Name
Definition: ArenaTeam.h:87
Definition: WorldPacket.h:26
uint32 TeamId
Definition: ArenaTeam.h:181
ObjectGuid GetCaptain() const
Definition: ArenaTeam.h:129
MemberList::iterator m_membersEnd()
Definition: ArenaTeam.h:144
Definition: Group.h:191
Definition: ArenaTeam.h:72
Definition: ArenaTeam.h:84