Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string   dataStr  = PageUtility.GetQueryString(Request, "data");
            string   charStr  = PageUtility.GetQueryString(Request, "char");
            string   itemsStr = PageUtility.GetQueryString(Request, "items");
            WowRealm realm    = PageUtility.GetQueryRealm(Request);

            if (realm == WowRealm.Unknown)
            {
                realm = WowRealm.All;
            }
            var wowVersion = PageUtility.GetQueryWowVersion(Request);

            if (PageUtility.GetQueryString(Request, "generateShortURL") != "null")
            {
                var    fullURL  = "http://realmplayers.com/CharacterDesigner.aspx?char=" + charStr + "&items=" + itemsStr;
                string shortURL = "";
                if (g_CachedShortURLs.TryGetValue(fullURL, out shortURL) == false)
                {
                    shortURL = VF.URLShortener.CreateShortURL(fullURL);
                    if (shortURL == "")
                    {
                        Response.Redirect(PageUtility.CreateUrlWithNewQueryValue(Request, "generateShortURL", "null"));
                    }

                    g_CachedShortURLs.TryAdd(fullURL, shortURL);
                    g_CachedShortURLs.TryAdd(shortURL, fullURL);
                }
                //if (Request.Url.Host == "localhost")
                //    Response.Redirect("localhost:4633/CharacterDesigner.aspx?char=" + charStr + "&items=" + itemsStr);
                //else
                Response.Redirect("CharacterDesigner.aspx?data=" + shortURL.Substring(shortURL.LastIndexOf("/") + 1));
            }
            if (dataStr == "null" && itemsStr == "null")
            {
                return;
            }
            if (dataStr != "null" && itemsStr == "null")
            {
                try
                {
                    string fullURL = "";
                    if (g_CachedShortURLs.TryGetValue("http://goo.gl/" + dataStr, out fullURL) == false)
                    {
                        fullURL = VF.URLShortener.GetFullURL("http://goo.gl/" + dataStr);
                        if (fullURL == "")
                        {
                            return;
                        }
                        g_CachedShortURLs.TryAdd("http://goo.gl/" + dataStr, fullURL);
                    }
                    var url         = new Uri(fullURL);
                    var queryString = System.Web.HttpUtility.ParseQueryString(url.Query);
                    itemsStr = queryString.Get("items");
                    if (itemsStr == null)
                    {
                        return;
                    }
                    var tempcharStr = queryString.Get("char");
                    if (tempcharStr != null)
                    {
                        charStr = tempcharStr;
                    }
                }
                catch (Exception)
                {
                    return;
                }
            }
            m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddFinish("Character Designer"));

            List <PlayerItemInfo> itemsList = new List <PlayerItemInfo>();
            var itemsStrSplit = itemsStr.Split(',', '+', ' ');

            Func <PlayerItemInfo, PlayerItemInfo, bool> slotEqualFunc = (_Value1, _Value2) => _Value1.Slot == _Value2.Slot;

            foreach (string itemLink in itemsStrSplit)
            {
                try
                {
                    itemsList.AddUnique(new PlayerItemInfo(itemLink, wowVersion), slotEqualFunc);
                }
                catch (Exception)
                {
                    try
                    {
                        var splittedLink = itemLink.Split(':', 'x');
                        if (splittedLink.Length > 1)
                        {
                            PlayerItemInfo itemInfo = new PlayerItemInfo("1:0:0:0:0:0:0:0:0", wowVersion);
                            if (Enum.TryParse(splittedLink[0], true, out itemInfo.Slot) == false)
                            {
                                itemInfo.Slot = (ItemSlot)int.Parse(splittedLink[0]);
                            }

                            itemInfo.ItemID = int.Parse(splittedLink[1]);

                            if (splittedLink.Length > 2)
                            {
                                itemInfo.EnchantID = int.Parse(splittedLink[2]);
                            }
                            if (splittedLink.Length > 3)
                            {
                                itemInfo.SuffixID = int.Parse(splittedLink[3]);
                            }
                            if (splittedLink.Length > 4)
                            {
                                itemInfo.UniqueID = int.Parse(splittedLink[4]);
                            }
                            if (splittedLink.Length > 5 && wowVersion == WowVersionEnum.TBC)
                            {
                                itemInfo.GemIDs    = new int[4];
                                itemInfo.GemIDs[0] = int.Parse(splittedLink[5]);
                                itemInfo.GemIDs[1] = 0;
                                itemInfo.GemIDs[2] = 0;
                                itemInfo.GemIDs[3] = 0;
                                if (splittedLink.Length > 6)
                                {
                                    itemInfo.GemIDs[1] = int.Parse(splittedLink[6]);
                                }
                                if (splittedLink.Length > 7)
                                {
                                    itemInfo.GemIDs[2] = int.Parse(splittedLink[7]);
                                }
                                if (splittedLink.Length > 8)
                                {
                                    itemInfo.GemIDs[3] = int.Parse(splittedLink[8]);
                                }
                            }

                            itemsList.AddUnique(itemInfo, slotEqualFunc);
                        }
                    }
                    catch (Exception)
                    {}
                }
            }
            PlayerRace  playerRace  = PlayerRace.Orc;
            PlayerClass playerClass = PlayerClass.Warrior;
            PlayerSex   playerSex   = PlayerSex.Male;

            if (charStr != "null")
            {
                try
                {
                    var charStrSplit = charStr.Split(',', '+', ' ');
                    if (charStrSplit.Length > 0)
                    {
                        if (Enum.TryParse(charStrSplit[0], true, out playerRace) == false)
                        {
                            playerRace = (PlayerRace)int.Parse(charStrSplit[0]);
                        }
                    }
                    if (charStrSplit.Length > 1)
                    {
                        if (Enum.TryParse(charStrSplit[1], true, out playerClass) == false)
                        {
                            playerClass = (PlayerClass)int.Parse(charStrSplit[1]);
                        }
                    }
                    if (charStrSplit.Length > 2)
                    {
                        if (Enum.TryParse(charStrSplit[2], true, out playerSex) == false)
                        {
                            playerSex = (PlayerSex)int.Parse(charStrSplit[2]);
                        }
                    }
                }
                catch (Exception)
                {}
            }
            if (playerRace == PlayerRace.Unknown)
            {
                playerRace = PlayerRace.Orc;
            }
            if (playerClass == PlayerClass.Unknown)
            {
                playerClass = PlayerClass.Warrior;
            }
            if (playerSex == PlayerSex.Unknown)
            {
                playerSex = PlayerSex.Male;
            }

            m_InventoryInfoHTML = new MvcHtmlString(CreateInventoryInfo(itemsList, playerRace, playerClass, playerSex, realm, wowVersion));
            GenerateGearStats(itemsList, wowVersion);
            if (dataStr != "null")
            {
                m_CharacterDesignerInfo = new MvcHtmlString("Short link for this Character: <br /><a href='http://realmplayers.com/vchar/" + dataStr + ".aspx'>http://realmplayers.com/vchar/" + dataStr + ".aspx</a> or <a href='http://goo.gl/" + dataStr + "'>http://goo.gl/" + dataStr + "</a>");
            }
            else
            {
                m_CharacterDesignerInfo = new MvcHtmlString("<a href='" + PageUtility.CreateUrlWithNewQueryValue(Request, "generateShortURL", "true") + "'>Click here to create a short link for this Character</a>");
            }

            if (IsPostBack == false)
            {
                foreach (var item in itemsList)
                {
                    int    gemIDcount = item.GetGemIDCount();
                    string itemStr    = item.ItemID.ToString();
                    if (item.EnchantID != 0 || item.SuffixID != 0 || item.UniqueID != 0 || gemIDcount != 0)
                    {
                        itemStr += "x" + item.EnchantID.ToString();
                        if (item.SuffixID != 0 || item.UniqueID != 0 || gemIDcount != 0)
                        {
                            itemStr += "x" + item.SuffixID.ToString();
                        }
                        if (item.UniqueID != 0 || gemIDcount != 0)
                        {
                            itemStr += "x" + item.UniqueID.ToString();
                        }
                        if (gemIDcount != 0)
                        {
                            for (int i = 0; i < gemIDcount; ++i)
                            {
                                itemStr += "x" + item.GemIDs[i].ToString();
                            }
                        }
                    }
                    switch (item.Slot)
                    {
                    case ItemSlot.Head:
                        txtHeadSlot.Text = itemStr;
                        break;

                    case ItemSlot.Neck:
                        txtNeckSlot.Text = itemStr;
                        break;

                    case ItemSlot.Shoulder:
                        txtShoulderSlot.Text = itemStr;
                        break;

                    case ItemSlot.Shirt:
                        txtShirtSlot.Text = itemStr;
                        break;

                    case ItemSlot.Chest:
                        txtChestSlot.Text = itemStr;
                        break;

                    case ItemSlot.Belt:
                        txtBeltSlot.Text = itemStr;
                        break;

                    case ItemSlot.Legs:
                        txtLegsSlot.Text = itemStr;
                        break;

                    case ItemSlot.Feet:
                        txtFeetSlot.Text = itemStr;
                        break;

                    case ItemSlot.Wrist:
                        txtWristSlot.Text = itemStr;
                        break;

                    case ItemSlot.Gloves:
                        txtGlovesSlot.Text = itemStr;
                        break;

                    case ItemSlot.Finger_1:
                        txtRing1Slot.Text = itemStr;
                        break;

                    case ItemSlot.Finger_2:
                        txtRing2Slot.Text = itemStr;
                        break;

                    case ItemSlot.Trinket_1:
                        txtTrinket1Slot.Text = itemStr;
                        break;

                    case ItemSlot.Trinket_2:
                        txtTrinket2Slot.Text = itemStr;
                        break;

                    case ItemSlot.Back:
                        txtBackSlot.Text = itemStr;
                        break;

                    case ItemSlot.Main_Hand:
                        txtMainhandSlot.Text = itemStr;
                        break;

                    case ItemSlot.Off_Hand:
                        txtOffhandSlot.Text = itemStr;
                        break;

                    case ItemSlot.Ranged:
                        txtRangedSlot.Text = itemStr;
                        break;

                    case ItemSlot.Tabard:
                        txtTabardSlot.Text = itemStr;
                        break;

                    default:
                        break;
                    }
                }

                ddlRace.SelectedValue = playerRace.ToString();
                if (StaticValues.GetFaction(playerRace) == VF_RealmPlayersDatabase.PlayerFaction.Horde)
                {
                    ddlRace.Style.Add("color", "#ff4546");
                }
                else
                {
                    ddlRace.Style.Add("color", "#45a3ff");
                }

                ddlClass.SelectedValue = playerClass.ToString();
                ddlClass.Style.Add("color", PageUtility.GetClassColor(playerClass));

                ddlSex.SelectedValue = playerSex.ToString();
            }
        }
Beispiel #2
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));
        }
Beispiel #3
0
        public string CreateStandingsTable(WowRealm _Realm, int _Count, Func <Player, bool> _RequirementLambda)
        {
            int pageIndex = PageUtility.GetQueryInt(Request, "page", 1) - 1;//Change range from 0 to * instead of 1 to *

            string commonTable = "<table id='characters-table' class='table'>";

            commonTable += "<thead>" + PageUtility.CreatePlayerTableHeaderRow(Table_Standings_Columns) + "</thead>";
            string hordeTable    = commonTable + "<tbody>";
            string allianceTable = commonTable + "<tbody>";
            Func <KeyValuePair <string, Player>, double> sortLambda = (KeyValuePair <string, Player> player) =>
            {
                double daysSinceLastSeen = (DateTime.UtcNow - player.Value.LastSeen).TotalDays;
                if (daysSinceLastSeen > 7)
                {
                    return(int.MaxValue);
                }
                return((double)player.Value.Honor.LastWeekStanding + (daysSinceLastSeen / 10.0));
            };
            var playerArray = DatabaseAccess.GetRealmPlayers(this, _Realm, NotLoadedDecision.RedirectAndWait).OrderBy(sortLambda);

            DateTime lastRankUpdateDateUTC = StaticValues.CalculateLastRankUpdadeDateUTC(_Realm);

            int hordeCount    = 0;
            int allianceCount = 0;

            foreach (var player in playerArray)
            {
                if ((player.Value.LastSeen - lastRankUpdateDateUTC).TotalHours > 0)
                {
                    var playerFaction = StaticValues.GetFaction(player.Value.Character.Race);
                    if (playerFaction == VF_RealmPlayersDatabase.PlayerFaction.Horde &&
                        hordeCount < (pageIndex + 1) * _Count &&
                        _RequirementLambda(player.Value) == true)
                    {
                        hordeCount++;
                        if (hordeCount > pageIndex * _Count && hordeCount <= (pageIndex + 1) * _Count)
                        {
                            hordeTable += PageUtility.CreatePlayerRow(hordeCount, _Realm, player.Value, Table_Standings_Columns);
                        }
                    }
                    else if (playerFaction == VF_RealmPlayersDatabase.PlayerFaction.Alliance &&
                             allianceCount < (pageIndex + 1) * _Count &&
                             _RequirementLambda(player.Value) == true)
                    {
                        allianceCount++;
                        if (allianceCount > pageIndex * _Count && allianceCount <= (pageIndex + 1) * _Count)
                        {
                            allianceTable += PageUtility.CreatePlayerRow(allianceCount, _Realm, player.Value, Table_Standings_Columns);
                        }
                    }
                }
                if (hordeCount >= (pageIndex + 1) * _Count && allianceCount >= (pageIndex + 1) * _Count)
                {
                    break;
                }
            }
            hordeTable    += "</tbody></table>";
            allianceTable += "</tbody></table>";
            string pageTable = "";

            pageTable += PageUtility.CreateDiv("span6", hordeTable);
            pageTable += PageUtility.CreateDiv("span6", allianceTable);
            pageTable  = PageUtility.CreateDiv("row", pageTable);

            if ((hordeCount != 0 && hordeCount < pageIndex * _Count) && (allianceCount != 0 && allianceCount < pageIndex * _Count))
            {
                pageIndex = (hordeCount - 1) / _Count;
                if (pageIndex < (allianceCount - 1) / _Count)
                {
                    pageIndex = (allianceCount - 1) / _Count;
                }
                Response.Redirect(PageUtility.CreateUrlWithNewQueryValue(Request, "page", (pageIndex + 1).ToString()));
            }
            return(pageTable);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddHome()
                                                 + PageUtility.BreadCrumb_AddFinish("RareItemsList"));

            var realm = RealmControl.Realm;

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

            int count = PageUtility.GetQueryInt(Request, "count", 100);

            var itemSummaryDB = Hidden.ApplicationInstance.Instance.GetItemSummaryDatabase();

            m_ItemUsageInfoHTML = new MvcHtmlString("<h1>Rarest items<span class='badge badge-inverse'>" + count + " Items</span></h1>"
                                                    + "<p>List contains the most rarest items on the realm.</p>");

            Dictionary <PlayerColumn, string[]> extraColumns = new Dictionary <PlayerColumn, string[]>();
            PlayerColumn ItemAndAquiredDateAfterColumn       = PlayerColumn.Number;

            extraColumns.Add(ItemAndAquiredDateAfterColumn, new string[] { "Item", "Count", "First Aquired", "First Player(s)" });
            m_TableHeadHTML = new MvcHtmlString(PageUtility.CreatePlayerTableHeaderRow(Table_Columns, extraColumns));

            string currentItemDatabase = DatabaseAccess.GetCurrentItemDatabaseAddress();

            string tableBody = "";
            int    nr        = 1;
            Func <KeyValuePair <ulong, VF_RPDatabase.ItemSummary>, int> lambdaComparison = (_Tuple) => { return(_Tuple.Value.m_ItemOwners.Count((_Value) => (itemSummaryDB.GetPlayerRealm(_Value.Item1) == realm))); };
            Func <Tuple <ulong, DateTime>, DateTime> lambdaDateTimeComparison            = (_Tuple) => { return(_Tuple.Item2); };
            var rareItemsList = itemSummaryDB.m_Items.OrderBy(lambdaComparison);

            foreach (var rareItem in rareItemsList)
            {
                if (nr >= count)
                {
                    break;
                }
                int rareItemCount = rareItem.Value.m_ItemOwners.Count((_Value) => (itemSummaryDB.GetPlayerRealm(_Value.Item1) == realm));
                if (rareItemCount > 0 && Code.Resources.ItemAnalyzer.IsRareItem(rareItem.Value.m_ItemID) == true)
                {
                    var itemInfo = DatabaseAccess.GetItemInfo(rareItem.Value.m_ItemID, wowVersion);
                    if (itemInfo.ItemQuality < 4)
                    {
                        continue;
                    }
                    //rareItem.
                    Player   player         = null;
                    var      orderedAquires = rareItem.Value.m_ItemOwners.OrderBy(lambdaDateTimeComparison);
                    DateTime dateTimeCutoff = orderedAquires.First((_Value) => (itemSummaryDB.GetPlayerRealm(_Value.Item1) == realm)).Item2;
                    if (dateTimeCutoff < new DateTime(2013, 8, 1, 0, 0, 0))
                    {
                        dateTimeCutoff = new DateTime(2013, 8, 1, 0, 0, 0);
                    }
                    else
                    {
                        dateTimeCutoff = dateTimeCutoff.AddDays(3);
                    }

                    string firstPlayers     = "<div style='overflow: hidden; display: table; height: 58px;'>";
                    var    interestingItems = orderedAquires.Where((_Tuple) => { return(_Tuple.Item2 < dateTimeCutoff && (itemSummaryDB.GetPlayerRealm(_Tuple.Item1) == realm)); });
                    if (interestingItems.Count() < 5)
                    {
                        foreach (var playerAquire in interestingItems)
                        {
                            if (playerAquire.Item2 < dateTimeCutoff)
                            {
                                player = DatabaseAccess.FindRealmPlayer(this, realm, itemSummaryDB.GetPlayerName(playerAquire.Item1));
                                if (player != null)
                                {
                                    var playerFaction = StaticValues.GetFaction(player.Character.Race);
                                    firstPlayers += "<div class='" + StaticValues.GetFactionCSSName(playerFaction) + "_col' style='display: table-cell; width:160px;" /*"background-color: " + (playerFaction == PlayerFaction.Horde ? "#372727" : "#272f37")*/ + "'>";
                                    firstPlayers += "<p style='text-align:center;'><a href='CharacterViewer.aspx?realm=" + StaticValues.ConvertRealmParam(realm) + "&player=" + System.Web.HttpUtility.HtmlEncode(player.Name) + "'>" + PageUtility.CreateColorCodedName(player.Name, player.Character.Class) + "</a>";
                                    if (player.Guild.GuildName != "nil")
                                    {
                                        string visualGuildName = PageUtility.BreakLongStr(player.Guild.GuildName, 16, 8);
                                        firstPlayers += "<br>" + PageUtility.CreateLink("GuildViewer.aspx?realm=" + StaticValues.ConvertRealmParam(realm) + "&guild=" + System.Web.HttpUtility.HtmlEncode(player.Guild.GuildName), "&lt;" + visualGuildName + "&gt;") + "</p>";
                                    }
                                    firstPlayers += "</div>";
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                    }
                    else
                    {
                        firstPlayers += "Data not detailed enough<br>(more than 5 players within aquire timespan)";
                    }
                    firstPlayers += "</div>";
                    extraColumns[ItemAndAquiredDateAfterColumn] = new string[] {
                        "<div class='inventory' style='background: none; width: 58px; height: 58px;'><div>"
                        + "<img class='itempic' src='" + "http://realmplayers.com/" + itemInfo.GetIconImageAddress() + "'/>"
                        + "<div class='quality' id='" + CharacterViewer.ItemQualityConversion[itemInfo.ItemQuality] + "'></div>"
                        + "<img class='itemframe' src='assets/img/icons/ItemNormalFrame.png'/>"
                        + CharacterViewer.GenerateItemLink(currentItemDatabase, rareItem.Value.m_ItemID, rareItem.Value.m_SuffixID, wowVersion)
                        + "<a class='itemplayersframe' href='ItemUsageInfo.aspx?realm=" + StaticValues.ConvertRealmParam(realm) + "&item=" + rareItem.Value.m_ItemID + (rareItem.Value.m_SuffixID != 0 ? "&suffix=" + rareItem.Value.m_SuffixID : "") + "'>" + rareItemCount.ToString() + "</a>"
                        + "</div></div>"
                        , rareItemCount.ToString()
                        , " &gt; " + interestingItems.First().Item2.ToString("yyyy-MM-dd") + "<br> &lt; " + dateTimeCutoff.ToString("yyyy-MM-dd")
                        , firstPlayers
                    };
                    tableBody += PageUtility.CreateTableRow("",
                                                            PageUtility.CreateTableColumn("#" + (nr++))
                                                            + PageUtility.CreateTableColumn(extraColumns[ItemAndAquiredDateAfterColumn][0])
                                                            + PageUtility.CreateTableColumn(extraColumns[ItemAndAquiredDateAfterColumn][1])
                                                            + PageUtility.CreateTableColumn(extraColumns[ItemAndAquiredDateAfterColumn][2])
                                                            + PageUtility.CreateTableColumn(extraColumns[ItemAndAquiredDateAfterColumn][3]));
                }
            }
            m_TableBodyHTML = new MvcHtmlString(tableBody);
        }