| 1 | /* |
|---|
| 2 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
|---|
| 3 | * |
|---|
| 4 | * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> |
|---|
| 5 | * |
|---|
| 6 | * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | * it under the terms of the GNU General Public License as published by |
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | * (at your option) any later version. |
|---|
| 10 | * |
|---|
| 11 | * This program is distributed in the hope that it will be useful, |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 14 | * GNU General Public License for more details. |
|---|
| 15 | * |
|---|
| 16 | * You should have received a copy of the GNU General Public License |
|---|
| 17 | * along with this program; if not, write to the Free Software |
|---|
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 19 | */ |
|---|
| 20 | |
|---|
| 21 | #ifndef TRINITYCORE_ARENATEAM_H |
|---|
| 22 | #define TRINITYCORE_ARENATEAM_H |
|---|
| 23 | |
|---|
| 24 | enum ArenaTeamCommandTypes |
|---|
| 25 | { |
|---|
| 26 | ERR_ARENA_TEAM_CREATE_S = 0x00, |
|---|
| 27 | ERR_ARENA_TEAM_INVITE_SS = 0x01, |
|---|
| 28 | //ERR_ARENA_TEAM_QUIT_S = 0x02, |
|---|
| 29 | ERR_ARENA_TEAM_QUIT_S = 0x03, |
|---|
| 30 | ERR_ARENA_TEAM_FOUNDER_S = 0x0C // need check, probably wrong... |
|---|
| 31 | }; |
|---|
| 32 | |
|---|
| 33 | enum ArenaTeamCommandErrors |
|---|
| 34 | { |
|---|
| 35 | //ARENA_TEAM_PLAYER_NO_MORE_IN_ARENA_TEAM = 0x00, |
|---|
| 36 | ERR_ARENA_TEAM_INTERNAL = 0x01, |
|---|
| 37 | ERR_ALREADY_IN_ARENA_TEAM = 0x02, |
|---|
| 38 | ERR_ALREADY_IN_ARENA_TEAM_S = 0x03, |
|---|
| 39 | ERR_INVITED_TO_ARENA_TEAM = 0x04, |
|---|
| 40 | ERR_ALREADY_INVITED_TO_ARENA_TEAM_S = 0x05, |
|---|
| 41 | ERR_ARENA_TEAM_NAME_INVALID = 0x06, |
|---|
| 42 | ERR_ARENA_TEAM_NAME_EXISTS_S = 0x07, |
|---|
| 43 | ERR_ARENA_TEAM_LEADER_LEAVE_S = 0x08, |
|---|
| 44 | ERR_ARENA_TEAM_PERMISSIONS = 0x08, |
|---|
| 45 | ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM = 0x09, |
|---|
| 46 | ERR_ARENA_TEAM_PLAYER_NOT_IN_TEAM_SS = 0x0A, |
|---|
| 47 | ERR_ARENA_TEAM_PLAYER_NOT_FOUND_S = 0x0B, |
|---|
| 48 | ERR_ARENA_TEAM_NOT_ALLIED = 0x0C |
|---|
| 49 | }; |
|---|
| 50 | |
|---|
| 51 | enum ArenaTeamEvents |
|---|
| 52 | { |
|---|
| 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 |
|---|
| 59 | }; |
|---|
| 60 | |
|---|
| 61 | /* |
|---|
| 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 |
|---|
| 67 | */ |
|---|
| 68 | |
|---|
| 69 | enum ArenaTeamStatTypes |
|---|
| 70 | { |
|---|
| 71 | STAT_TYPE_RATING = 0, |
|---|
| 72 | STAT_TYPE_GAMES = 1, |
|---|
| 73 | STAT_TYPE_WINS = 2, |
|---|
| 74 | STAT_TYPE_PLAYED = 3, |
|---|
| 75 | STAT_TYPE_WINS2 = 4, |
|---|
| 76 | STAT_TYPE_RANK = 5 |
|---|
| 77 | }; |
|---|
| 78 | |
|---|
| 79 | enum ArenaTeamTypes |
|---|
| 80 | { |
|---|
| 81 | ARENA_TEAM_2v2 = 2, |
|---|
| 82 | ARENA_TEAM_3v3 = 3, |
|---|
| 83 | ARENA_TEAM_5v5 = 5 |
|---|
| 84 | }; |
|---|
| 85 | |
|---|
| 86 | struct ArenaTeamMember |
|---|
| 87 | { |
|---|
| 88 | uint64 guid; |
|---|
| 89 | std::string name; |
|---|
| 90 | //uint32 unk2; |
|---|
| 91 | //uint8 unk1; |
|---|
| 92 | uint8 Class; |
|---|
| 93 | uint32 played_week; |
|---|
| 94 | uint32 wons_week; |
|---|
| 95 | uint32 played_season; |
|---|
| 96 | uint32 wons_season; |
|---|
| 97 | }; |
|---|
| 98 | |
|---|
| 99 | struct ArenaTeamStats |
|---|
| 100 | { |
|---|
| 101 | uint32 rating; |
|---|
| 102 | uint32 games; |
|---|
| 103 | uint32 wins; |
|---|
| 104 | uint32 played; |
|---|
| 105 | uint32 wins2; |
|---|
| 106 | uint32 rank; |
|---|
| 107 | }; |
|---|
| 108 | |
|---|
| 109 | #define MAX_ARENA_SLOT 3 // 0..2 slots |
|---|
| 110 | |
|---|
| 111 | class ArenaTeam |
|---|
| 112 | { |
|---|
| 113 | public: |
|---|
| 114 | ArenaTeam(); |
|---|
| 115 | ~ArenaTeam(); |
|---|
| 116 | |
|---|
| 117 | bool create(uint64 CaptainGuid, uint32 type, std::string ArenaTeamName); |
|---|
| 118 | void Disband(WorldSession *session); |
|---|
| 119 | |
|---|
| 120 | typedef std::list<ArenaTeamMember> MemberList; |
|---|
| 121 | |
|---|
| 122 | uint32 GetId() const { return Id; } |
|---|
| 123 | uint32 GetType() const { return Type; } |
|---|
| 124 | uint8 GetSlot() const; |
|---|
| 125 | static uint8 GetSlotByType(uint32 type); |
|---|
| 126 | const uint64& GetCaptain() const { return CaptainGuid; } |
|---|
| 127 | std::string GetName() const { return Name; } |
|---|
| 128 | ArenaTeamStats GetStats() const { return stats; } |
|---|
| 129 | void SetStats(uint32 stat_type, uint32 value); |
|---|
| 130 | uint32 GetRating() const { return stats.rating; } |
|---|
| 131 | |
|---|
| 132 | uint32 GetEmblemStyle() const { return EmblemStyle; } |
|---|
| 133 | uint32 GetEmblemColor() const { return EmblemColor; } |
|---|
| 134 | uint32 GetBorderStyle() const { return BorderStyle; } |
|---|
| 135 | uint32 GetBorderColor() const { return BorderColor; } |
|---|
| 136 | uint32 GetBackgroundColor() const { return BackgroundColor; } |
|---|
| 137 | |
|---|
| 138 | void SetCaptain(uint64 guid); |
|---|
| 139 | bool AddMember(uint64 PlayerGuid); |
|---|
| 140 | void DelMember(uint64 guid); |
|---|
| 141 | |
|---|
| 142 | void SetEmblem(uint32 backgroundColor, uint32 emblemStyle, uint32 emblemColor, uint32 borderStyle, uint32 borderColor); |
|---|
| 143 | |
|---|
| 144 | uint32 GetMembersSize() const { return members.size(); } |
|---|
| 145 | MemberList::iterator membersbegin(){ return members.begin(); } |
|---|
| 146 | MemberList::iterator membersEnd(){ return members.end(); } |
|---|
| 147 | bool HaveMember(uint64 guid) const; |
|---|
| 148 | |
|---|
| 149 | bool LoadArenaTeamFromDB(uint32 ArenaTeamId); |
|---|
| 150 | void LoadMembersFromDB(uint32 ArenaTeamId); |
|---|
| 151 | void LoadStatsFromDB(uint32 ArenaTeamId); |
|---|
| 152 | void LoadPlayerStats(ArenaTeamMember* member); |
|---|
| 153 | |
|---|
| 154 | void SaveToDB(); |
|---|
| 155 | |
|---|
| 156 | void BroadcastPacket(WorldPacket *packet); |
|---|
| 157 | |
|---|
| 158 | void Roster(WorldSession *session); |
|---|
| 159 | void Query(WorldSession *session); |
|---|
| 160 | void Stats(WorldSession *session); |
|---|
| 161 | void InspectStats(WorldSession *session, uint64 guid); |
|---|
| 162 | |
|---|
| 163 | uint32 GetPoints(uint32 MemberRating); |
|---|
| 164 | float GetChanceAgainst(uint32 rating); |
|---|
| 165 | int32 WonAgainstChance(float chance); |
|---|
| 166 | void MemberWon(Player * plr, uint32 againstrating); |
|---|
| 167 | int32 LostAgainstChance(float chance); |
|---|
| 168 | void MemberLost(Player * plr, uint32 againstrating); |
|---|
| 169 | |
|---|
| 170 | void UpdateArenaPointsHelper(); |
|---|
| 171 | |
|---|
| 172 | void FinishWeek(); |
|---|
| 173 | |
|---|
| 174 | void NotifyStatsChanged(); |
|---|
| 175 | |
|---|
| 176 | protected: |
|---|
| 177 | |
|---|
| 178 | uint32 Id; |
|---|
| 179 | uint32 Type; |
|---|
| 180 | std::string Name; |
|---|
| 181 | uint64 CaptainGuid; |
|---|
| 182 | |
|---|
| 183 | uint32 BackgroundColor; // ARGB format |
|---|
| 184 | uint32 EmblemStyle; // icon id |
|---|
| 185 | uint32 EmblemColor; // ARGB format |
|---|
| 186 | uint32 BorderStyle; // border image id |
|---|
| 187 | uint32 BorderColor; // ARGB format |
|---|
| 188 | |
|---|
| 189 | MemberList members; |
|---|
| 190 | ArenaTeamStats stats; |
|---|
| 191 | }; |
|---|
| 192 | #endif |
|---|