Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sectionStr = PageUtility.GetQueryString(Request, "section", "ranks");
            int    count      = PageUtility.GetQueryInt(Request, "count", 100);

            if (count > 500)
            {
                count = 500;
            }

            var realm = RealmControl.Realm;

            if (realm == WowRealm.Unknown)
            {
                return;
            }
            var wowVersion = StaticValues.GetWowVersion(realm);

            PlayerColumn[] lifetimeKillsColumns = Table_Lifetime_Kills_Columns;
            PlayerColumn[] rankColumns          = Table_Ranks_Columns;
            Func <KeyValuePair <string, Player>, double> rankSorterLambda = (KeyValuePair <string, Player> _Player) => { return(_Player.Value.GetRankTotal()); };
            Func <Player, bool> rankShowLambda = (Player _Player) => { return(_Player.ReceivedStandingLastWeek() == true && ((DateTime.UtcNow - _Player.LastSeen).TotalDays <= 7.0)); };

            if (wowVersion == VF_RealmPlayersDatabase.WowVersionEnum.TBC)
            {
                lifetimeKillsColumns = Table_Lifetime_Kills_Columns_TBC;
                rankColumns          = Table_Ranks_Columns_TBC;
                rankSorterLambda     = (KeyValuePair <string, Player> _Player) => {
                    return(_Player.Value.GetArenaRatingTotal());
                };
                rankShowLambda = (Player _Player) => {
                    return(_Player.Arena != null);
                };
            }
            if (sectionStr == "standings")
            {
                this.Title = "Standings @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers";

                m_PageHTML = new MvcHtmlString(CreateStandingsTable(realm, count, (player) => { return(player.ReceivedStandingLastWeek()); }));

                if (wowVersion == VF_RealmPlayersDatabase.WowVersionEnum.TBC)
                {
                    GeneratePageDetails("Standings", count * 2, "TBC works with a different PVP system so there are no standings.");
                }
                else
                {
                    var rankUpdateDay = StaticValues.GetRankUpdadeDayType(realm);
                    switch (rankUpdateDay)
                    {
                    case VF_RealmPlayersDatabase.StaticValues.RankUpdateDayType.Wednesday_Morning:
                        GeneratePageDetails("Standings", count * 2, "Last weeks standings for players. Only shows players who received a standing last week. This list resets when the realm calculates new standings for players every wednesday morning.");
                        break;

                    case VF_RealmPlayersDatabase.StaticValues.RankUpdateDayType.Wednesday_Midday:
                        GeneratePageDetails("Standings", count * 2, "Last weeks standings for players. Only shows players who received a standing last week. This list resets when the realm calculates new standings for players every wednesday.");
                        break;

                    case VF_RealmPlayersDatabase.StaticValues.RankUpdateDayType.Sunday_Midnight:
                        GeneratePageDetails("Standings", count * 2, "Last weeks standings for players. Only shows players who received a standing last week. This list resets when the realm calculates new standings for players every sunday midnight.");
                        break;

                    default:
                        break;
                    }
                }
            }
            else if (sectionStr == "twink_ranks")
            {
                this.Title = "Twinks @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers";

                m_PageHTML = new MvcHtmlString(CreatePVPTable(realm, count, Table_Twink_Ranks_Columns
                                                              , (KeyValuePair <string, Player> _Player) => { return(_Player.Value.GetRankTotal()); }
                                                              , (Player _Player) => { return(_Player.Character.Level > 10 && _Player.Character.Level < 60 && _Player.Honor.CurrentRank > 0 && (DateTime.UtcNow - _Player.LastSeen).TotalDays <= 30); }));
                GeneratePageDetails("Twinks", count, "PVP Ranks for players that are below lvl 60. This is meant to show active twinks on the realm. Only shows players that was seen less than 30 days ago");
            }
            else if (sectionStr == "lifetime_kills")
            {
                this.Title = "Lifetime Kills @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers";

                m_PageHTML = new MvcHtmlString(CreatePVPTable(realm, count, lifetimeKillsColumns
                                                              , (KeyValuePair <string, Player> _Player) => { return(_Player.Value.Honor.LifetimeHK); }
                                                              , (Player _Player) => { return(true); }));

                GeneratePageDetails("Lifetime Kills", count, "List sorted by the amount of total honorable kills received. This is to show the players who have pvped the most overall.");
            }
            else if (sectionStr == "highest_ranks")
            {
                this.Title = "Highest Ranks @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers";

                if (wowVersion == VF_RealmPlayersDatabase.WowVersionEnum.TBC)
                {
                    m_PageHTML = new MvcHtmlString("");
                    GeneratePageDetails("Highest Ranks", count, "TBC works with a different PVP system so there are no lifetime highest ranks.");
                }
                else
                {
                    var      playerSummaryDB     = Hidden.ApplicationInstance.Instance.GetPlayerSummaryDatabase();
                    var      pvpSummaries        = playerSummaryDB.GetPVPSummaries(realm);
                    DateTime referenceDateTime   = new DateTime(2010, 1, 1);
                    var      orderedPVPSummaries = pvpSummaries.OrderByDescending((_Value) => ((int)_Value.Value.m_HighestRank.Key) * 100000 - (_Value.Value.m_HighestRank.Value != DateTime.MinValue ? (int)((_Value.Value.m_HighestRank.Value - referenceDateTime).TotalDays) : 0));
                    //////////////////////////////////
                    int pageIndex = PageUtility.GetQueryInt(Request, "page", 1) - 1;//Change range from 0 to * instead of 1 to *

                    PlayerColumn[] playerColumns = new PlayerColumn[] {
                        PlayerColumn.Number,
                        PlayerColumn.Character_And_Guild,
                        PlayerColumn.Race_And_Class,
                        PlayerColumn.Total_HKs,
                        PlayerColumn.LastSeen,
                    };
                    Dictionary <PlayerColumn, string[]> extraColumns = new Dictionary <PlayerColumn, string[]>();

                    extraColumns[PlayerColumn.Number] = new string[] { "Rank", "Date Achieved" };
                    //extraColumns[PlayerColumn.Total_HKs] = new string[] { "Weeks with standing" };

                    string table = "<table class='table'>";
                    table += "<thead>" + PageUtility.CreatePlayerTableHeaderRow(playerColumns, extraColumns) + "</thead>";
                    table += "<tbody>";
                    var playerArray = DatabaseAccess.GetRealmPlayers(this, realm, NotLoadedDecision.RedirectAndWait);
                    int nr          = 0;
                    foreach (var pvpSummary in orderedPVPSummaries)
                    {
                        nr++;
                        if (nr > pageIndex * count && nr <= (pageIndex + 1) * count)
                        {
                            Player playerData = null;
                            if (playerArray.TryGetValue(playerSummaryDB.GetPlayer(pvpSummary), out playerData) == true)
                            {
                                VF_RealmPlayersDatabase.PlayerFaction playerFaction = StaticValues.GetFaction(playerData.Character.Race);
                                int   rank         = (int)pvpSummary.Value.m_HighestRank.Key;
                                float rankProgress = pvpSummary.Value.m_HighestRank.Key - (float)rank;
                                extraColumns[PlayerColumn.Number] = new string[] { PageUtility.CreatePlayerRankDiv(rank, rankProgress, playerFaction), pvpSummary.Value.m_HighestRank.Value.ToString("yyyy-MM-dd") };
                                //extraColumns[PlayerColumn.Total_HKs] = new string[] { pvpSummary.Value.m_ActivePVPWeeks.ToString() };
                                table += PageUtility.CreatePlayerRow(nr, realm, playerData, playerColumns, null, extraColumns);
                            }
                        }
                        if (nr >= (pageIndex + 1) * count)
                        {
                            break;
                        }
                    }
                    table += "</tbody></table>";

                    if (nr != 0 && nr <= pageIndex * count)
                    {
                        pageIndex = (nr - 1) / count;
                        Response.Redirect(PageUtility.CreateUrlWithNewQueryValue(Request, "page", (pageIndex + 1).ToString()));
                    }
                    m_PageHTML = new MvcHtmlString(table);
                    //////////////////////////////////

                    GeneratePageDetails("Highest Ranks", count, "Highest lifetime achieved PVP Ranks for players, sorted by date of achievment");
                }
            }
            else// if (sectionStr == "ranks")
            {
                this.Title = "Ranks @ " + StaticValues.ConvertRealmParam(realm) + " | RealmPlayers";

                if (realm == WowRealm.Nostalrius || realm == WowRealm.NostalriusPVE)
                {
                    rankShowLambda = (Player _Player) =>
                    {
                        return((DateTime.UtcNow - _Player.LastSeen).TotalDays < 14);
                    };
                    GeneratePageDetails("Ranks", count, "Highest PVP Ranks for active players.");
                }
                else if (wowVersion == VF_RealmPlayersDatabase.WowVersionEnum.TBC)
                {
                    GeneratePageDetails("Arena Ranking", count, "Shows the highest rated arena teams, sorted by a sum of the total rating for 5v5, 3v3 and 2v2.");
                }
                else
                {
                    GeneratePageDetails("Ranks", count, "Highest PVP Ranks for players. Only lists players who received standing last week. This is because no rank decay would make the list extremely boring(filled with players that dont even pvp).");
                }
                m_PageHTML = new MvcHtmlString(CreatePVPTable(realm, count, rankColumns
                                                              , rankSorterLambda, rankShowLambda));
            }
            //href='javascript:navigateWithNewQuery(\"page\",\"1\")'
            int pageNr    = PageUtility.GetQueryInt(Request, "page", 1);
            int maxPageNr = 1000000 / count;

            m_PaginationHTML = new MvcHtmlString(PageUtility.CreatePagination(Request, pageNr, maxPageNr));
        }