Пример #1
0
int32 ArenaTeam::LostAgainst(uint32 againstRating)
{
    // called when the team has lost
    //'chance' calculation - to loose to the opponent
    float chance = GetChanceAgainst(m_stats.rating, againstRating);
    float K = (m_stats.rating < 1000) ? 48.0f : 32.0f;
    // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000)
    int32 mod = (int32)ceil(K * (0.0f - chance));
    // modify the team stats accordingly
    FinishGame(mod);

    // return the rating change, used to display it on the results screen
    return mod;
}
Пример #2
0
void ArenaTeam::MemberLost(Player * plr, uint32 againstRating)
{
    // called for each participant of a match after losing
    for(MemberList::iterator itr = m_members.begin(); itr !=  m_members.end(); ++itr)
    {
        if (itr->guid == plr->GetObjectGuid())
        {
            // update personal rating
            float chance = GetChanceAgainst(itr->personal_rating, againstRating);
            float K = (itr->personal_rating < 1000) ? 48.0f : 32.0f;
            // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000)
            int32 mod = (int32)ceil(K * (0.0f - chance));
            
            if(againstRating <= sWorld.getConfig(CONFIG_UINT32_LOSERNOCHANGE) || itr->personal_rating <= sWorld.getConfig(CONFIG_UINT32_LOSERNOCHANGE))
                mod = 0;
            else if (itr->personal_rating <= sWorld.getConfig(CONFIG_UINT32_LOSERHALFCHANGE))
                mod /= 2;

            itr->ModifyPersonalRating(plr, mod, GetSlot());

            // update matchmaker rating 
            chance = GetChanceAgainst(itr->matchmaker_rating, againstRating);
            K = (itr->matchmaker_rating < 1000) ? 48.0f : 32.0f;
            // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000)
            mod = (int32)ceil(K * (0.0f - chance));
            itr->ModifyMatchmakerRating(plr,mod,GetType());

            // update personal played stats
            itr->games_week += 1;
            itr->games_season += 1;
            // update the unit fields
            plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK,  itr->games_week);
            plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON,  itr->games_season);
            return;
        }
    }
}
Пример #3
0
int32 ArenaTeam::WonAgainst(uint32 againstRating)
{
    // called when the team has won
    // 'chance' calculation - to beat the opponent
    float chance = GetChanceAgainst(m_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);
    m_stats.wins_week += 1;
    m_stats.wins_season += 1;

    // return the rating change, used to display it on the results screen
    return mod;
}
Пример #4
0
int32 ArenaTeam::LostAgainst(uint32 againstRating)
{
    // called when the team has lost
    //'chance' calculation - to loose to the opponent
    float chance = GetChanceAgainst(m_stats.rating, againstRating);
    float K = (m_stats.rating < 1000) ? 48.0f : 32.0f;
    // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000)
    int32 mod = (int32)ceil(K * (0.0f - chance));
    // modify the team stats accordingly
    
    if(againstRating <= sWorld.getConfig(CONFIG_UINT32_LOSERNOCHANGE) || m_stats.rating <= sWorld.getConfig(CONFIG_UINT32_LOSERNOCHANGE))
        mod = 0;
    else if (m_stats.rating <= sWorld.getConfig(CONFIG_UINT32_LOSERHALFCHANGE))
        mod /= 2;

    FinishGame(mod);

    // return the rating change, used to display it on the results screen
    return mod;
}
Пример #5
0
void ArenaTeam::MemberWon(Player * plr, uint32 againstRating)
{
    // called for each participant after winning a match
    for(MemberList::iterator itr = m_members.begin(); itr !=  m_members.end(); ++itr)
    {
        if (itr->guid == plr->GetObjectGuid())
        {
            // FG: attempt to prevent "win trading" - dont give reward to winner if player with same IP is in opposite team
            Map::PlayerList const& plist = plr->GetMap()->GetPlayers();
            for(Map::PlayerList::const_iterator pit = plist.begin(); pit != plist.end(); ++pit)
            {
                Player *pp = pit->getSource();
                if( !(pp && pp->IsSessionValid() && plr->IsSessionValid()) )
                    return; // something wrong

                if(pp->GetSession()->GetIP() == plr->GetSession()->GetIP() && pp->IsHostileTo(plr))
                {
                    ChatHandler(plr).PSendSysMessage(11110, pp->GetName());
                    return;
                }
            }
            // FG: -end-

            // update personal rating
            float chance = GetChanceAgainst(itr->personal_rating, againstRating);
            float K = (itr->personal_rating < 1000) ? 48.0f : 32.0f;
            // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000)
            int32 mod = (int32)floor(K* (1.0f - chance));
            itr->ModifyPersonalRating(plr, mod, GetSlot());
            // update personal stats
            itr->games_week += 1;
            itr->games_season += 1;
            itr->wins_season += 1;
            itr->wins_week += 1;
            // update unit fields
            plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->games_week);
            plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->games_season);
            return;
        }
    }
}
Пример #6
0
void ArenaTeam::OfflineMemberLost(uint64 guid, uint32 againstRating)
{
    // called for offline player after ending rated arena match!
    for(MemberList::iterator itr = m_members.begin(); itr !=  m_members.end(); ++itr)
    {
        if(itr->guid == guid)
        {
            // update personal rating
            float chance = GetChanceAgainst(itr->personal_rating, againstRating);
            int32 mod = (int32)ceil(32.0f * (0.0f - chance));
            if (int32(itr->personal_rating) + mod < 0)
                itr->personal_rating = 0;
            else
                itr->personal_rating += mod;
            // update personal played stats
            itr->games_week += 1;
            itr->games_season += 1;
            return;
        }
    }
}
Пример #7
0
void ArenaTeam::MemberLost(Player * plr, uint32 againstRating)
{
    // called for each participant of a match after losing
    for(MemberList::iterator itr = m_members.begin(); itr !=  m_members.end(); ++itr)
    {
        if(itr->guid == plr->GetGUID())
        {
            // update personal rating
            float chance = GetChanceAgainst(itr->personal_rating, againstRating);
            int32 mod = (int32)ceil(32.0f * (0.0f - chance));
            itr->ModifyPersonalRating(plr, mod, GetSlot());
            // update personal played stats
            itr->games_week += 1;
            itr->games_season += 1;
            // update the unit fields
            plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_GAMES_WEEK, itr->games_week);
            plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + (GetSlot() * ARENA_TEAM_END) + ARENA_TEAM_GAMES_SEASON, itr->games_season);
            return;
        }
    }
}
Пример #8
0
void ArenaTeam::MemberWon(Player * plr, uint32 againstRating)
{
    // We handle personal rating for Solo Queue in Arena Team win or lost function
    if (GetType() == ARENA_TEAM_5v5)
        return;

    // called for each participant after winning a match
    for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
    {
        if (itr->guid == plr->GetGUID())
        {
            // update personal rating
            float chance = GetChanceAgainst(itr->personal_rating, againstRating);
            int32 mod = (int32)floor(32.0f * (1.0f - chance));

            if (GetType() == ARENA_TEAM_2v2)
            {
                if (m_stats.rating < 1850)
                    mod += 2;
                if (mod == 30)
                    mod++;
                if (mod < 3)
                    mod = 3;
            }

            itr->ModifyPersonalRating(plr, mod, GetSlot());
            // update personal stats
            itr->games_week +=1;
            itr->games_season +=1;
            itr->wins_season += 1;
            itr->wins_week += 1;
            // update unit fields
            plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->games_week);
            plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->games_season);
            return;
        }
    }
}
Пример #9
0
void ArenaTeam::MemberLost(Player * plr, uint32 againstRating)
{
    // We handle personal rating for Solo Queue in Arena Team win or lost function
    if (GetType() == ARENA_TEAM_5v5)
        return;

    // called for each participant of a match after losing
    for (MemberList::iterator itr = m_members.begin(); itr != m_members.end(); ++itr)
    {
        if (itr->guid == plr->GetGUID())
        {
            // update personal rating
            float chance = GetChanceAgainst(itr->personal_rating, againstRating);
            int32 mod = (int32)ceil(32.0f) * (0.0f - chance);

            // Smolderforge rating adjustments
            if (GetType() == ARENA_TEAM_2v2)
            {
                if (mod <= -25)
                    mod = -24;
            }

            itr->ModifyPersonalRating(plr, mod, GetSlot());

            // SOLOQUEUE - Don't track stats for lost games
            if (GetType() < ARENA_TEAM_5v5)
            {
                // update personal played stats
                itr->games_week += 1;
                itr->games_season += 1;
            }
            // update the unit fields
            plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK,  itr->games_week);
            plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON,  itr->games_season);
            return;
        }
    }
}
Пример #10
0
int32 ArenaTeam::OfflineMemberLost(uint64 guid, uint32 againstRating)
{
    // called for offline player after ending rated arena match!
    for(MemberList::iterator itr = m_members.begin(); itr !=  m_members.end(); ++itr)
    {
        if (itr->guid == guid)
        {
            // update personal rating
            float chance = GetChanceAgainst(itr->personal_rating, againstRating);
            float K = (itr->personal_rating < 1000) ? 48.0f : 32.0f;
            // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000)
            int32 mod = (int32)ceil(K * (0.0f - chance));
            if (int32(itr->personal_rating) + mod < 0)
                itr->personal_rating = 0;
            else
                itr->personal_rating += mod;
            // update personal played stats
            itr->games_week += 1;
            itr->games_season += 1;
            return mod;
        }
    }return 0;
}
Пример #11
0
void ArenaTeam::MemberWon(Player* plr, uint32 againstRating)
{
    // called for each participant after winning a match
    for (MemberList::iterator itr = m_members.begin(); itr !=  m_members.end(); ++itr)
    {
        if (itr->guid == plr->GetObjectGuid())
        {
            // update personal rating
            float chance = GetChanceAgainst(itr->personal_rating, againstRating);
            int32 mod = (int32)floor(32.0f * (1.0f - chance));
            itr->ModifyPersonalRating(plr, mod, GetSlot());
            // update personal stats
            itr->games_week += 1;
            itr->games_season += 1;
            itr->wins_season += 1;
            itr->wins_week += 1;
            // update unit fields
            plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK, itr->games_week);
            plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON, itr->games_season);
            return;
        }
    }
}
Пример #12
0
void ArenaTeam::MemberLost(Player * plr, uint32 againstRating)
{
    // called for each participant of a match after losing
    for(MemberList::iterator itr = m_members.begin(); itr !=  m_members.end(); ++itr)
    {
        if(itr->guid == plr->GetGUID())
        {
            // update personal rating
            float chance = GetChanceAgainst(itr->personal_rating, againstRating);
            float K = (itr->personal_rating < 1000) ? 48.0f : 32.0f;
            // calculate the rating modification (ELO system with k=32 or k=48 if rating<1000)
            int32 mod = (int32)ceil(K * (0.0f - chance));
            itr->ModifyPersonalRating(plr, mod, GetSlot());
            // update personal played stats
            itr->games_week += 1;
            itr->games_season += 1;
            // update the unit fields
            plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_WEEK,  itr->games_week);
            plr->SetArenaTeamInfoField(GetSlot(), ARENA_TEAM_GAMES_SEASON,  itr->games_season);
            return;
        }
    }
}
Пример #13
0
void ArenaTeam::MemberWon(Player * plr, uint32 againstRating)
{
    // called for each participant after winning a match
    for(MemberList::iterator itr = members.begin(); itr !=  members.end(); ++itr)
    {
        if(itr->guid == plr->GetGUID())
        {
            // update personal rating
            float chance = GetChanceAgainst(itr->personal_rating, againstRating);
            int32 mod = (int32)floor(32.0f * (1.0f - chance));
            itr->ModifyPersonalRating(plr, mod, GetSlot());
            // update personal stats
            itr->games_week +=1;
            itr->games_season +=1;
            itr->wins_season += 1;
            itr->wins_week += 1;
            // update unit fields
            plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 2, itr->games_week);
            plr->SetUInt32Value(PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 6 * GetSlot() + 3, itr->games_season);
            return;
        }
    }
}
Пример #14
0
int32 ArenaTeam::GetRatingMod(uint32 ownRating, uint32 opponentRating, bool won /*, float confidence_factor*/)
{
    // 'Chance' calculation - to beat the opponent
    // This is a simulation. Not much info on how it really works
    float chance = GetChanceAgainst(ownRating, opponentRating);
    float won_mod = (won) ? 1.0f : 0.0f;

    // Calculate the rating modification
    float mod;

    // TODO: Replace this hack with using the confidence factor (limiting the factor to 2.0f)
    if (won && ownRating < 1300)
    {
        if (ownRating < 1000)
            mod = 48.0f * (won_mod - chance);
        else
            mod = (24.0f + (24.0f * (1300.0f - float(ownRating)) / 300.0f)) * (won_mod - chance);
    }
    else
        mod = 24.0f * (won_mod - chance);

    return (int32)ceil(mod);
}
Пример #15
0
int32 ArenaTeam::GetRatingMod(uint32 own_rating, uint32 enemy_rating, bool won, bool calculating_mmr)
{
    // 'chance' calculation - to beat the opponent
    float chance = GetChanceAgainst(own_rating, enemy_rating);
    float won_mod = (won) ? 1.0f : 0.0f;

    // calculate the rating modification
    // simulation on how it works. Not much info on how it really works
    float mod;

    if (won && !calculating_mmr)
    {
        if (own_rating < 1000)
            mod = 48.0f * (won_mod - chance);
        else if (own_rating < 1300)
            mod = (24.0f + (24.0f * (1300.0f - int32(own_rating)) / 300.0f)) * (won_mod - chance);
        else
            mod = 24.0f * (won_mod - chance);
    }
    else
        mod = 24.0f * (won_mod - chance);

    return (int32)ceil(mod);
}
Пример #16
0
int32 ArenaTeam::LostAgainst(uint32 againstRating)
{
    // called when the team has lost
    //'chance' calculation - to loose to the opponent
    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::iterator i = objmgr.GetArenaTeamMapBegin();
    for ( ; i != objmgr.GetArenaTeamMapEnd(); ++i)
    {
        if (i->second->GetType() == this->Type && i->second->GetStats().rating > stats.rating)
            ++stats.rank;
    }

    // return the rating change, used to display it on the results screen
    return mod;
}
Пример #17
0
int32 ArenaTeam::GetPersonalRatingMod(int32 base_rating, uint32 own_rating, uint32 enemy_rating)
{
    float chance = GetChanceAgainst(own_rating, enemy_rating);
    chance *= 2.0f;
    return (int32)ceil(float(base_rating) * chance);
}