root/trunk/src/game/ArenaTeam.h @ 18

Revision 9, 6.2 kB (checked in by yumileroy, 17 years ago)

[svn] -enabled instantiated battlegrounds
-enabled arena matches
-rewritten battleground queuing to support joining as group
-removed queue announcements

Original author: w12x
Date: 2008-10-05 08:48:32-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
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.
8 *
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.
13 *
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
17 */
18
19#ifndef MANGOSSERVER_ARENATEAM_H
20#define MANGOSSERVER_ARENATEAM_H
21
22enum ArenaTeamCommandTypes
23{
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...
29};
30
31enum ArenaTeamCommandErrors
32{
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};
48
49enum ArenaTeamEvents
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/*
60need info how to send these ones:
61ERR_ARENA_TEAM_YOU_JOIN_S - client show it automatically when accept invite
62ERR_ARENA_TEAM_TARGET_TOO_LOW_S
63ERR_ARENA_TEAM_TOO_MANY_MEMBERS_S
64ERR_ARENA_TEAM_LEVEL_TOO_LOW_I
65*/
66
67enum ArenaTeamStatTypes
68{
69    STAT_TYPE_RATING    = 0,
70    STAT_TYPE_GAMES     = 1,
71    STAT_TYPE_WINS      = 2,
72    STAT_TYPE_PLAYED    = 3,
73    STAT_TYPE_WINS2     = 4,
74    STAT_TYPE_RANK      = 5
75};
76
77enum ArenaTeamTypes
78{
79    ARENA_TEAM_2v2      = 2,
80    ARENA_TEAM_3v3      = 3,
81    ARENA_TEAM_5v5      = 5
82};
83
84struct ArenaTeamMember
85{
86    uint64 guid;
87    std::string name;
88    //uint32 unk2;
89    //uint8 unk1;
90    uint8 Class;
91    uint32 played_week;
92    uint32 wons_week;
93    uint32 played_season;
94    uint32 wons_season;
95};
96
97struct ArenaTeamStats
98{
99    uint32 rating;
100    uint32 games;
101    uint32 wins;
102    uint32 played;
103    uint32 wins2;
104    uint32 rank;
105};
106
107#define MAX_ARENA_SLOT 3                                    // 0..2 slots
108
109class ArenaTeam
110{
111    public:
112        ArenaTeam();
113        ~ArenaTeam();
114
115        bool create(uint64 CaptainGuid, uint32 type, std::string ArenaTeamName);
116        void Disband(WorldSession *session);
117
118        typedef std::list<ArenaTeamMember> MemberList;
119
120        uint32 GetId() const { return Id; }
121        uint32 GetType() const { return Type; }
122        uint8 GetSlot() const;
123        static uint8 GetSlotByType(uint32 type);
124        const uint64& GetCaptain() const { return CaptainGuid; }
125        std::string GetName() const { return Name; }
126        ArenaTeamStats GetStats() const { return stats; }
127        void SetStats(uint32 stat_type, uint32 value);
128        uint32 GetRating() const { return stats.rating; }
129
130        uint32 GetEmblemStyle() const { return EmblemStyle; }
131        uint32 GetEmblemColor() const { return EmblemColor; }
132        uint32 GetBorderStyle() const { return BorderStyle; }
133        uint32 GetBorderColor() const { return BorderColor; }
134        uint32 GetBackgroundColor() const { return BackgroundColor; }
135
136        void SetCaptain(uint64 guid);
137        bool AddMember(uint64 PlayerGuid);
138        void DelMember(uint64 guid);
139
140        void SetEmblem(uint32 backgroundColor, uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor);
141
142        uint32 GetMembersSize() const { return members.size(); }
143        MemberList::iterator membersbegin(){ return members.begin(); }
144        MemberList::iterator membersEnd(){ return members.end(); }
145        bool HaveMember(uint64 guid) const;
146
147        bool LoadArenaTeamFromDB(uint32 ArenaTeamId);
148        void LoadMembersFromDB(uint32 ArenaTeamId);
149        void LoadStatsFromDB(uint32 ArenaTeamId);
150        void LoadPlayerStats(ArenaTeamMember* member);
151
152        void SaveToDB();
153
154        void BroadcastPacket(WorldPacket *packet);
155
156        void Roster(WorldSession *session);
157        void Query(WorldSession *session);
158        void Stats(WorldSession *session);
159        void InspectStats(WorldSession *session, uint64 guid);
160
161        uint32 GetPoints(uint32 MemberRating);
162        float GetChanceAgainst(uint32 rating);
163        int32 WonAgainstChance(float chance);
164        void MemberWon(Player * plr, uint32 againstrating);
165        int32 LostAgainstChance(float chance);
166        void MemberLost(Player * plr, uint32 againstrating);
167
168        void UpdateArenaPointsHelper();
169
170        void FinishWeek();
171
172        void NotifyStatsChanged();
173
174    protected:
175
176        uint32 Id;
177        uint32 Type;
178        std::string Name;
179        uint64 CaptainGuid;
180
181        uint32 BackgroundColor; // ARGB format
182        uint32 EmblemStyle;     // icon id
183        uint32 EmblemColor;     // ARGB format
184        uint32 BorderStyle;     // border image id
185        uint32 BorderColor;     // ARGB format
186
187        MemberList members;
188        ArenaTeamStats stats;
189};
190#endif
Note: See TracBrowser for help on using the browser.