TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ArenaTeam Class Reference

#include <ArenaTeam.h>

Public Types

typedef std::list
< ArenaTeamMember
MemberList
 

Public Member Functions

 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 ()
 
uint32 GetId () const
 
uint32 GetType () const
 
uint8 GetSlot () const
 
ObjectGuid GetCaptain () const
 
std::string constGetName () const
 
const ArenaTeamStatsGetStats () const
 
uint32 GetRating () const
 
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
 
bool Empty () const
 
MemberList::iterator m_membersBegin ()
 
MemberList::iterator m_membersEnd ()
 
bool IsMember (ObjectGuid guid) const
 
ArenaTeamMemberGetMember (ObjectGuid guid)
 
ArenaTeamMemberGetMember (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)
 

Static Public Member Functions

static uint8 GetSlotByType (uint32 type)
 
static uint8 GetTypeBySlot (uint8 slot)
 

Protected Attributes

uint32 TeamId
 
uint8 Type
 
std::string TeamName
 
ObjectGuid CaptainGuid
 
uint32 BackgroundColor
 
uint8 EmblemStyle
 
uint32 EmblemColor
 
uint8 BorderStyle
 
uint32 BorderColor
 
MemberList Members
 
ArenaTeamStats Stats
 

Member Typedef Documentation

Constructor & Destructor Documentation

ArenaTeam::ArenaTeam ( )
32 {
33  Stats.WeekGames = 0;
34  Stats.SeasonGames = 0;
35  Stats.Rank = 0;
36  Stats.Rating = sWorld->getIntConfig(CONFIG_ARENA_START_RATING);
37  Stats.WeekWins = 0;
38  Stats.SeasonWins = 0;
39 }
Definition: World.h:310
uint8 EmblemStyle
Definition: ArenaTeam.h:187
Stats
Definition: SharedDefines.h:235
#define sWorld
Definition: World.h:887
uint8 Type
Definition: ArenaTeam.h:182
ObjectGuid CaptainGuid
Definition: ArenaTeam.h:184
uint8 BorderStyle
Definition: ArenaTeam.h:189
uint32 BorderColor
Definition: ArenaTeam.h:190
uint32 BackgroundColor
Definition: ArenaTeam.h:186
std::string TeamName
Definition: ArenaTeam.h:183
uint32 EmblemColor
Definition: ArenaTeam.h:188
uint32 TeamId
Definition: ArenaTeam.h:181
ArenaTeam::~ArenaTeam ( )
42 { }

Member Function Documentation

bool ArenaTeam::AddMember ( ObjectGuid  PlayerGuid)
90 {
91  std::string playerName;
92  uint8 playerClass;
93 
94  // Check if arena team is full (Can't have more than type * 2 players)
95  if (GetMembersSize() >= GetType() * 2)
96  return false;
97 
98  // Get player name and class either from db or ObjectMgr
99  Player* player = ObjectAccessor::FindPlayer(playerGuid);
100  if (player)
101  {
102  playerClass = player->getClass();
103  playerName = player->GetName();
104  }
105  else if (CharacterInfo const* characterInfo = sWorld->GetCharacterInfo(playerGuid))
106  {
107  playerName = characterInfo->Name;
108  playerClass = characterInfo->Class;
109  }
110  else
111  return false;
112 
113  // Check if player is already in a similar arena team
114  if ((player && player->GetArenaTeamId(GetSlot())) || Player::GetArenaTeamIdFromDB(playerGuid, GetType()) != 0)
115  {
116  TC_LOG_DEBUG("bg.arena", "Arena: %s %s already has an arena team of type %u", playerGuid.ToString().c_str(), playerName.c_str(), GetType());
117  return false;
118  }
119 
120  // Set player's personal rating
121  uint32 personalRating = 0;
122 
123  if (sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING) > 0)
124  personalRating = sWorld->getIntConfig(CONFIG_ARENA_START_PERSONAL_RATING);
125  else if (GetRating() >= 1000)
126  personalRating = 1000;
127 
128  // Try to get player's match maker rating from db and fall back to config setting if not found
130  stmt->setUInt64(0, playerGuid.GetCounter());
131  stmt->setUInt8(1, GetSlot());
133 
134  uint32 matchMakerRating;
135  if (result)
136  matchMakerRating = (*result)[0].GetUInt16();
137  else
138  matchMakerRating = sWorld->getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING);
139 
140  // Remove all player signatures from other petitions
141  // This will prevent player from joining too many arena teams and corrupt arena team data integrity
142  //Player::RemovePetitionsAndSigns(playerGuid, GetType()); /// @todo arena teams removed in 5.4
143 
144  // Feed data to the struct
145  ArenaTeamMember newMember;
146  newMember.Name = playerName;
147  newMember.Guid = playerGuid;
148  newMember.Class = playerClass;
149  newMember.SeasonGames = 0;
150  newMember.WeekGames = 0;
151  newMember.SeasonWins = 0;
152  newMember.WeekWins = 0;
153  newMember.PersonalRating = personalRating;
154  newMember.MatchMakerRating = matchMakerRating;
155 
156  Members.push_back(newMember);
157 
158  // Save player's arena team membership to db
160  stmt->setUInt32(0, TeamId);
161  stmt->setUInt64(1, playerGuid.GetCounter());
163 
164  // Inform player if online
165  if (player)
166  {
167  player->SetInArenaTeam(TeamId, GetSlot(), GetType());
168  player->SetArenaTeamIdInvited(0);
169 
170  // Hide promote/remove buttons
171  if (CaptainGuid != playerGuid)
172  player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1);
173  }
174 
175  TC_LOG_DEBUG("bg.arena", "Player: %s [%s] joined arena team type: %u [Id: %u, Name: %s].", playerName.c_str(), playerGuid.ToString().c_str(), GetType(), GetId(), GetName().c_str());
176 
177  return true;
178 }
size_t GetMembersSize() const
Definition: ArenaTeam.h:141
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
uint16 PersonalRating
Definition: ArenaTeam.h:93
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint8 Class
Definition: ArenaTeam.h:88
uint32 GetType() const
Definition: ArenaTeam.h:125
uint16 MatchMakerRating
Definition: ArenaTeam.h:94
std::string const & GetName() const
Definition: ArenaTeam.h:130
Definition: CharacterDatabase.h:153
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
uint16 WeekWins
Definition: ArenaTeam.h:90
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sWorld
Definition: World.h:887
uint16 WeekGames
Definition: ArenaTeam.h:89
Definition: PreparedStatement.h:74
uint32 GetRating() const
Definition: ArenaTeam.h:133
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
ObjectGuid CaptainGuid
Definition: ArenaTeam.h:184
Definition: World.h:311
uint32 GetId() const
Definition: ArenaTeam.h:124
Definition: World.h:532
MemberList Members
Definition: ArenaTeam.h:192
uint32_t uint32
Definition: Define.h:150
Definition: CharacterDatabase.h:252
uint16 SeasonGames
Definition: ArenaTeam.h:91
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
ObjectGuid Guid
Definition: ArenaTeam.h:86
TeamId
Definition: SharedDefines.h:990
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint16 SeasonWins
Definition: ArenaTeam.h:92
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8 GetSlot() const
Definition: ArenaTeam.h:126
uint8_t uint8
Definition: Define.h:152
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
std::string Name
Definition: ArenaTeam.h:87
Definition: ArenaTeam.h:84

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ArenaTeam::BroadcastPacket ( WorldPacket packet)
452 {
453  for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
454  if (Player* player = ObjectAccessor::FindConnectedPlayer(itr->Guid))
455  player->GetSession()->SendPacket(packet);
456 }
MemberList Members
Definition: ArenaTeam.h:192
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

bool ArenaTeam::Create ( ObjectGuid  captainGuid,
uint8  type,
std::string const teamName,
uint32  backgroundColor,
uint8  emblemStyle,
uint32  emblemColor,
uint8  borderStyle,
uint32  borderColor 
)
45 {
46  // Check if captain is present
47  if (!ObjectAccessor::FindPlayer(captainGuid))
48  return false;
49 
50  // Check if arena team name is already taken
51  if (sArenaTeamMgr->GetArenaTeamByName(teamName))
52  return false;
53 
54  // Generate new arena team id
55  TeamId = sArenaTeamMgr->GenerateArenaTeamId();
56 
57  // Assign member variables
58  CaptainGuid = captainGuid;
59  Type = type;
60  TeamName = teamName;
61  BackgroundColor = backgroundColor;
62  EmblemStyle = emblemStyle;
63  EmblemColor = emblemColor;
64  BorderStyle = borderStyle;
65  BorderColor = borderColor;
66  ObjectGuid::LowType captainLowGuid = captainGuid.GetCounter();
67 
68  // Save arena team to db
70  stmt->setUInt32(0, TeamId);
71  stmt->setString(1, TeamName);
72  stmt->setUInt64(2, captainLowGuid);
73  stmt->setUInt8(3, Type);
74  stmt->setUInt16(4, Stats.Rating);
75  stmt->setUInt32(5, BackgroundColor);
76  stmt->setUInt8(6, EmblemStyle);
77  stmt->setUInt32(7, EmblemColor);
78  stmt->setUInt8(8, BorderStyle);
79  stmt->setUInt32(9, BorderColor);
81 
82  // Add captain as member
84 
85  TC_LOG_DEBUG("bg.arena", "New ArenaTeam created [Id: %u, Name: %s] [Type: %u] [Captain low GUID: " UI64FMTD "]", GetId(), GetName().c_str(), GetType(), captainLowGuid);
86  return true;
87 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
uint8 EmblemStyle
Definition: ArenaTeam.h:187
uint32 GetType() const
Definition: ArenaTeam.h:125
std::string const & GetName() const
Definition: ArenaTeam.h:130
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
Stats
Definition: SharedDefines.h:235
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint64 LowType
Definition: ObjectGuid.h:199
Definition: PreparedStatement.h:74
Definition: CharacterDatabase.h:251
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
ObjectGuid CaptainGuid
Definition: ArenaTeam.h:184
uint8 BorderStyle
Definition: ArenaTeam.h:189
uint32 GetId() const
Definition: ArenaTeam.h:124
uint32 BorderColor
Definition: ArenaTeam.h:190
#define UI64FMTD
Definition: Define.h:137
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
uint32 BackgroundColor
Definition: ArenaTeam.h:186
std::string TeamName
Definition: ArenaTeam.h:183
TeamId
Definition: SharedDefines.h:990
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32 EmblemColor
Definition: ArenaTeam.h:188
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:53
bool AddMember(ObjectGuid PlayerGuid)
Definition: ArenaTeam.cpp:89
Type
Type of JSON value.
Definition: rapidjson.h:642
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ArenaTeam::DelMember ( ObjectGuid  guid,
bool  cleanDb 
)
308 {
309  // Remove member from team
310  for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
311  if (itr->Guid == guid)
312  {
313  Members.erase(itr);
314  break;
315  }
316 
317  // Remove arena team info from player data
318  if (Player* player = ObjectAccessor::FindPlayer(guid))
319  {
320  // delete all info regarding this team
321  for (uint32 i = 0; i < ARENA_TEAM_END; ++i)
322  player->SetArenaTeamInfoField(GetSlot(), ArenaTeamInfoType(i), 0);
323  TC_LOG_DEBUG("bg.arena", "Player: %s [%s] left arena team type: %u [Id: %u, Name: %s].", player->GetName().c_str(), player->GetGUID().ToString().c_str(), GetType(), GetId(), GetName().c_str());
324  }
325 
326  // Only used for single member deletion, for arena team disband we use a single query for more efficiency
327  if (cleanDb)
328  {
330  stmt->setUInt32(0, GetId());
331  stmt->setUInt64(1, guid.GetCounter());
333  }
334 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
uint32 GetType() const
Definition: ArenaTeam.h:125
std::string const & GetName() const
Definition: ArenaTeam.h:130
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: PreparedStatement.h:74
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
Definition: CharacterDatabase.h:256
uint32 GetId() const
Definition: ArenaTeam.h:124
MemberList Members
Definition: ArenaTeam.h:192
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8 GetSlot() const
Definition: ArenaTeam.h:126
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ArenaTeam::Disband ( WorldSession session)
337 {
338  // Broadcast update
339  if (session)
340  {
341  if (Player* player = session->GetPlayer())
342  TC_LOG_DEBUG("bg.arena", "Player: %s [%s] disbanded arena team type: %u [Id: %u, Name: %s].", player->GetName().c_str(), player->GetGUID().ToString().c_str(), GetType(), GetId(), GetName().c_str());
343  }
344 
345  // Remove all members from arena team
346  while (!Members.empty())
347  DelMember(Members.front().Guid, false);
348 
349  // Update database
351 
353  stmt->setUInt32(0, TeamId);
354  trans->Append(stmt);
355 
357  stmt->setUInt32(0, TeamId);
358  trans->Append(stmt);
359 
361 
362  // Remove arena team from ObjectMgr
363  sArenaTeamMgr->RemoveArenaTeam(TeamId);
364 }
uint32 GetType() const
Definition: ArenaTeam.h:125
std::string const & GetName() const
Definition: ArenaTeam.h:130
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: PreparedStatement.h:74
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
uint32 GetId() const
Definition: ArenaTeam.h:124
MemberList Members
Definition: ArenaTeam.h:192
Definition: CharacterDatabase.h:253
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
TeamId
Definition: SharedDefines.h:990
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void DelMember(ObjectGuid guid, bool cleanDb)
Definition: ArenaTeam.cpp:307
Definition: CharacterDatabase.h:254
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:53
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ArenaTeam::Disband ( )
367 {
368  // Remove all members from arena team
369  while (!Members.empty())
370  DelMember(Members.front().Guid, false);
371 
372  // Update database
374 
376  stmt->setUInt32(0, TeamId);
377  trans->Append(stmt);
378 
380  stmt->setUInt32(0, TeamId);
381  trans->Append(stmt);
382 
384 
385  // Remove arena team from ObjectMgr
386  sArenaTeamMgr->RemoveArenaTeam(TeamId);
387 }
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
Definition: PreparedStatement.h:74
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
MemberList Members
Definition: ArenaTeam.h:192
Definition: CharacterDatabase.h:253
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
TeamId
Definition: SharedDefines.h:990
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void DelMember(ObjectGuid guid, bool cleanDb)
Definition: ArenaTeam.cpp:307
Definition: CharacterDatabase.h:254
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:53
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

bool ArenaTeam::Empty ( ) const
inline
142 { return Members.empty(); }
MemberList Members
Definition: ArenaTeam.h:192

+ Here is the caller graph for this function:

void ArenaTeam::FinishGame ( int32  mod)
589 {
590  // Rating can only drop to 0
591  if (int32(Stats.Rating) + mod < 0)
592  Stats.Rating = 0;
593  else
594  {
595  Stats.Rating += mod;
596 
597  // Check if rating related achivements are met
598  for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
599  if (Player* member = ObjectAccessor::FindConnectedPlayer(itr->Guid))
600  member->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING, Stats.Rating, Type);
601  }
602 
603  // Update number of games played per season or week
604  Stats.WeekGames += 1;
605  Stats.SeasonGames += 1;
606 
607  // Update team's rank, start with rank 1 and increase until no team with more rating was found
608  Stats.Rank = 1;
609  ArenaTeamMgr::ArenaTeamContainer::const_iterator i = sArenaTeamMgr->GetArenaTeamMapBegin();
610  for (; i != sArenaTeamMgr->GetArenaTeamMapEnd(); ++i)
611  {
612  if (i->second->GetType() == Type && i->second->GetStats().Rating > Stats.Rating)
613  ++Stats.Rank;
614  }
615 }
Stats
Definition: SharedDefines.h:235
MemberList Members
Definition: ArenaTeam.h:192
int32_t int32
Definition: g3dmath.h:167
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:53
Type
Type of JSON value.
Definition: rapidjson.h:642
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ArenaTeam::FinishWeek ( )
768 {
769  // Reset team stats
770  Stats.WeekGames = 0;
771  Stats.WeekWins = 0;
772 
773  // Reset member stats
774  for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
775  {
776  itr->WeekGames = 0;
777  itr->WeekWins = 0;
778  }
779 }
Stats
Definition: SharedDefines.h:235
MemberList Members
Definition: ArenaTeam.h:192
uint32 ArenaTeam::GetAverageMMR ( Group group) const
496 {
497  if (!group)
498  return 0;
499 
500  uint32 matchMakerRating = 0;
501  uint32 playerDivider = 0;
502  for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
503  {
504  // Skip if player is not online
505  if (!ObjectAccessor::FindConnectedPlayer(itr->Guid))
506  continue;
507 
508  // Skip if player is not a member of group
509  if (!group->IsMember(itr->Guid))
510  continue;
511 
512  matchMakerRating += itr->MatchMakerRating;
513  ++playerDivider;
514  }
515 
516  // x/0 = crash
517  if (playerDivider == 0)
518  playerDivider = 1;
519 
520  matchMakerRating /= playerDivider;
521 
522  return matchMakerRating;
523 }
MemberList Members
Definition: ArenaTeam.h:192
uint32_t uint32
Definition: Define.h:150
bool IsMember(ObjectGuid guid) const
Definition: Group.cpp:2566
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ObjectGuid ArenaTeam::GetCaptain ( ) const
inline
129 { return CaptainGuid; }
ObjectGuid CaptainGuid
Definition: ArenaTeam.h:184

+ Here is the caller graph for this function:

float ArenaTeam::GetChanceAgainst ( uint32  ownRating,
uint32  opponentRating 
)
526 {
527  // Returns the chance to win against a team with the given rating, used in the rating adjustment calculation
528  // ELO system
529  return 1.0f / (1.0f + std::exp(std::log(10.0f) * (float(opponentRating) - float(ownRating)) / 650.0f));
530 }
Quat exp(const Quat &q)
Definition: Quat.h:729
TC_SHARED_API::google::protobuf::internal::ExtensionIdentifier< ::google::protobuf::FieldOptions,::google::protobuf::internal::EnumTypeTraits< ::bgs::protocol::LogOption,::bgs::protocol::LogOption_IsValid >, 14, false > log

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 ArenaTeam::GetId ( ) const
inline
124 { return TeamId; }
uint32 TeamId
Definition: ArenaTeam.h:181

+ Here is the caller graph for this function:

int32 ArenaTeam::GetMatchmakerRatingMod ( uint32  ownRating,
uint32  opponentRating,
bool  won 
)
533 {
534  // 'Chance' calculation - to beat the opponent
535  // This is a simulation. Not much info on how it really works
536  float chance = GetChanceAgainst(ownRating, opponentRating);
537  float won_mod = (won) ? 1.0f : 0.0f;
538  float mod = won_mod - chance;
539 
540  // Work in progress:
541  /*
542  // This is a simulation, as there is not much info on how it really works
543  float confidence_mod = min(1.0f - fabs(mod), 0.5f);
544 
545  // Apply confidence factor to the mod:
546  mod *= confidence_factor
547 
548  // And only after that update the new confidence factor
549  confidence_factor -= ((confidence_factor - 1.0f) * confidence_mod) / confidence_factor;
550  */
551 
552  // Real rating modification
553  mod *= sWorld->getFloatConfig(CONFIG_ARENA_MATCHMAKER_RATING_MODIFIER);
554 
555  return (int32)ceil(mod);
556 }
#define sWorld
Definition: World.h:887
int32_t int32
Definition: Define.h:146
static Vector3int16 ceil(const Vector3 &v)
Definition: Vector3int16.cpp:55
float GetChanceAgainst(uint32 ownRating, uint32 opponentRating)
Definition: ArenaTeam.cpp:525

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ArenaTeamMember * ArenaTeam::GetMember ( ObjectGuid  guid)
801 {
802  for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
803  if (itr->Guid == guid)
804  return &(*itr);
805 
806  return NULL;
807 }
arena_t NULL
Definition: jemalloc_internal.h:624
MemberList Members
Definition: ArenaTeam.h:192

+ Here is the caller graph for this function:

ArenaTeamMember * ArenaTeam::GetMember ( std::string const name)
792 {
793  for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
794  if (itr->Name == name)
795  return &(*itr);
796 
797  return NULL;
798 }
arena_t NULL
Definition: jemalloc_internal.h:624
MemberList Members
Definition: ArenaTeam.h:192
size_t ArenaTeam::GetMembersSize ( ) const
inline
141 { return Members.size(); }
MemberList Members
Definition: ArenaTeam.h:192

+ Here is the caller graph for this function:

std::string const& ArenaTeam::GetName ( ) const
inline
130 { return TeamName; }
std::string TeamName
Definition: ArenaTeam.h:183

+ Here is the caller graph for this function:

uint32 ArenaTeam::GetPoints ( uint32  MemberRating)
uint32 ArenaTeam::GetRating ( ) const
inline
133 { return Stats.Rating; }
Stats
Definition: SharedDefines.h:235

+ Here is the caller graph for this function:

int32 ArenaTeam::GetRatingMod ( uint32  ownRating,
uint32  opponentRating,
bool  won 
)
Todo:
Replace this hack with using the confidence factor (limiting the factor to 2.0f)
559 {
560  // 'Chance' calculation - to beat the opponent
561  // This is a simulation. Not much info on how it really works
562  float chance = GetChanceAgainst(ownRating, opponentRating);
563 
564  // Calculate the rating modification
565  float mod;
566 
568  if (won)
569  {
570  if (ownRating < 1300)
571  {
572  float win_rating_modifier1 = sWorld->getFloatConfig(CONFIG_ARENA_WIN_RATING_MODIFIER_1);
573 
574  if (ownRating < 1000)
575  mod = win_rating_modifier1 * (1.0f - chance);
576  else
577  mod = ((win_rating_modifier1 / 2.0f) + ((win_rating_modifier1 / 2.0f) * (1300.0f - float(ownRating)) / 300.0f)) * (1.0f - chance);
578  }
579  else
580  mod = sWorld->getFloatConfig(CONFIG_ARENA_WIN_RATING_MODIFIER_2) * (1.0f - chance);
581  }
582  else
583  mod = sWorld->getFloatConfig(CONFIG_ARENA_LOSE_RATING_MODIFIER) * (-chance);
584 
585  return (int32)ceil(mod);
586 }
#define sWorld
Definition: World.h:887
Definition: World.h:202
Definition: World.h:201
int32_t int32
Definition: Define.h:146
static Vector3int16 ceil(const Vector3 &v)
Definition: Vector3int16.cpp:55
float GetChanceAgainst(uint32 ownRating, uint32 opponentRating)
Definition: ArenaTeam.cpp:525
Definition: World.h:200

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint8 ArenaTeam::GetSlot ( ) const
inline
126 { return GetSlotByType(GetType()); }
uint32 GetType() const
Definition: ArenaTeam.h:125
static uint8 GetSlotByType(uint32 type)
Definition: ArenaTeam.cpp:458

+ Here is the caller graph for this function:

uint8 ArenaTeam::GetSlotByType ( uint32  type)
static
459 {
460  switch (type)
461  {
462  case ARENA_TEAM_2v2: return 0;
463  case ARENA_TEAM_3v3: return 1;
464  case ARENA_TEAM_5v5: return 2;
465  default:
466  break;
467  }
468  TC_LOG_ERROR("bg.arena", "FATAL: Unknown arena team type %u for some arena team", type);
469  return 0xFF;
470 }
Definition: ArenaTeam.h:80
Definition: ArenaTeam.h:81
Definition: ArenaTeam.h:79
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the caller graph for this function:

const ArenaTeamStats& ArenaTeam::GetStats ( ) const
inline
131 { return Stats; }
ArenaTeamStats Stats
Definition: ArenaTeam.h:193
uint32 ArenaTeam::GetType ( ) const
inline
125 { return Type; }
uint8 Type
Definition: ArenaTeam.h:182

+ Here is the caller graph for this function:

uint8 ArenaTeam::GetTypeBySlot ( uint8  slot)
static
473 {
474  switch (slot)
475  {
476  case 0: return ARENA_TEAM_2v2;
477  case 1: return ARENA_TEAM_3v3;
478  case 2: return ARENA_TEAM_5v5;
479  default:
480  break;
481  }
482  TC_LOG_ERROR("bg.arena", "FATAL: Unknown arena team slot %u for some arena team", slot);
483  return 0xFF;
484 }
Definition: ArenaTeam.h:80
Definition: ArenaTeam.h:81
Definition: ArenaTeam.h:79
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the caller graph for this function:

void ArenaTeam::Inspect ( WorldSession session,
ObjectGuid  guid 
)
412 {
413  ArenaTeamMember* member = GetMember(guid);
414  if (!member)
415  return;
416 
417  //WorldPacket data(MSG_INSPECT_ARENA_TEAMS, 8+1+4*6);
418  //data << guid; // player guid
419  //data << uint8(GetSlot()); // slot (0...2)
420  //data << uint32(GetId()); // arena team id
421  //data << uint32(Stats.Rating); // rating
422  //data << uint32(Stats.SeasonGames); // season played
423  //data << uint32(Stats.SeasonWins); // season wins
424  //data << uint32(member->SeasonGames); // played (count of all games, that the inspected member participated...)
425  //data << uint32(member->PersonalRating); // personal rating
426  //session->SendPacket(&data);
427 }
ArenaTeamMember * GetMember(ObjectGuid guid)
Definition: ArenaTeam.cpp:800
Definition: ArenaTeam.h:84

+ Here is the call graph for this function:

bool ArenaTeam::IsFighting ( ) const
782 {
783  for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
784  if (Player* player = ObjectAccessor::FindPlayer(itr->Guid))
785  if (player->GetMap()->IsBattleArena())
786  return true;
787 
788  return false;
789 }
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
MemberList Members
Definition: ArenaTeam.h:192

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ArenaTeam::IsMember ( ObjectGuid  guid) const
487 {
488  for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
489  if (itr->Guid == guid)
490  return true;
491 
492  return false;
493 }
MemberList Members
Definition: ArenaTeam.h:192

+ Here is the caller graph for this function:

bool ArenaTeam::LoadArenaTeamFromDB ( QueryResult  arenaTeamDataResult)
181 {
182  if (!result)
183  return false;
184 
185  Field* fields = result->Fetch();
186 
187  TeamId = fields[0].GetUInt32();
188  TeamName = fields[1].GetString();
189  CaptainGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt64());
190  Type = fields[3].GetUInt8();
191  BackgroundColor = fields[4].GetUInt32();
192  EmblemStyle = fields[5].GetUInt8();
193  EmblemColor = fields[6].GetUInt32();
194  BorderStyle = fields[7].GetUInt8();
195  BorderColor = fields[8].GetUInt32();
196  Stats.Rating = fields[9].GetUInt16();
197  Stats.WeekGames = fields[10].GetUInt16();
198  Stats.WeekWins = fields[11].GetUInt16();
199  Stats.SeasonGames = fields[12].GetUInt16();
200  Stats.SeasonWins = fields[13].GetUInt16();
201  Stats.Rank = fields[14].GetUInt32();
202 
203  return true;
204 }
uint64 GetUInt64() const
Definition: Field.h:184
uint8 EmblemStyle
Definition: ArenaTeam.h:187
Class used to access individual fields of database query result.
Definition: Field.h:56
Stats
Definition: SharedDefines.h:235
uint8 GetUInt8() const
Definition: Field.h:70
ObjectGuid CaptainGuid
Definition: ArenaTeam.h:184
uint8 BorderStyle
Definition: ArenaTeam.h:189
uint32 BorderColor
Definition: ArenaTeam.h:190
uint16 GetUInt16() const
Definition: Field.h:108
uint32 BackgroundColor
Definition: ArenaTeam.h:186
std::string TeamName
Definition: ArenaTeam.h:183
TeamId
Definition: SharedDefines.h:990
uint32 GetUInt32() const
Definition: Field.h:146
uint32 EmblemColor
Definition: ArenaTeam.h:188
Type
Type of JSON value.
Definition: rapidjson.h:642
std::string GetString() const
Definition: Field.h:276

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ArenaTeam::LoadMembersFromDB ( QueryResult  arenaTeamMembersResult)
207 {
208  if (!result)
209  return false;
210 
211  bool captainPresentInTeam = false;
212 
213  do
214  {
215  Field* fields = result->Fetch();
216 
217  // Prevent crash if db records are broken when all members in result are already processed and current team doesn't have any members
218  if (!fields)
219  break;
220 
221  uint32 arenaTeamId = fields[0].GetUInt32();
222 
223  // We loaded all members for this arena_team already, break cycle
224  if (arenaTeamId > TeamId)
225  break;
226 
227  ArenaTeamMember newMember;
228  newMember.Guid = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt64());
229  newMember.WeekGames = fields[2].GetUInt16();
230  newMember.WeekWins = fields[3].GetUInt16();
231  newMember.SeasonGames = fields[4].GetUInt16();
232  newMember.SeasonWins = fields[5].GetUInt16();
233  newMember.Name = fields[6].GetString();
234  newMember.Class = fields[7].GetUInt8();
235  newMember.PersonalRating = fields[8].GetUInt16();
236  newMember.MatchMakerRating = fields[9].GetUInt16() > 0 ? fields[9].GetUInt16() : sWorld->getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING);
237 
238  // Delete member if character information is missing
239  if (newMember.Name.empty())
240  {
241  TC_LOG_ERROR("sql.sql", "ArenaTeam %u has member with empty name - probably %s doesn't exist, deleting him from memberlist!", arenaTeamId, newMember.Guid.ToString().c_str());
242  DelMember(newMember.Guid, true);
243  continue;
244  }
245 
246  // Check if team team has a valid captain
247  if (newMember.Guid == GetCaptain())
248  captainPresentInTeam = true;
249 
250  // Put the player in the team
251  Members.push_back(newMember);
252  }
253  while (result->NextRow());
254 
255  if (Empty() || !captainPresentInTeam)
256  {
257  // Arena team is empty or captain is not in team, delete from db
258  TC_LOG_DEBUG("bg.arena", "ArenaTeam %u does not have any members or its captain is not in team, disbanding it...", TeamId);
259  return false;
260  }
261 
262  return true;
263 }
uint16 PersonalRating
Definition: ArenaTeam.h:93
uint64 GetUInt64() const
Definition: Field.h:184
uint8 Class
Definition: ArenaTeam.h:88
uint16 MatchMakerRating
Definition: ArenaTeam.h:94
Class used to access individual fields of database query result.
Definition: Field.h:56
uint16 WeekWins
Definition: ArenaTeam.h:90
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sWorld
Definition: World.h:887
uint16 WeekGames
Definition: ArenaTeam.h:89
uint8 GetUInt8() const
Definition: Field.h:70
bool Empty() const
Definition: ArenaTeam.h:142
MemberList Members
Definition: ArenaTeam.h:192
uint32_t uint32
Definition: Define.h:150
uint16 SeasonGames
Definition: ArenaTeam.h:91
uint16 GetUInt16() const
Definition: Field.h:108
ObjectGuid Guid
Definition: ArenaTeam.h:86
TeamId
Definition: SharedDefines.h:990
void DelMember(ObjectGuid guid, bool cleanDb)
Definition: ArenaTeam.cpp:307
uint16 SeasonWins
Definition: ArenaTeam.h:92
uint32 GetUInt32() const
Definition: Field.h:146
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string Name
Definition: ArenaTeam.h:87
std::string GetString() const
Definition: Field.h:276
std::string ToString() const
Definition: ObjectGuid.cpp:99
ObjectGuid GetCaptain() const
Definition: ArenaTeam.h:129
Definition: ArenaTeam.h:84

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ArenaTeam::LoadStatsFromDB ( uint32  ArenaTeamId)
int32 ArenaTeam::LostAgainst ( uint32  Own_MMRating,
uint32  Opponent_MMRating,
int32 rating_change 
)
638 {
639  // Called when the team has lost
640  // Change in Matchmaker Rating
641  int32 mod = GetMatchmakerRatingMod(ownMMRating, opponentMMRating, false);
642 
643  // Change in Team Rating
644  ratingChange = GetRatingMod(Stats.Rating, opponentMMRating, false);
645 
646  // Modify the team stats accordingly
647  FinishGame(ratingChange);
648 
649  // return the rating change, used to display it on the results screen
650  return mod;
651 }
Stats
Definition: SharedDefines.h:235
int32 GetMatchmakerRatingMod(uint32 ownRating, uint32 opponentRating, bool won)
Definition: ArenaTeam.cpp:532
void FinishGame(int32 mod)
Definition: ArenaTeam.cpp:588
int32_t int32
Definition: Define.h:146
int32 GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won)
Definition: ArenaTeam.cpp:558

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MemberList::iterator ArenaTeam::m_membersBegin ( )
inline
143 { return Members.begin(); }
MemberList Members
Definition: ArenaTeam.h:192

+ Here is the caller graph for this function:

MemberList::iterator ArenaTeam::m_membersEnd ( )
inline
144 { return Members.end(); }
MemberList Members
Definition: ArenaTeam.h:192

+ Here is the caller graph for this function:

void ArenaTeam::MemberLost ( Player player,
uint32  againstMatchmakerRating,
int32  MatchmakerRatingChange = -12 
)
654 {
655  // Called for each participant of a match after losing
656  for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
657  {
658  if (itr->Guid == player->GetGUID())
659  {
660  // Update personal rating
661  int32 mod = GetRatingMod(itr->PersonalRating, againstMatchmakerRating, false);
662  itr->ModifyPersonalRating(player, mod, GetType());
663 
664  // Update matchmaker rating
665  itr->ModifyMatchmakerRating(matchmakerRatingChange, GetSlot());
666 
667  // Update personal played stats
668  itr->WeekGames +=1;
669  itr->SeasonGames +=1;
670 
671  // update the unit fields
672  player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->WeekGames);
673  player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->SeasonGames);
674  return;
675  }
676  }
677 }
uint32 GetType() const
Definition: ArenaTeam.h:125
MemberList Members
Definition: ArenaTeam.h:192
int32_t int32
Definition: Define.h:146
int32 GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won)
Definition: ArenaTeam.cpp:558
uint8 GetSlot() const
Definition: ArenaTeam.h:126

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ArenaTeam::MemberWon ( Player player,
uint32  againstMatchmakerRating,
int32  MatchmakerRatingChange 
)
702 {
703  // called for each participant after winning a match
704  for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
705  {
706  if (itr->Guid == player->GetGUID())
707  {
708  // update personal rating
709  int32 mod = GetRatingMod(itr->PersonalRating, againstMatchmakerRating, true);
710  itr->ModifyPersonalRating(player, mod, GetType());
711 
712  // update matchmaker rating
713  itr->ModifyMatchmakerRating(matchmakerRatingChange, GetSlot());
714 
715  // update personal stats
716  itr->WeekGames +=1;
717  itr->SeasonGames +=1;
718  itr->SeasonWins += 1;
719  itr->WeekWins += 1;
720  // update unit fields
721  player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->WeekGames);
722  player->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->SeasonGames);
723  return;
724  }
725  }
726 }
uint32 GetType() const
Definition: ArenaTeam.h:125
MemberList Members
Definition: ArenaTeam.h:192
int32_t int32
Definition: Define.h:146
int32 GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won)
Definition: ArenaTeam.cpp:558
uint8 GetSlot() const
Definition: ArenaTeam.h:126

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ArenaTeam::NotifyStatsChanged ( )
403 {
404  // This is called after a rated match ended
405  // Updates arena team stats for every member of the team (not only the ones who participated!)
406  for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
407  if (Player* player = ObjectAccessor::FindConnectedPlayer(itr->Guid))
408  SendStats(player->GetSession());
409 }
void SendStats(WorldSession *session)
Definition: ArenaTeam.cpp:389
MemberList Members
Definition: ArenaTeam.h:192
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ArenaTeam::OfflineMemberLost ( ObjectGuid  guid,
uint32  againstMatchmakerRating,
int32  MatchmakerRatingChange = -12 
)
680 {
681  // Called for offline player after ending rated arena match!
682  for (MemberList::iterator itr = Members.begin(); itr != Members.end(); ++itr)
683  {
684  if (itr->Guid == guid)
685  {
686  // update personal rating
687  int32 mod = GetRatingMod(itr->PersonalRating, againstMatchmakerRating, false);
688  itr->ModifyPersonalRating(NULL, mod, GetType());
689 
690  // update matchmaker rating
691  itr->ModifyMatchmakerRating(MatchmakerRatingChange, GetSlot());
692 
693  // update personal played stats
694  itr->WeekGames += 1;
695  itr->SeasonGames += 1;
696  return;
697  }
698  }
699 }
uint32 GetType() const
Definition: ArenaTeam.h:125
arena_t NULL
Definition: jemalloc_internal.h:624
MemberList Members
Definition: ArenaTeam.h:192
int32_t int32
Definition: Define.h:146
int32 GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won)
Definition: ArenaTeam.cpp:558
uint8 GetSlot() const
Definition: ArenaTeam.h:126

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ArenaTeam::SaveToDB ( )
729 {
730  // Save team and member stats to db
731  // Called after a match has ended or when calculating arena_points
732 
734 
736  stmt->setUInt16(0, Stats.Rating);
737  stmt->setUInt16(1, Stats.WeekGames);
738  stmt->setUInt16(2, Stats.WeekWins);
739  stmt->setUInt16(3, Stats.SeasonGames);
740  stmt->setUInt16(4, Stats.SeasonWins);
741  stmt->setUInt32(5, Stats.Rank);
742  stmt->setUInt32(6, GetId());
743  trans->Append(stmt);
744 
745  for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
746  {
748  stmt->setUInt16(0, itr->PersonalRating);
749  stmt->setUInt16(1, itr->WeekGames);
750  stmt->setUInt16(2, itr->WeekWins);
751  stmt->setUInt16(3, itr->SeasonGames);
752  stmt->setUInt16(4, itr->SeasonWins);
753  stmt->setUInt32(5, GetId());
754  stmt->setUInt64(6, itr->Guid.GetCounter());
755  trans->Append(stmt);
756 
758  stmt->setUInt64(0, itr->Guid.GetCounter());
759  stmt->setUInt8(1, GetSlot());
760  stmt->setUInt16(2, itr->MatchMakerRating);
761  trans->Append(stmt);
762  }
763 
765 }
void setUInt8(const uint8 index, const uint8 value)
Definition: PreparedStatement.cpp:97
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
Definition: CharacterDatabase.h:258
Stats
Definition: SharedDefines.h:235
Definition: PreparedStatement.h:74
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
uint32 GetId() const
Definition: ArenaTeam.h:124
MemberList Members
Definition: ArenaTeam.h:192
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
Definition: CharacterDatabase.h:257
uint8 GetSlot() const
Definition: ArenaTeam.h:126
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:260
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ArenaTeam::SendStats ( WorldSession session)
390 {
392  data << uint32(GetId()); // team id
393  data << uint32(Stats.Rating); // rating
394  data << uint32(Stats.WeekGames); // games this week
395  data << uint32(Stats.WeekWins); // wins this week
396  data << uint32(Stats.SeasonGames); // played this season
397  data << uint32(Stats.SeasonWins); // wins this season
398  data << uint32(Stats.Rank); // rank
399  session->SendPacket(&data);
400 }
Stats
Definition: SharedDefines.h:235
uint32 GetId() const
Definition: ArenaTeam.h:124
Definition: Opcodes.h:1651
void SendPacket(WorldPacket const *packet, bool forced=false)
Send a packet to the client.
Definition: WorldSession.cpp:211
uint32_t uint32
Definition: g3dmath.h:168
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ArenaTeam::SetCaptain ( ObjectGuid  guid)
279 {
280  // Disable remove/promote buttons
282  if (oldCaptain)
283  oldCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 1);
284 
285  // Set new captain
286  CaptainGuid = guid;
287 
288  // Update database
290  stmt->setUInt64(0, guid.GetCounter());
291  stmt->setUInt32(1, GetId());
293 
294  // Enable remove/promote buttons
295  if (Player* newCaptain = ObjectAccessor::FindPlayer(guid))
296  {
297  newCaptain->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_MEMBER, 0);
298  if (oldCaptain)
299  {
300  TC_LOG_DEBUG("bg.arena", "Player: %s [%s] promoted player: %s [%s] to leader of arena team [Id: %u, Name: %s] [Type: %u].",
301  oldCaptain->GetName().c_str(), oldCaptain->GetGUID().ToString().c_str(), newCaptain->GetName().c_str(),
302  newCaptain->GetGUID().ToString().c_str(), GetId(), GetName().c_str(), GetType());
303  }
304  }
305 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
uint32 GetType() const
Definition: ArenaTeam.h:125
std::string const & GetName() const
Definition: ArenaTeam.h:130
Definition: CharacterDatabase.h:255
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: PreparedStatement.h:74
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
ObjectGuid CaptainGuid
Definition: ArenaTeam.h:184
uint32 GetId() const
Definition: ArenaTeam.h:124
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
uint8 GetSlot() const
Definition: ArenaTeam.h:126
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
ObjectGuid GetCaptain() const
Definition: ArenaTeam.h:129
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ArenaTeam::SetName ( std::string const name)
266 {
267  if (TeamName == name || name.empty() || name.length() > 24 || sObjectMgr->IsReservedName(name) || !ObjectMgr::IsValidCharterName(name))
268  return false;
269 
270  TeamName = name;
272  stmt->setString(0, TeamName);
273  stmt->setUInt32(1, GetId());
275  return true;
276 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
void setString(const uint8 index, const std::string &value)
Definition: PreparedStatement.cpp:187
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: PreparedStatement.h:74
uint32 GetId() const
Definition: ArenaTeam.h:124
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
std::string TeamName
Definition: ArenaTeam.h:183
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
static bool IsValidCharterName(std::string const &name)
Definition: ObjectMgr.cpp:7605
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:262

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32 ArenaTeam::WonAgainst ( uint32  Own_MMRating,
uint32  Opponent_MMRating,
int32 rating_change 
)
618 {
619  // Called when the team has won
620  // Change in Matchmaker rating
621  int32 mod = GetMatchmakerRatingMod(ownMMRating, opponentMMRating, true);
622 
623  // Change in Team Rating
624  ratingChange = GetRatingMod(Stats.Rating, opponentMMRating, true);
625 
626  // Modify the team stats accordingly
627  FinishGame(ratingChange);
628 
629  // Update number of wins per season and week
630  Stats.WeekWins += 1;
631  Stats.SeasonWins += 1;
632 
633  // Return the rating change, used to display it on the results screen
634  return mod;
635 }
Stats
Definition: SharedDefines.h:235
int32 GetMatchmakerRatingMod(uint32 ownRating, uint32 opponentRating, bool won)
Definition: ArenaTeam.cpp:532
void FinishGame(int32 mod)
Definition: ArenaTeam.cpp:588
int32_t int32
Definition: Define.h:146
int32 GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won)
Definition: ArenaTeam.cpp:558

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

uint32 ArenaTeam::BackgroundColor
protected
uint32 ArenaTeam::BorderColor
protected
uint8 ArenaTeam::BorderStyle
protected
ObjectGuid ArenaTeam::CaptainGuid
protected
uint32 ArenaTeam::EmblemColor
protected
uint8 ArenaTeam::EmblemStyle
protected
MemberList ArenaTeam::Members
protected
ArenaTeamStats ArenaTeam::Stats
protected
uint32 ArenaTeam::TeamId
protected
std::string ArenaTeam::TeamName
protected
uint8 ArenaTeam::Type
protected

The documentation for this class was generated from the following files: