diff --git a/src/game/ArenaTeam.cpp b/src/game/ArenaTeam.cpp index 6b88ba687..6321225ff 100644 --- a/src/game/ArenaTeam.cpp +++ b/src/game/ArenaTeam.cpp @@ -502,20 +502,16 @@ float ArenaTeam::GetChanceAgainst(uint32 own_rating, uint32 enemy_rating) 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 - stats.rating += mod; + 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) @@ -524,6 +520,21 @@ int32 ArenaTeam::WonAgainst(uint32 againstRating) ++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; } @@ -532,22 +543,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 - stats.rating += mod; - 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; diff --git a/src/game/ArenaTeam.h b/src/game/ArenaTeam.h index 9ad3ea618..8025f9d91 100644 --- a/src/game/ArenaTeam.h +++ b/src/game/ArenaTeam.h @@ -205,6 +205,7 @@ class ArenaTeam void NotifyStatsChanged(); void FinishWeek(); + void FinishGame(int32 mod); protected: diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 14b08251c..254306b66 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "8266" + #define REVISION_NR "8267" #endif // __REVISION_NR_H__