mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
*[8267] ArenaTeam: added check, that teamrating won't become negative Author: Barlok
*[8268] ArenaTeam: new rating-system for season 6 Authors: danielich and XTZGZoReX. --HG-- branch : trunk
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "WorldPacket.h"
|
||||
|
||||
#include "ArenaTeam.h"
|
||||
#include "World.h"
|
||||
|
||||
void ArenaTeamMember::ModifyPersonalRating(Player* plr, int32 mod, uint32 slot)
|
||||
{
|
||||
@@ -44,7 +45,10 @@ ArenaTeam::ArenaTeam()
|
||||
stats.games_week = 0;
|
||||
stats.games_season = 0;
|
||||
stats.rank = 0;
|
||||
stats.rating = ARENA_NEW_TEAM_RATING;
|
||||
if (sWorld.getConfig(CONFIG_ARENA_SEASON_ID) >= 6)
|
||||
stats.rating = 0;
|
||||
else
|
||||
stats.rating = 1500;
|
||||
stats.wins_week = 0;
|
||||
stats.wins_season = 0;
|
||||
}
|
||||
@@ -139,7 +143,17 @@ bool ArenaTeam::AddMember(const uint64& PlayerGuid)
|
||||
newmember.games_week = 0;
|
||||
newmember.wins_season = 0;
|
||||
newmember.wins_week = 0;
|
||||
newmember.personal_rating = AREAN_NEW_PERSONAL_RATING;
|
||||
if (sWorld.getConfig(CONFIG_ARENA_SEASON_ID) >= 6)
|
||||
{
|
||||
if (stats.rating < 1000)
|
||||
newmember.personal_rating = stats.rating;
|
||||
else
|
||||
newmember.personal_rating = 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
newmember.personal_rating = 1500;
|
||||
}
|
||||
members.push_back(newmember);
|
||||
|
||||
CharacterDatabase.PExecute("INSERT INTO arena_team_member (arenateamid, guid, personal_rating) VALUES ('%u', '%u', '%u')", Id, GUID_LOPART(newmember.guid), newmember.personal_rating );
|
||||
@@ -517,24 +531,24 @@ float ArenaTeam::GetChanceAgainst(uint32 own_rating, uint32 enemy_rating)
|
||||
{
|
||||
// returns the chance to win against a team with the given rating, used in the rating adjustment calculation
|
||||
// ELO system
|
||||
|
||||
if (sWorld.getConfig(CONFIG_ARENA_SEASON_ID) >= 6)
|
||||
if (enemy_rating < 1300)
|
||||
enemy_rating = 1300;
|
||||
|
||||
return 1.0f/(1.0f+exp(log(10.0f)*(float)((float)enemy_rating - (float)own_rating)/400.0f));
|
||||
}
|
||||
|
||||
int32 ArenaTeam::WonAgainst(uint32 againstRating)
|
||||
void ArenaTeam::FinishGame(int32 mod)
|
||||
{
|
||||
// called when the team has won
|
||||
//'chance' calculation - to beat the opponent
|
||||
float chance = GetChanceAgainst(stats.rating,againstRating);
|
||||
// calculate the rating modification (ELO system with k=32)
|
||||
int32 mod = (int32)floor(32.0f * (1.0f - chance));
|
||||
// modify the team stats accordingly
|
||||
int32 newTeamRating = (int32)stats.rating + mod;
|
||||
stats.rating = newTeamRating > 0 ? newTeamRating : 0;
|
||||
if (int32(stats.rating) + mod < 0)
|
||||
stats.rating = 0;
|
||||
else
|
||||
stats.rating += mod;
|
||||
|
||||
stats.games_week += 1;
|
||||
stats.wins_week += 1;
|
||||
stats.games_season += 1;
|
||||
stats.wins_season += 1;
|
||||
//update team's rank
|
||||
// update team's rank
|
||||
stats.rank = 1;
|
||||
ObjectMgr::ArenaTeamMap::const_iterator i = objmgr.GetArenaTeamMapBegin();
|
||||
for ( ; i != objmgr.GetArenaTeamMapEnd(); ++i)
|
||||
@@ -542,6 +556,19 @@ int32 ArenaTeam::WonAgainst(uint32 againstRating)
|
||||
if (i->second->GetType() == this->Type && i->second->GetStats().rating > stats.rating)
|
||||
++stats.rank;
|
||||
}
|
||||
}
|
||||
|
||||
int32 ArenaTeam::WonAgainst(uint32 againstRating)
|
||||
{
|
||||
// called when the team has won
|
||||
//'chance' calculation - to beat the opponent
|
||||
float chance = GetChanceAgainst(stats.rating, againstRating);
|
||||
// calculate the rating modification (ELO system with k=32)
|
||||
int32 mod = (int32)floor(32.0f * (1.0f - chance));
|
||||
// modify the team stats accordingly
|
||||
FinishGame(mod);
|
||||
stats.wins_week += 1;
|
||||
stats.wins_season += 1;
|
||||
|
||||
// return the rating change, used to display it on the results screen
|
||||
return mod;
|
||||
@@ -551,23 +578,11 @@ int32 ArenaTeam::LostAgainst(uint32 againstRating)
|
||||
{
|
||||
// called when the team has lost
|
||||
//'chance' calculation - to loose to the opponent
|
||||
float chance = GetChanceAgainst(stats.rating,againstRating);
|
||||
float chance = GetChanceAgainst(stats.rating, againstRating);
|
||||
// calculate the rating modification (ELO system with k=32)
|
||||
int32 mod = (int32)ceil(32.0f * (0.0f - chance));
|
||||
// modify the team stats accordingly
|
||||
int32 newTeamRating = (int32)stats.rating + mod;
|
||||
stats.rating = newTeamRating > 0 ? newTeamRating : 0;
|
||||
stats.games_week += 1;
|
||||
stats.games_season += 1;
|
||||
//update team's rank
|
||||
|
||||
stats.rank = 1;
|
||||
ObjectMgr::ArenaTeamMap::const_iterator i = objmgr.GetArenaTeamMapBegin();
|
||||
for ( ; i != objmgr.GetArenaTeamMapEnd(); ++i)
|
||||
{
|
||||
if (i->second->GetType() == this->Type && i->second->GetStats().rating > stats.rating)
|
||||
++stats.rank;
|
||||
}
|
||||
FinishGame(mod);
|
||||
|
||||
// return the rating change, used to display it on the results screen
|
||||
return mod;
|
||||
|
||||
@@ -85,9 +85,6 @@ enum ArenaTeamTypes
|
||||
ARENA_TEAM_5v5 = 5
|
||||
};
|
||||
|
||||
#define ARENA_NEW_TEAM_RATING 0
|
||||
#define AREAN_NEW_PERSONAL_RATING 0
|
||||
|
||||
struct ArenaTeamMember
|
||||
{
|
||||
uint64 guid;
|
||||
@@ -202,6 +199,7 @@ class ArenaTeam
|
||||
void NotifyStatsChanged();
|
||||
|
||||
void FinishWeek();
|
||||
void FinishGame(int32 mod);
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user