2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOSSERVER_ARENATEAM_H
20 #define MANGOSSERVER_ARENATEAM_H
22 enum ArenaTeamCommandTypes
24 ERR_ARENA_TEAM_CREATE_S
= 0x00,
25 ERR_ARENA_TEAM_INVITE_SS
= 0x01,
26 //ERR_ARENA_TEAM_QUIT_S = 0x02,
27 ERR_ARENA_TEAM_QUIT_S
= 0x03,
28 ERR_ARENA_TEAM_FOUNDER_S
= 0x0C // need check, probably wrong...
31 enum ArenaTeamCommandErrors
33 //ARENA_TEAM_PLAYER_NO_MORE_IN_ARENA_TEAM = 0x00,
34 ERR_ARENA_TEAM_INTERNAL
= 0x01,
35 ERR_ALREADY_IN_ARENA_TEAM
= 0x02,
36 ERR_ALREADY_IN_ARENA_TEAM_S
= 0x03,
37 ERR_INVITED_TO_ARENA_TEAM
= 0x04,
38 ERR_ALREADY_INVITED_TO_ARENA_TEAM_S
= 0x05,
39 ERR_ARENA_TEAM_NAME_INVALID
= 0x06,
40 ERR_ARENA_TEAM_NAME_EXISTS_S
= 0x07,
41 ERR_ARENA_TEAM_LEADER_LEAVE_S
= 0x08,
42 ERR_ARENA_TEAM_PERMISSIONS
= 0x08,
43 ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM
= 0x09,
44 ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM_SS
= 0x0A,
45 ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S
= 0x0B,
46 ERR_ARENA_TEAM_NOT_ALLIED
= 0x0C,
47 ERR_ARENA_TEAM_PLAYER_TO_LOW
= 0x15,
48 ERR_ARENA_TEAM_FULL
= 0x16
53 ERR_ARENA_TEAM_JOIN_SS
= 3, // player name + arena team name
54 ERR_ARENA_TEAM_LEAVE_SS
= 4, // player name + arena team name
55 ERR_ARENA_TEAM_REMOVE_SSS
= 5, // player name + arena team name + captain name
56 ERR_ARENA_TEAM_LEADER_IS_SS
= 6, // player name + arena team name
57 ERR_ARENA_TEAM_LEADER_CHANGED_SSS
= 7, // old captain + new captain + arena team name
58 ERR_ARENA_TEAM_DISBANDED_S
= 8 // captain name + arena team name
62 need info how to send these ones:
63 ERR_ARENA_TEAM_YOU_JOIN_S - client show it automatically when accept invite
64 ERR_ARENA_TEAM_TARGET_TOO_LOW_S
65 ERR_ARENA_TEAM_TOO_MANY_MEMBERS_S
66 ERR_ARENA_TEAM_LEVEL_TOO_LOW_I
69 enum ArenaTeamStatTypes
72 STAT_TYPE_GAMES_WEEK
= 1,
73 STAT_TYPE_WINS_WEEK
= 2,
74 STAT_TYPE_GAMES_SEASON
= 3,
75 STAT_TYPE_WINS_SEASON
= 4,
86 struct ArenaTeamMember
95 uint32 personal_rating
;
97 void ModifyPersonalRating(Player
* plr
, int32 mod
, uint32 slot
)
99 if (int32(personal_rating
) + mod
< 0)
102 personal_rating
+= mod
;
104 plr
->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1
+ (slot
*6) + 5, personal_rating
);
108 struct ArenaTeamStats
118 #define MAX_ARENA_SLOT 3 // 0..2 slots
126 bool Create(uint64 CaptainGuid
, uint32 type
, std::string ArenaTeamName
);
127 void Disband(WorldSession
*session
);
129 typedef std::list
<ArenaTeamMember
> MemberList
;
131 uint32
GetId() const { return Id
; }
132 uint32
GetType() const { return Type
; }
133 uint8
GetSlot() const { return GetSlotByType(GetType()); }
134 static uint8
GetSlotByType(uint32 type
);
135 const uint64
& GetCaptain() const { return CaptainGuid
; }
136 std::string
GetName() const { return Name
; }
137 const ArenaTeamStats
& GetStats() const { return stats
; }
138 void SetStats(uint32 stat_type
, uint32 value
);
139 uint32
GetRating() const { return stats
.rating
; }
141 uint32
GetEmblemStyle() const { return EmblemStyle
; }
142 uint32
GetEmblemColor() const { return EmblemColor
; }
143 uint32
GetBorderStyle() const { return BorderStyle
; }
144 uint32
GetBorderColor() const { return BorderColor
; }
145 uint32
GetBackgroundColor() const { return BackgroundColor
; }
147 void SetCaptain(const uint64
& guid
);
148 bool AddMember(const uint64
& PlayerGuid
);
150 // Shouldn't be const uint64& ed, because than can reference guid from members on Disband
151 // and this method removes given record from list. So invalid reference can happen.
152 void DelMember(uint64 guid
);
154 void SetEmblem(uint32 backgroundColor
, uint32 emblemStyle
, uint32 emblemColor
, uint32 borderStyle
, uint32 borderColor
);
156 size_t GetMembersSize() const { return members
.size(); }
157 bool Empty() const { return members
.empty(); }
158 MemberList::iterator
membersBegin() { return members
.begin(); }
159 MemberList::iterator
membersEnd() { return members
.end(); }
160 bool HaveMember(const uint64
& guid
) const;
162 ArenaTeamMember
* GetMember(const uint64
& guid
)
164 for (MemberList::iterator itr
= members
.begin(); itr
!= members
.end(); ++itr
)
165 if(itr
->guid
== guid
)
171 ArenaTeamMember
* GetMember(const std::string
& name
)
173 for (MemberList::iterator itr
= members
.begin(); itr
!= members
.end(); ++itr
)
174 if(itr
->name
== name
)
180 bool IsFighting() const;
182 bool LoadArenaTeamFromDB(uint32 ArenaTeamId
);
183 void LoadMembersFromDB(uint32 ArenaTeamId
);
184 void LoadStatsFromDB(uint32 ArenaTeamId
);
188 void BroadcastPacket(WorldPacket
*packet
);
190 void Roster(WorldSession
*session
);
191 void Query(WorldSession
*session
);
192 void Stats(WorldSession
*session
);
193 void InspectStats(WorldSession
*session
, uint64 guid
);
195 uint32
GetPoints(uint32 MemberRating
);
196 float GetChanceAgainst(uint32 own_rating
, uint32 enemy_rating
);
197 int32
WonAgainst(uint32 againstRating
);
198 void MemberWon(Player
* plr
, uint32 againstRating
);
199 int32
LostAgainst(uint32 againstRating
);
200 void MemberLost(Player
* plr
, uint32 againstRating
);
201 void OfflineMemberLost(uint64 guid
, uint32 againstRating
);
203 void UpdateArenaPointsHelper(std::map
<uint32
, uint32
> & PlayerPoints
);
205 void NotifyStatsChanged();
216 uint32 BackgroundColor
; // ARGB format
217 uint32 EmblemStyle
; // icon id
218 uint32 EmblemColor
; // ARGB format
219 uint32 BorderStyle
; // border image id
220 uint32 BorderColor
; // ARGB format
223 ArenaTeamStats stats
;