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