public static RankProgress GetRankProgress(Account acc, IRatingSystem ratingSystem)
        {
            var rating = ratingSystem.GetPlayerRating(acc.AccountID);

            if (rating.Rank == int.MaxValue)
            {
                return(null);
            }
            //var stdev = Math.Min(10000, rating.EloStdev);
            var rank           = acc.Rank;
            var bracket        = ratingSystem.GetPercentileBracket(rank);
            var stdevUp        = 1000.0;
            var stdevDown      = 1000.0;
            var bracketOverlap = 0.2; //sets overlap in next rank: player needs to be at least this amount within the next rank

            if (ValidateRank(rank + 1))
            {
                stdevUp = (ratingSystem.GetPercentileBracket(rank + 1).UpperEloLimit - ratingSystem.GetPercentileBracket(rank + 1).LowerEloLimit) * bracketOverlap;
            }
            if (ValidateRank(rank - 1))
            {
                stdevDown = (ratingSystem.GetPercentileBracket(rank - 1).UpperEloLimit - ratingSystem.GetPercentileBracket(rank - 1).LowerEloLimit) * bracketOverlap;
            }
            var rankCeil  = bracket.UpperEloLimit + stdevUp;
            var rankFloor = bracket.LowerEloLimit - stdevDown;

            //Trace.TraceInformation(acc.Name + ": bracket(" + bracket.LowerEloLimit + ", " + bracket.UpperEloLimit + ") requirements (" + rankFloor + ", " + rankCeil + ") current: " + rating.RealElo + " -> progress: " + bestProgress);
            return(new RankProgress()
            {
                ProgressRatio = (float)Math.Min(1, (rating.LadderElo - rankFloor) / (rankCeil - rankFloor)),
                RankCeilElo = (float)rankCeil,
                RankFloorElo = (float)rankFloor,
                CurrentElo = rating.LadderElo
            });
        }
示例#2
0
 public static void BackupToDB(IRatingSystem ratingSystem)
 {
     if (DisableRatingSystems)
     {
         return;
     }
     Trace.TraceInformation("Backing up rating system...");
     ratingCategories.Where(category => whr[category].Equals(ratingSystem)).ForEach(category => MiscVar.SetValue("WHR_" + category.ToString(), whr[category].SerializeJSON()));
 }
示例#3
0
        public void UserRate(IRateable rateable, IRatingSystem system)
        {
            Request r = new Request();

            r.UserKarma   = UserKarma;
            r.UserRate    = GetUserRate();
            r.Rateable    = rateable;
            r.Recommended = Recommended;
            system.Requests.Enqueue(r);
        }
示例#4
0
        public static RankProgress GetRankProgress(Account acc, IRatingSystem ratingSystem)
        {
            var rating = ratingSystem.GetPlayerRating(acc.AccountID);

            //if (rating.Rank == int.MaxValue) return null;
            // ignore inactivity
            if (ratingSystem.GetActivePlayers() < GlobalConst.LadderSize)
            {
                return(null);
            }
            // don't count unused rating systems, e.g. planetwars
            var rank           = acc.Rank;
            var bracket        = ratingSystem.GetPercentileBracket(rank);
            var stdevUp        = 0.0;
            var stdevDown      = 0.0;
            var bracketOverlap = 0.2;
            //sets overlap in next rank: player needs to be at least this amount within the next rank
            var myBracketWidth = ratingSystem.GetPercentileBracket(rank).UpperEloLimit - ratingSystem.GetPercentileBracket(rank).LowerEloLimit;

            if (ValidateRank(rank + 1))
            {
                var nextBracketWidth = ratingSystem.GetPercentileBracket(rank + 1).UpperEloLimit - ratingSystem.GetPercentileBracket(rank + 1).LowerEloLimit;
                stdevUp = Math.Min(myBracketWidth, nextBracketWidth) * bracketOverlap;
            }
            if (ValidateRank(rank - 1))
            {
                var prevBracketWidth = ratingSystem.GetPercentileBracket(rank - 1).UpperEloLimit - ratingSystem.GetPercentileBracket(rank - 1).LowerEloLimit;
                stdevDown = Math.Min(myBracketWidth, prevBracketWidth) * bracketOverlap;
            }
            var rankCeil  = bracket.UpperEloLimit + stdevUp;
            var rankFloor = bracket.LowerEloLimit - stdevDown;

            //Trace.TraceInformation(acc.Name + ": bracket(" + bracket.LowerEloLimit + ", " + bracket.UpperEloLimit + ") requirements (" + rankFloor + ", " + rankCeil + ") current: " + rating.RealElo + " -> progress: " + bestProgress);
            return(new RankProgress()
            {
                ProgressRatio = (float)Math.Min(1, (rating.LadderElo - rankFloor) / (rankCeil - rankFloor)),
                RankCeilElo = (float)rankCeil,
                RankFloorElo = (float)rankFloor,
                CurrentElo = rating.LadderElo
            });
        }