Skip to content

Commit

Permalink
fix: rating calculation and season games count
Browse files Browse the repository at this point in the history
  • Loading branch information
Helias committed Nov 2, 2024
1 parent 2bd58ad commit 2b109fe
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 17 deletions.
42 changes: 40 additions & 2 deletions conf/arena_3v3_solo_queue.conf.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@
#

Solo.3v3.Enable = 1


#
# Solo.3v3.EnableCommand
# Description: If enabled, it allows to run .qsolo rated/unrated
# Default: 1
# Value: 1 - (true)
# 0 - (false)

Solo.3v3.EnableCommand = 1

Solo.3v3.EnableTestingCommand = 1


Expand All @@ -22,9 +32,28 @@ Solo.3v3.StopGameIncomplete = 1
Solo.3v3.RatingPenalty.LeaveDuringMatch = 24
Solo.3v3.RatingPenalty.LeaveBeforeMatchStart = 50

#
# Solo.3v3.MinLevel
# Description: Min level to create an arena team
# Default: 80

Solo.3v3.MinLevel = 80
Solo.3v3.Cost = 45

#
# Solo.3v3.Cost
# Description: Costs for create an arena team
# Default: 100000 - (10 gold)

Solo.3v3.Cost = 100000

#
# Solo.3v3.ArenaPointsMulti
# Description: An 5v5 arena team with 1500 rating will gain 344 points per week (blizzlike).
# 3v3 with same rating will gain 302 points (5v5points * 0.88)
# 2v2 will gain 261 points (5v5points * 0.76)
# and 3v3soloQ will gain 167 points (5v5points * 0.64)
# With this multiplier you can modify the arenapoints for 3v3soloQ.
# Default: 0.8

Solo.3v3.ArenaPointsMulti = 0.8

Expand All @@ -36,5 +65,14 @@ Solo.3v3.ArenaPointsMulti = 0.8

Solo.3v3.ArenaPointsMinLevel = 70

Solo.3v3.VendorRating = 1

#
# Solo.3v3.VendorRating
# Description: If true, 3v3soloQ rating will use to calculate highest personal-rating (extended costs).
# Note: The vendor-item will show as not buyable (red), but players can buy it, if enabled and rating is high enough.
# Default: 0 - (false)
# 1 - (true)

Solo.3v3.VendorRating = 0

Solo.3v3.ShowMessageOnLogin = 0
41 changes: 29 additions & 12 deletions src/solo3v3_sc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
*/

#include "solo3v3_sc.h"
#include <unordered_map>

struct ArenaTeamsRating {
uint32 allianceRating;
uint32 hordeRating;
uint8 playersCount = 0;
};
std::unordered_map<uint32, ArenaTeamsRating> bgArenaTeamsRating;

void NpcSolo3v3::Initialize()
{
Expand Down Expand Up @@ -511,8 +519,14 @@ void Solo3v3BG::OnQueueUpdate(BattlegroundQueue* queue, uint32 /*diff*/, Battleg
arena->SetArenaTeamIdForTeam(TEAM_ALLIANCE, arenaTeams[TEAM_ALLIANCE]->GetId());
arena->SetArenaTeamIdForTeam(TEAM_HORDE, arenaTeams[TEAM_HORDE]->GetId());

oldTeamRatingAlliance = arenaTeams[TEAM_ALLIANCE]->GetStats().Rating;
oldTeamRatingHorde = arenaTeams[TEAM_HORDE]->GetStats().Rating;
if (isRated) {
ArenaTeamsRating arenaTeamsRating;

arenaTeamsRating.allianceRating = arenaTeams[TEAM_ALLIANCE]->GetStats().Rating;
arenaTeamsRating.hordeRating = arenaTeams[TEAM_HORDE]->GetStats().Rating;

bgArenaTeamsRating[arena->GetInstanceID()] = arenaTeamsRating;
}

// Set matchmaker rating for calculating rating-modifier on EndBattleground (when a team has won/lost)
arena->SetArenaMatchmakerRating(TEAM_ALLIANCE, sSolo->GetAverageMMR(arenaTeams[TEAM_ALLIANCE]));
Expand Down Expand Up @@ -551,15 +565,17 @@ void Solo3v3BG::OnBattlegroundEndReward(Battleground* bg, Player* player, TeamId
int32 ratingModifier;
int32 oldTeamRating;

uint32 oldTeamRatingAlliance = bgArenaTeamsRating[bg->GetInstanceID()].allianceRating;
uint32 oldTeamRatingHorde = bgArenaTeamsRating[bg->GetInstanceID()].hordeRating;

bgArenaTeamsRating[bg->GetInstanceID()].playersCount += 1;

TeamId bgTeamId = player->GetBgTeamId();
const bool isPlayerWinning = bgTeamId == winnerTeamId;
if (isPlayerWinning) {
ArenaTeam* winnerArenaTeam = sArenaTeamMgr->GetArenaTeamById(bg->GetArenaTeamIdForTeam(winnerTeamId == TEAM_NEUTRAL ? TEAM_HORDE : winnerTeamId));
oldTeamRating = winnerTeamId == TEAM_HORDE ? oldTeamRatingHorde : oldTeamRatingAlliance;
ratingModifier = int32(winnerArenaTeam->GetRating()) - oldTeamRating;

atStats.SeasonWins += 1;
atStats.WeekWins += 1;
} else {
ArenaTeam* loserArenaTeam = sArenaTeamMgr->GetArenaTeamById(bg->GetArenaTeamIdForTeam(winnerTeamId == TEAM_NEUTRAL ? TEAM_ALLIANCE : bg->GetOtherTeamId(winnerTeamId)));
oldTeamRating = winnerTeamId != TEAM_HORDE ? oldTeamRatingHorde : oldTeamRatingAlliance;
Expand All @@ -571,9 +587,6 @@ void Solo3v3BG::OnBattlegroundEndReward(Battleground* bg, Player* player, TeamId
else
atStats.Rating += ratingModifier;

atStats.SeasonGames += 1;
atStats.WeekGames += 1;

// Update team's rank, start with rank 1 and increase until no team with more rating was found
atStats.Rank = 1;
ArenaTeamMgr::ArenaTeamContainer::const_iterator i = sArenaTeamMgr->GetArenaTeamMapBegin();
Expand All @@ -587,12 +600,12 @@ void Solo3v3BG::OnBattlegroundEndReward(Battleground* bg, Player* player, TeamId
if (itr->Guid == player->GetGUID())
{
itr->PersonalRating = atStats.Rating;
itr->WeekWins = atStats.WeekWins;
itr->SeasonWins = atStats.SeasonWins;
itr->WeekGames = atStats.WeekGames;
itr->SeasonGames = atStats.SeasonGames;
itr->WeekGames += 1;
itr->SeasonGames += 1;

if (isPlayerWinning) {
itr->WeekWins += 1;
itr->SeasonWins += 1;
// itr->MatchMakerRating = bg->GetArenaMatchmakerRating(winnerTeamId);
itr->MatchMakerRating += ratingModifier;
itr->MaxMMR = std::max(itr->MaxMMR, itr->MatchMakerRating);
Expand All @@ -613,6 +626,10 @@ void Solo3v3BG::OnBattlegroundEndReward(Battleground* bg, Player* player, TeamId
plrArenaTeam->SetArenaTeamStats(atStats);
plrArenaTeam->NotifyStatsChanged();
plrArenaTeam->SaveToDB(true);

// if all the players rating have been processed, delete the stored bg rating informations
if (bgArenaTeamsRating[bg->GetInstanceID()].playersCount == bg->GetPlayersSize())
bgArenaTeamsRating.erase(bg->GetInstanceID());
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/solo3v3_sc.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ class Solo3v3BG : public AllBattlegroundScript
public:
Solo3v3BG() : AllBattlegroundScript("Solo3v3_BG") {}

uint32 oldTeamRatingAlliance;
uint32 oldTeamRatingHorde;

void OnQueueUpdate(BattlegroundQueue* queue, uint32 /*diff*/, BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id, uint8 arenaType, bool isRated, uint32 /*arenaRatedTeamId*/) override;
bool OnQueueUpdateValidity(BattlegroundQueue* /* queue */, uint32 /*diff*/, BattlegroundTypeId /* bgTypeId */, BattlegroundBracketId /* bracket_id */, uint8 arenaType, bool /* isRated */, uint32 /*arenaRatedTeamId*/) override;
void OnBattlegroundDestroy(Battleground* bg) override;
Expand Down

0 comments on commit 2b109fe

Please sign in to comment.