Ejemplo n.º 1
0
        private void GenerateBossFightPage(bool DEBUG_Website, bool filteredData, int uniqueRaidID, RaidBossFight interestingFight)
        {
            if (interestingFight == null)
            {
                Response.Redirect("RaidList.aspx");
            }

            var realmDB = ApplicationInstance.Instance.GetRealmDB(interestingFight.GetRaid().Realm);

            if (interestingFight != null)
            {
                //int fightDuration = timeEnd - timeStart;
                //if (fightDuration <= 0)
                //{
                //    if (timeEnd < timeStart)
                //        fightDuration = interestingFight.GetFightData().GetFightRecordDuration() - timeStart;
                //    else
                //        fightDuration = interestingFight.GetFightData().GetFightRecordDuration();
                //}
                m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddHome()
                                                     + PageUtility.BreadCrumb_AddRaidList()
                                                     + PageUtility.BreadCrumb_AddLink("RaidList.aspx?Guild=" + interestingFight.GetRaid().RaidOwnerName + "&realm=" + StaticValues.ConvertRealmParam(realmDB.Realm), interestingFight.GetRaid().RaidOwnerName)
                                                     + PageUtility.BreadCrumb_AddRaidOverview(interestingFight.GetRaid())
                                                     + PageUtility.BreadCrumb_AddFinish(interestingFight.GetBossName()));

                var raidSummary = ApplicationInstance.Instance.GetSummaryDatabase().GetRaid(uniqueRaidID);
                m_FightOverviewInfoHTML = new MvcHtmlString(FightOverviewGenerator.Generate(realmDB, raidSummary, interestingFight
                                                                                            , new FightOverviewGenerator.GenerateDetails
                {
                    FilterSpikes          = filteredData
                    , DebugInfo           = DEBUG_Website
                    , DebugBuff           = PageUtility.GetQueryString(Request, "DebugBuff", null)
                    , FilterSpikesURL     = PageUtility.CreateUrlWithNewQueryValue(Request, "Filtered", "true")
                    , NoFilterSpikesURL   = PageUtility.CreateUrlWithNewQueryValue(Request, "Filtered", "false")
                    , VersionChangeURL    = PageUtility.CreateUrlWithNewQueryValue(Request, "Version", "versionchangeid")
                    , ItemSummaryDatabase = ApplicationInstance.Instance.GetItemSummaryDatabase()
                    , GetItemInfoFunc     = ApplicationInstance.Instance.GetItemInfo
                }));
            }
            else
            {
                Response.Redirect("RaidOverview.aspx?Raid=" + uniqueRaidID);
            }
        }
Ejemplo n.º 2
0
        //public static bool derp = false;
        //public static void ValidateCacheOutput(HttpContext context, Object data,
        //    ref HttpValidationStatus status)
        //{
        //    if (derp == true)
        //        status = HttpValidationStatus.Valid;
        //    else
        //        status = HttpValidationStatus.Invalid;
        //    if (context.Request.QueryString["Status"] != null)
        //    {
        //        string pageStatus = context.Request.QueryString["Status"];

        //        if (pageStatus == "invalid")
        //            status = HttpValidationStatus.Invalid;
        //        else if (pageStatus == "ignore")
        //            status = HttpValidationStatus.IgnoreThisRequest;
        //        else
        //            status = HttpValidationStatus.Valid;
        //    }
        //    else
        //        status = HttpValidationStatus.Valid;
        //}
        protected void Page_Load(object sender, EventArgs e)
        {
            //Response.Cache.AddValidationCallback(
            //    new HttpCacheValidateHandler(ValidateCacheOutput),
            //    null);
            //Response.Cache.SetExpires(DateTime.Now.AddSeconds(600));
            //Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
            //Response.Cache.SetValidUntilExpires(true);

            bool filteredData = PageUtility.GetQueryString(Request, "Filtered", "true") == "true";
            int  uniqueRaidID = PageUtility.GetQueryInt(Request, "Raid", -1);

            if (uniqueRaidID == -1)
            {
                Response.Redirect("RaidList.aspx");
            }

            this.Title = "Raid " + uniqueRaidID + " | RaidStats";

#if false//LIMIT_USERS_USING_LOGIN_SYSTEM
            if ((DateTime.Now - ApplicationInstance.Instance.GetRaidDate(uniqueRaidID)).TotalDays > 30)
            {
                var user = Authentication.GetSessionUser(Page, true);
                if (user.IsPremium() == false)
                {
                    m_TrashHTML = new MvcHtmlString("Sorry. Raids that are older than 30 days are only viewable for Premium users!");
                    return;
                }
            }
#endif
            if (PageUtility.GetQueryString(Request, "Debug", "null") != "null")
            {
                var raidFiles = ApplicationInstance.Instance.GetRaidFiles(uniqueRaidID);
                if (raidFiles != null)
                {
                    Logger.ConsoleWriteLine("RaidOverview::Debug(): GetRaidFiles was: \"" + raidFiles.MergeToStringVF("\", \"") + "\"", ConsoleColor.DarkYellow);
                }
                else
                {
                    Logger.ConsoleWriteLine("RaidOverview::Debug(): GetRaidFiles was null!", ConsoleColor.DarkYellow);
                }
            }
            var orderedFights = ApplicationInstance.Instance.GetRaidBossFights(uniqueRaidID);
            if (orderedFights == null || orderedFights.Count() == 0)
            {
                Response.Redirect("RaidList.aspx");
            }

            var orderedTrashFights = ApplicationInstance.Instance.GetRaidTrashFights(uniqueRaidID);

            var realmDB = ApplicationInstance.Instance.GetRealmDB(orderedFights.First().GetRaid().Realm);

            var currRaid = orderedFights.First().GetRaid();
            if (currRaid.Realm == VF_RealmPlayersDatabase.WowRealm.Test_Server && PageUtility.GetQueryString(Request, "Debug") == "null")
            {
                Response.Redirect("RaidList.aspx");
            }
            m_BreadCrumbHTML = new MvcHtmlString(PageUtility.BreadCrumb_AddHome()
                                                 + PageUtility.BreadCrumb_AddRaidList()
                                                 + PageUtility.BreadCrumb_AddLink("RaidList.aspx?Guild=" + currRaid.RaidOwnerName + "&realm=" + StaticValues.ConvertRealmParam(realmDB.Realm), currRaid.RaidOwnerName)
                                                 + PageUtility.BreadCrumb_AddFinish(currRaid.RaidInstance + "(" + currRaid.RaidID.ToString() + ")"));

            bool displayLoot = false;
            if (orderedFights.FindIndex((_Value) => _Value.GetItemDrops().Count > 0) != -1)
            {
                displayLoot = true;
            }

            m_TableHeadHTML = new MvcHtmlString(
                PageUtility.CreateTableRow("",
                                           PageUtility.CreateTableColumnHead("#Nr") +
                                           PageUtility.CreateTableColumnHead("Boss") +
                                           PageUtility.CreateTableColumnHead("Players") +
                                           (displayLoot == true ? PageUtility.CreateTableColumnHead("Items Dropped") : "") +
                                           //PageUtility.CreateTableColumnHead(PageUtility.CreateTooltipText("Recorded Damage", "Recorded damage done by players during the fight")) +
                                           PageUtility.CreateTableColumnHead("Player Deaths") +
                                           PageUtility.CreateTableColumnHead("Fight Duration") +
                                           PageUtility.CreateTableColumnHead("Kill Time") +
                                           PageUtility.CreateTableColumnHead(PageUtility.CreateTooltipText("Precision", "How much percentage of the recorded fight is vs the boss intended. Calculated using the formula: Boss+Adds DmgTaken/Recorded Damage"))));


            List <string> attendingRaidPlayers = new List <string>();
            string        tableBody            = "";
            foreach (var fight in orderedFights)
            {
                var attendingFightPlayers = fight.GetAttendingUnits((_Name) => { return(realmDB.RD_IsPlayer(_Name, fight)); });
                attendingRaidPlayers.AddRange(attendingFightPlayers);

                double precision = fight.CalculatePrecision(realmDB.RD_IsPlayerFunc(fight));

                var    attemptType = fight.GetFightData().GetAttemptType();
                string attemptStr  = "";
                if (attemptType == VF_RaidDamageDatabase.FightData.AttemptType.KillAttempt)
                {
                    attemptStr = "(kill)";
                }
                else if (attemptType == VF_RaidDamageDatabase.FightData.AttemptType.WipeAttempt)
                {
                    attemptStr = "(attempt)";
                }

                string trashPercentageStr = "<font color='#FF0000'>???</font>";
                if (precision != 0)
                {
                    double trashPercentage = precision;
                    if (precision >= 1.0)
                    {
                        precision = 1.0;
                    }
                    trashPercentageStr = PageUtility.CreateColorisedPercentage(precision);
                }
                var realm = fight.GetRaid().Realm;
                ///////////////////////
                string lootDropped = "";
                if (attemptType == VF_RaidDamageDatabase.FightData.AttemptType.KillAttempt)
                {
                    lootDropped = LootGenerator.CreateLootDroppedData(fight.GetItemDrops(), realmDB, ApplicationInstance.Instance.GetItemSummaryDatabase(), ApplicationInstance.Instance.GetItemInfo);
                }
                ///////////////////////

                tableBody += PageUtility.CreateTableRow("", PageUtility.CreateTableColumn("#" + (fight.GetRaidBossFightIndex() + 1)) +
                                                        PageUtility.CreateTableColumn(PageUtility.CreateLink("FightOverview.aspx?Raid=" + uniqueRaidID + "&Fight=" + fight.GetRaidBossFightIndex(), "<font color='#f70002'>" + fight.GetFightData().FightName + "</font>") + attemptStr) +
                                                        PageUtility.CreateTableColumn(attendingFightPlayers.Count.ToString()) +
                                                        (displayLoot == true ? PageUtility.CreateTableColumn(lootDropped) : "") +
                                                        //PageUtility.CreateTableColumn(((int)(totalValue / 1000)).ToString() + "k") +
                                                        PageUtility.CreateTableColumn(((int)fight.GetTotal((_Value) => { return(_Value.I.Death); }
                                                                                                           , (_Value) => { return(realmDB.RD_IsPlayer(_Value.Item1, fight) && _Value.Item2.I.Death > 0); })).ToString()) +
                                                        PageUtility.CreateTableColumn(fight.GetFightDuration().ToString() + " sec") +
                                                        PageUtility.CreateTableColumn(fight.GetFightData().StartDateTime.AddSeconds(fight.GetFightData().GetFightRecordDuration()).ToLocalTime().ToString("yyy-MM-dd HH:mm:ss")) +
                                                        PageUtility.CreateTableColumn(trashPercentageStr));//PageUtility.CreateTooltipText(trashPercentageStr, (bossPlusAddsDmgTaken != 0 ? bossPlusAddsDmgTaken.ToString() : "???") + "/" + totalValue.ToString())));
            }
            m_TableBodyHTML = new MvcHtmlString(tableBody);

            /////////////////////
            List <Tuple <string, VF_RealmPlayersDatabase.PlayerClass> > playersAttending = new List <Tuple <string, VF_RealmPlayersDatabase.PlayerClass> >();

            foreach (var playerName in attendingRaidPlayers.Distinct())
            {
                var playerData = realmDB.RD_FindPlayer(playerName, attendingRaidPlayers);
                if (playerData != null)
                {
                    playersAttending.Add(new Tuple <string, VF_RealmPlayersDatabase.PlayerClass>(playerName, playerData.Character.Class));
                }
            }
            string playersAttendingStr     = "<h3>Players attending(" + playersAttending.Count + "):</h3>";
            var    orderedPlayersAttending = playersAttending.OrderBy((_Value) => { return("" + (int)_Value.Item2 + _Value.Item1); });

            try
            {
                var lastClass = orderedPlayersAttending.First().Item2;
                foreach (var player in orderedPlayersAttending)
                {
                    if (lastClass != player.Item2)
                    {
                        playersAttendingStr += "<br />";
                    }
                    playersAttendingStr += PageUtility.CreateColorCodedName(player.Item1, player.Item2) + " ";
                    lastClass            = player.Item2;
                }
            }
            catch (Exception ex)
            {
            }
            /////////////////////

            var    recordedBy       = currRaid.GetRecordedByPlayers();
            string recordedByString = "";
            foreach (var playerName in recordedBy)
            {
                var playerData = realmDB.RD_FindPlayer(playerName, attendingRaidPlayers);
                if (playerData != null)
                {
                    if (recordedByString == "")
                    {
                        recordedByString += " by ";
                    }
                    recordedByString += PageUtility.CreateColorCodedName(playerData) + ", ";
                }
            }
            if (recordedByString != "")
            {
                recordedByString = recordedByString.Substring(0, recordedByString.Length - 2); //Get rid of last ", "
                if (recordedByString.Contains(", "))
                {
                    var subStr      = recordedByString.Substring(recordedByString.LastIndexOf(", "));
                    var replacement = subStr.Replace(", ", " and ");
                    recordedByString = recordedByString.Replace(subStr, replacement);
                }
            }

            var startRecordTime = orderedFights.First().GetFightData().StartDateTime.ToLocalTime();
            var endRecordTime   = orderedFights.Last().GetFightData().GetEndDateTime().ToLocalTime();

            var totalRecordTime = " (" + ((int)(endRecordTime - startRecordTime).TotalMinutes) + " minutes and " + (endRecordTime - startRecordTime).Seconds + " seconds)";

            m_RaidOverviewInfoHTML = "<h1>" + currRaid.RaidOwnerName + " vs "
                                     + currRaid.RaidInstance + "(" + currRaid.RaidID.ToString() + ")<span class='badge badge-inverse'>" + orderedFights.Count() + " fights</span></h1>"
                                     + "<p>Fights recorded" + recordedByString + " between " + startRecordTime.ToString("yyy-MM-dd HH:mm:ss") + " and "
                                     + endRecordTime.ToString("yyy-MM-dd HH:mm:ss") + totalRecordTime + "</p>" + playersAttendingStr;

            string graphStyle      = "<style>" + PageUtility.CreateStatsBars_HTML_CSSCode() + "</style>";
            string totalBossMeters = "<h2>Damage/Healing total(only bosses)</h2>" +
                                     "<p>Total for all boss fights";
            string totalTrashMeters = "<h2>Damage/Healing total(only trash)</h2>" +
                                      "<p>Total for all trash fights";

            if (filteredData == true)
            {
                totalBossMeters += ", unrealistic dmg/heal spikes are filtered. <a href='"
                                   + PageUtility.CreateUrlWithNewQueryValue(Request, "Filtered", "false")
                                   + "'>View Unfiltered</a></p><br />";
                totalTrashMeters += ", unrealistic dmg/heal spikes are filtered. <a href='"
                                    + PageUtility.CreateUrlWithNewQueryValue(Request, "Filtered", "false")
                                    + "'>View Unfiltered</a></p><br />";
            }
            else
            {
                totalBossMeters += ", unrealistic dmg/heal spikes are not filtered. <a href='"
                                   + PageUtility.CreateUrlWithNewQueryValue(Request, "Filtered", "true")
                                   + "'>View Filtered</a></p><br />";
                totalTrashMeters += ", unrealistic dmg/heal spikes are not filtered. <a href='"
                                    + PageUtility.CreateUrlWithNewQueryValue(Request, "Filtered", "true")
                                    + "'>View Filtered</a></p><br />";
            }

            totalBossMeters += GenerateTotalMeters(filteredData, orderedFights, realmDB, attendingRaidPlayers);
            if (orderedTrashFights.Count > 0)
            {
                totalTrashMeters += GenerateTotalMeters(filteredData, orderedTrashFights, realmDB, attendingRaidPlayers);
            }
            else
            {
                totalTrashMeters = "";
            }
            m_GraphSection = new MvcHtmlString(graphStyle + "<div class='blackframe'>" + totalBossMeters + "</div><br/><div class='blackframe'>" + totalTrashMeters + "</div>");

            //TRASH HANDLING
            {
                if (orderedTrashFights.Count > 0)
                {
                    System.Text.StringBuilder trashSection = new System.Text.StringBuilder(4000);

                    trashSection.Append("<div class='row'><div class='span12'><table class='table'><thead>");
                    trashSection.Append(PageUtility.CreateTableRow("",
                                                                   PageUtility.CreateTableColumnHead("Trash") +
                                                                   PageUtility.CreateTableColumnHead("Players") +
                                                                   PageUtility.CreateTableColumnHead("Player Deaths") +
                                                                   PageUtility.CreateTableColumnHead("Trash Duration")));

                    trashSection.Append("</thead><tbody>");

                    foreach (var fight in orderedTrashFights)
                    {
                        var attendingFightPlayers = fight.GetAttendingUnits((_Name) => { return(realmDB.RD_IsPlayer(_Name, attendingRaidPlayers)); });

                        var endTime = fight.GetStartDateTime().AddSeconds(fight.GetFightData().GetFightRecordDuration());
                        trashSection.Append(PageUtility.CreateTableRow("",
                                                                       PageUtility.CreateTableColumn(PageUtility.CreateLink("FightOverview.aspx?Raid=" + uniqueRaidID + "&Trash=" + fight.GetRaidBossFightIndex(), "<font color='#f70002'>" + fight.GetStartDateTime().ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") + " to " + endTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") + "</font>")) +
                                                                       PageUtility.CreateTableColumn(attendingFightPlayers.Count.ToString()) +
                                                                       PageUtility.CreateTableColumn(((int)fight.GetTotal((_Value) => { return(_Value.I.Death); }
                                                                                                                          , (_Value) => { return(realmDB.RD_IsPlayer(_Value.Item1, attendingRaidPlayers) && _Value.Item2.I.Death > 0); })).ToString()) +
                                                                       PageUtility.CreateTableColumn((int)(endTime - fight.GetStartDateTime()).TotalMinutes + " min")
                                                                       ));
                    }

                    trashSection.Append("</tbody></table></div></div>");

                    m_TrashHTML = new MvcHtmlString(trashSection.ToString());
                }
            }
        }