35 :
TeamId(0), Type(0), TeamName(), CaptainGuid(), BackgroundColor(0), EmblemStyle(0), EmblemColor(0),
36 BorderStyle(0), BorderColor(0), PreviousOpponents(0)
39 Stats.SeasonGames = 0;
96 std::string playerName;
108 playerName = player->
GetName();
112 playerName = characterInfo->Name;
113 playerClass = characterInfo->Class;
126 uint16 personalRating = 0;
131 personalRating = 1000;
141 matchMakerRating = (*result)[0].GetUInt16();
151 newMember.
Name = playerName;
152 newMember.
Guid = playerGuid;
153 newMember.
Class = playerClass;
192 Field* fields = result->Fetch();
196 CaptainGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt32());
218 bool captainPresentInTeam =
false;
222 Field* fields = result->Fetch();
235 newMember.
Guid = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32());
246 if (newMember.
Name.empty())
248 TC_LOG_ERROR(
"sql.sql",
"ArenaTeam {} has member with empty name - probably {} doesn't exist, deleting him from memberlist!", arenaTeamId, newMember.
Guid.
ToString());
255 captainPresentInTeam =
true;
261 while (result->NextRow());
263 if (
Empty() || !captainPresentInTeam)
266 TC_LOG_DEBUG(
"bg.arena",
"ArenaTeam {} does not have any members or its captain is not in team, disbanding it...",
TeamId);
308 TC_LOG_DEBUG(
"bg.arena",
"Player: {} {} promoted player: {} {} to leader of arena team [Id: {}, Name: {}] [Type: {}].",
321 for (MemberList::iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
326 if (group && playerMember->GetGroup() && group->
GetGUID() == playerMember->GetGroup()->GetGUID())
339 playerMember->RemoveBattlegroundQueueId(bgQueue);
343 playerMember->SendDirectMessage(battlefieldStatus.
Write());
349 if (itr->Guid == guid)
389 TC_LOG_DEBUG(
"bg.arena",
"Player: {} {} disbanded arena team type: {} [Id: {}, Name: {}].", player->GetName(), player->GetGUID().ToString(),
GetType(),
GetId(),
GetName());
440 data <<
uint8(unk308);
444 for (MemberList::const_iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
449 data <<
uint8((player ? 1 : 0));
453 data <<
uint8(itr->Class);
454 data <<
uint32(itr->WeekGames);
455 data <<
uint32(itr->WeekWins);
456 data <<
uint32(itr->SeasonGames);
457 data <<
uint32(itr->SeasonWins);
458 data <<
uint32(itr->PersonalRating);
467 TC_LOG_DEBUG(
"network",
"WORLD: Sent SMSG_ARENA_TEAM_ROSTER");
482 TC_LOG_DEBUG(
"network",
"WORLD: Sent SMSG_ARENA_TEAM_QUERY_RESPONSE");
502 for (MemberList::const_iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
549 for (MemberList::const_iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
551 player->SendDirectMessage(packet);
557 data <<
uint8(event);
558 data <<
uint8(strCount);
567 data << str1 << str2;
570 data << str1 << str2 << str3;
573 TC_LOG_ERROR(
"bg.arena",
"Unhandled strCount {} in ArenaTeam::BroadcastEvent", strCount);
582 TC_LOG_DEBUG(
"network",
"WORLD: Sent SMSG_ARENA_TEAM_EVENT");
591 packet.
Invites.emplace_back(member.Guid, 0);
606 TC_LOG_ERROR(
"bg.arena",
"FATAL: Unknown arena team type {} for some arena team", type);
620 TC_LOG_ERROR(
"bg.arena",
"FATAL: Unknown arena team slot {} for some arena team", slot);
626 for (MemberList::const_iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
627 if (itr->Guid == guid)
638 uint32 rating = memberRating + 150 <
Stats.Rating ? memberRating :
Stats.Rating;
643 points = (float)rating * 0.22f + 14.0f;
648 points = 1511.26f / (1.0f + 1639.28f * std::exp(-0.00412f *
float(rating)));
666 uint32 matchMakerRating = 0;
668 for (MemberList::const_iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
678 matchMakerRating += itr->MatchMakerRating;
683 if (playerDivider == 0)
686 matchMakerRating /= playerDivider;
688 return matchMakerRating;
695 return 1.0f / (1.0f + std::exp(std::log(10.0f) * (
float(opponentRating) -
float(ownRating)) / 650.0f));
703 float won_mod = (won) ? 1.0f : 0.0f;
704 float mod = won_mod - chance;
721 return (
int32)ceil(mod);
736 if (ownRating < 1300)
740 if (ownRating < 1000)
741 mod = win_rating_modifier1 * (1.0f - chance);
743 mod = ((win_rating_modifier1 / 2.0f) + ((win_rating_modifier1 / 2.0f) * (1300.0f - float(ownRating)) / 300.0f)) * (1.0f - chance);
751 return (
int32)ceil(mod);
764 for (MemberList::iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
770 Stats.WeekGames += 1;
771 Stats.SeasonGames += 1;
776 if (team->GetType() ==
Type && team->GetStats().Rating >
Stats.Rating)
794 Stats.SeasonWins += 1;
819 for (MemberList::iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
821 if (itr->Guid == player->
GetGUID())
825 itr->ModifyPersonalRating(player, mod,
GetType());
828 itr->ModifyMatchmakerRating(MatchmakerRatingChange,
GetSlot());
832 itr->SeasonGames +=1;
845 for (MemberList::iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
847 if (itr->Guid == guid)
851 itr->ModifyPersonalRating(
nullptr, mod,
GetType());
854 itr->ModifyMatchmakerRating(MatchmakerRatingChange,
GetSlot());
858 itr->SeasonGames += 1;
867 for (MemberList::iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
869 if (itr->Guid == player->
GetGUID())
873 itr->ModifyPersonalRating(player, mod,
GetType());
876 itr->ModifyMatchmakerRating(MatchmakerRatingChange,
GetSlot());
880 itr->SeasonGames +=1;
881 itr->SeasonWins += 1;
896 if (
Stats.WeekGames < 10)
902 for (MemberList::const_iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
906 if (itr->WeekGames >= requiredGames)
907 pointsToAdd =
GetPoints(itr->PersonalRating);
909 std::map<ObjectGuid, uint32>::iterator plr_itr = playerPoints.find(itr->Guid);
910 if (plr_itr != playerPoints.end())
913 if (plr_itr->second < pointsToAdd)
914 playerPoints[itr->Guid] = pointsToAdd;
917 playerPoints[itr->Guid] = pointsToAdd;
938 for (MemberList::const_iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
941 if (itr->WeekGames == 0 && !forceMemberSave)
951 stmt->
setUInt32(6, itr->Guid.GetCounter());
955 stmt->
setUInt32(0, itr->Guid.GetCounter());
957 stmt->
setUInt16(2, itr->MatchMakerRating);
967 if (
Stats.WeekGames == 0)
975 for (MemberList::iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
986 for (MemberList::const_iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
988 if (player->GetMap()->IsBattleArena())
996 for (MemberList::iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
997 if (itr->Name == name)
1005 for (MemberList::iterator itr =
Members.begin(); itr !=
Members.end(); ++itr)
1006 if (itr->Guid == guid)
@ ERR_ARENA_TEAM_DISBANDED_S
@ CHAR_DEL_ARENA_TEAM_MEMBERS
@ CHAR_UPD_ARENA_TEAM_STATS
@ CHAR_INS_ARENA_TEAM_MEMBER
@ CHAR_REP_CHARACTER_ARENA_STATS
@ CHAR_UPD_ARENA_TEAM_MEMBER
@ CHAR_SEL_MATCH_MAKER_RATING
@ CHAR_UPD_ARENA_TEAM_NAME
@ CHAR_UPD_ARENA_TEAM_CAPTAIN
@ CHAR_DEL_ARENA_TEAM_MEMBER
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_TEAM_RATING
@ ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_PERSONAL_RATING
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
std::shared_ptr< ResultSet > QueryResult
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
#define TC_LOG_DEBUG(filterType__,...)
#define TC_LOG_ERROR(filterType__,...)
@ ARENA_TEAM_PERSONAL_RATING
@ ARENA_TEAM_GAMES_SEASON
#define PLAYER_MAX_BATTLEGROUND_QUEUES
void SaveToDB(bool forceMemberSave=false)
void Inspect(WorldSession *session, ObjectGuid guid)
void Roster(WorldSession *session)
ObjectGuid GetCaptain() const
bool LoadArenaTeamFromDB(QueryResult arenaTeamDataResult)
void OfflineMemberLost(ObjectGuid guid, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange=-12)
int32 LostAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32 &rating_change)
float GetChanceAgainst(uint32 ownRating, uint32 opponentRating)
int32 GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won)
size_t GetMembersSize() const
void DelMember(ObjectGuid guid, bool cleanDb)
void MemberLost(Player *player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange=-12)
bool IsMember(ObjectGuid guid) const
bool SetName(std::string const &name)
bool Create(ObjectGuid captainGuid, uint8 type, std::string const &teamName, uint32 backgroundColor, uint8 emblemStyle, uint32 emblemColor, uint8 borderStyle, uint32 borderColor)
int32 GetMatchmakerRatingMod(uint32 ownRating, uint32 opponentRating, bool won)
void SendStats(WorldSession *session)
int32 WonAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32 &rating_change)
void Query(WorldSession *session)
void SetCaptain(ObjectGuid guid)
bool AddMember(ObjectGuid PlayerGuid)
ArenaTeamMember * GetMember(ObjectGuid guid)
void FinishGame(int32 mod)
void UpdateArenaPointsHelper(std::map< ObjectGuid, uint32 > &PlayerPoints)
void BroadcastEvent(ArenaTeamEvents event, ObjectGuid guid, uint8 strCount, std::string const &str1, std::string const &str2, std::string const &str3)
void NotifyStatsChanged()
void MassInviteToEvent(WorldSession *session)
void BroadcastPacket(WorldPacket *packet)
uint32 GetAverageMMR(Group *group) const
std::string const & GetName() const
uint32 GetPoints(uint32 MemberRating)
static uint8 GetTypeBySlot(uint8 slot)
bool LoadMembersFromDB(QueryResult arenaTeamMembersResult)
void MemberWon(Player *player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange)
static uint8 GetSlotByType(uint32 type)
static void BuildBattlegroundStatusNone(WorldPackets::Battleground::BattlefieldStatusNone *battlefieldStatus, uint32 queueSlot)
bool GetPlayerGroupInfoData(ObjectGuid guid, GroupQueueInfo *ginfo)
void RemovePlayer(ObjectGuid guid, bool decreaseInvitedCount)
Class used to access individual fields of database query result.
std::string GetString() const
ObjectGuid GetGUID() const
bool IsMember(ObjectGuid guid) const
LowType GetCounter() const
static ObjectGuid const Empty
std::string ToString() const
static bool IsValidCharterName(std::string_view name)
static ObjectGuid GetGUID(Object const *o)
void SetArenaTeamInfoField(uint8 slot, ArenaTeamInfoType type, uint32 value)
void UpdateAchievementCriteria(AchievementCriteriaTypes type, uint32 miscValue1=0, uint32 miscValue2=0, WorldObject *ref=nullptr)
void SetInArenaTeam(uint32 ArenaTeamId, uint8 slot, uint8 type)
WorldSession * GetSession() const
uint32 GetArenaTeamId(uint8 slot) const
void SetArenaTeamIdInvited(uint32 ArenaTeamId)
static void RemovePetitionsAndSigns(ObjectGuid guid, CharterTypes type)
void setUInt16(uint8 index, uint16 value)
void setUInt32(uint8 index, uint32 value)
void setUInt8(uint8 index, uint8 value)
void setString(uint8 index, std::string const &value)
std::string const & GetName() const
WorldPacket const * Write() override
WorldPacket const * Write() override
std::vector< CalendarEventInitialInviteInfo > Invites
Player session in the World.
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Player * GetPlayer() const
void SendArenaTeamCommandResult(uint32 team_action, std::string const &team, std::string const &player, uint32 error_id=0)
std::string const & GetPlayerName() const
@ MSG_INSPECT_ARENA_TEAMS
@ SMSG_ARENA_TEAM_QUERY_RESPONSE
@ CONFIG_ARENA_START_MATCHMAKER_RATING
@ CONFIG_ARENA_START_RATING
@ CONFIG_ARENA_START_PERSONAL_RATING
@ CONFIG_ARENA_WIN_RATING_MODIFIER_1
@ CONFIG_ARENA_WIN_RATING_MODIFIER_2
@ CONFIG_ARENA_LOSE_RATING_MODIFIER
@ CONFIG_ARENA_MATCHMAKER_RATING_MODIFIER
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
void ModifyPersonalRating(Player *player, int32 mod, uint32 type)
void ModifyMatchmakerRating(int32 mod, uint32 slot)
uint16 BattlemasterListId
uint32 IsInvitedToBGInstanceGUID