コード例 #1
0
ファイル: Click.cs プロジェクト: KagefumiMerry/OverParse
        private void EndEncounter_Click(object sender, RoutedEventArgs e)
        {
            //Ending encounter
            bool temp = Properties.Settings.Default.AutoEndEncounters;

            Properties.Settings.Default.AutoEndEncounters = false;
            UpdateForm(null, null); // I'M F*****G STUPID
            Properties.Settings.Default.AutoEndEncounters = temp;
            encounterlog.backupCombatants = encounterlog.combatants;
            Log.backupTime = Log.ActiveTime;

            List <Combatant> workingListCopy = new List <Combatant>();

            foreach (Combatant c in workingList)
            {
                Combatant temp2 = new Combatant(c.ID, c.Name, c.isTemporary);
                foreach (Attack a in c.Attacks)
                {
                    temp2.Attacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                foreach (Attack a in c.AllyAttacks)
                {
                    temp2.AllyAttacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                foreach (Attack a in c.DBAttacks)
                {
                    temp2.DBAttacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                foreach (Attack a in c.LswAttacks)
                {
                    temp2.LswAttacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                foreach (Attack a in c.PwpAttacks)
                {
                    temp2.PwpAttacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                foreach (Attack a in c.AisAttacks)
                {
                    temp2.AisAttacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                foreach (Attack a in c.RideAttacks)
                {
                    temp2.RideAttacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                temp2.Damaged        = c.Damaged;
                temp2.AllyDamage     = c.AllyDamage;
                temp2.DBDamage       = c.DBDamage;
                temp2.LswDamage      = c.LswDamage;
                temp2.PwpDamage      = c.PwpDamage;
                temp2.AisDamage      = c.AisDamage;
                temp2.RideDamage     = c.RideDamage;
                temp2.PercentReadDPS = c.PercentReadDPS;
                workingListCopy.Add(temp2);
            }
            //Saving last combatant list"
            lastCombatants          = encounterlog.combatants;
            encounterlog.combatants = workingListCopy;
            string filename = encounterlog.WriteLog();

            if (filename != null)
            {
                if ((SessionLogs.Items[0] as MenuItem).Name == "SessionLogPlaceholder")
                {
                    SessionLogs.Items.Clear();
                }
                int    items      = SessionLogs.Items.Count;
                string prettyName = filename.Split('/').LastOrDefault();
                sessionLogFilenames.Add(filename);
                var menuItem = new MenuItem()
                {
                    Name = "SessionLog_" + items.ToString(), Header = prettyName
                };
                menuItem.Click += OpenRecentLog_Click;
                SessionLogs.Items.Add(menuItem);
            }
            if (Properties.Settings.Default.LogToClipboard)
            {
                encounterlog.WriteClipboard();
            }

            encounterlog = new Log(Properties.Settings.Default.Path);
            UpdateForm(null, null);
            Log.startTimestamp = Log.nowTimestamp = Log.diffTime = 0;
        }
コード例 #2
0
        public void UpdateForm(object sender, EventArgs e)
        {
            if (Properties.Settings.Default.Clock)
            {
                Datetime.Content = DateTime.Now.ToString("HH:mm:ss.ff");
            }
            if (encounterlog == null)
            {
                return;
            }

            encounterlog.UpdateLog(this, null);
            EncounterStatus.Content = encounterlog.LogStatus();

            // every part of this section is f*****g stupid

            // get a copy of the right combatants
            List <Combatant> targetList = (encounterlog.running ? encounterlog.combatants : lastCombatants);

            workingList = new List <Combatant>();
            foreach (Combatant c in targetList)
            {
                Combatant temp = new Combatant(c.ID, c.Name, c.isTemporary);
                foreach (Attack a in c.Attacks)
                {
                    temp.Attacks.Add(new Attack(a.ID, a.Damage, a.Timestamp, a.JA, a.Cri, a.Dmgd));
                }
                temp.ActiveTime = c.ActiveTime;
                workingList.Add(temp);
            }

            // clear out the list
            CombatantData.Items.Clear();
            AllyData.Items.Clear();
            DBData.Items.Clear();
            LswData.Items.Clear();
            PwpData.Items.Clear();
            AisData.Items.Clear();
            RideData.Items.Clear();
            //workingList.RemoveAll(c => c.isTemporary != "no");

            // for zanverse dummy and status bar because WHAT IS GOOD STRUCTURE
            int       elapsed = 0;
            Combatant stealActiveTimeDummy = workingList.FirstOrDefault();

            if (stealActiveTimeDummy != null)
            {
                elapsed = stealActiveTimeDummy.ActiveTime;
            }

            // create and sort dummy AIS combatants
            if (Properties.Settings.Default.SeparateAIS)
            {
                List <Combatant> pendingCombatants = new List <Combatant>();

                foreach (Combatant c in workingList)
                {
                    if (!c.IsAlly)
                    {
                        continue;
                    }
                    if (c.AisDamage > 0)
                    {
                        Combatant     AISHolder     = new Combatant(c.ID, "AIS|" + c.Name, "AIS");
                        List <Attack> targetAttacks = c.Attacks.Where(a => Combatant.AISAttackIDs.Contains(a.ID)).ToList();
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        AISHolder.Attacks.AddRange(targetAttacks);
                        AISHolder.ActiveTime = elapsed;
                        pendingCombatants.Add(AISHolder);
                    }
                }
                workingList.AddRange(pendingCombatants);
            }

            if (Properties.Settings.Default.SeparateDB)
            {
                List <Combatant> pendingDBCombatants = new List <Combatant>();

                foreach (Combatant c in workingList)
                {
                    if (!c.IsAlly)
                    {
                        continue;
                    }
                    if (c.DBDamage > 0)
                    {
                        Combatant     DBHolder      = new Combatant(c.ID, "DB|" + c.Name, "DB");
                        List <Attack> targetAttacks = c.Attacks.Where(a => Combatant.DBAttackIDs.Contains(a.ID)).ToList();
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        DBHolder.Attacks.AddRange(targetAttacks);
                        DBHolder.ActiveTime = elapsed;
                        pendingDBCombatants.Add(DBHolder);
                    }
                }
                workingList.AddRange(pendingDBCombatants);
            }

            if (Properties.Settings.Default.SeparateRide)
            {
                List <Combatant> pendingRideCombatants = new List <Combatant>();

                foreach (Combatant c in workingList)
                {
                    if (!c.IsAlly)
                    {
                        continue;
                    }
                    if (c.RideDamage > 0)
                    {
                        Combatant     RideHolder    = new Combatant(c.ID, "Ride|" + c.Name, "Ride");
                        List <Attack> targetAttacks = c.Attacks.Where(a => Combatant.RideAttackIDs.Contains(a.ID)).ToList();
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        RideHolder.Attacks.AddRange(targetAttacks);
                        RideHolder.ActiveTime = elapsed;
                        pendingRideCombatants.Add(RideHolder);
                    }
                }
                workingList.AddRange(pendingRideCombatants);
            }

            if (Properties.Settings.Default.SeparatePwp)
            {
                List <Combatant> pendingPwpCombatants = new List <Combatant>();

                foreach (Combatant c in workingList)
                {
                    if (!c.IsAlly)
                    {
                        continue;
                    }
                    if (c.PwpDamage > 0)
                    {
                        Combatant     PhotonHolder  = new Combatant(c.ID, "Pwp|" + c.Name, "Pwp");
                        List <Attack> targetAttacks = c.Attacks.Where(a => Combatant.PhotonAttackIDs.Contains(a.ID)).ToList();
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        PhotonHolder.Attacks.AddRange(targetAttacks);
                        PhotonHolder.ActiveTime = elapsed;
                        pendingPwpCombatants.Add(PhotonHolder);
                    }
                }
                workingList.AddRange(pendingPwpCombatants);
            }

            if (Properties.Settings.Default.SeparateLsw)
            {
                List <Combatant> pendingLswCombatants = new List <Combatant>();

                foreach (Combatant c in workingList)
                {
                    if (!c.IsAlly)
                    {
                        continue;
                    }
                    if (c.LswDamage > 0)
                    {
                        Combatant     LswHolder     = new Combatant(c.ID, "Lsw|" + c.Name, "Lsw");
                        List <Attack> targetAttacks = c.Attacks.Where(a => Combatant.LaconiumAttackIDs.Contains(a.ID)).ToList();
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        LswHolder.Attacks.AddRange(targetAttacks);
                        LswHolder.ActiveTime = elapsed;
                        pendingLswCombatants.Add(LswHolder);
                    }
                }
                workingList.AddRange(pendingLswCombatants);
            }

            // force resort here to neatly shuffle AIS parses back into place
            workingList.Sort((x, y) => y.ReadDamage.CompareTo(x.ReadDamage));

            // make dummy zanverse combatant if necessary
            int totalZanverse = workingList.Where(c => c.IsAlly == true).Sum(x => x.GetZanverseDamage);
            int totalFinish   = workingList.Where(c => c.IsAlly == true).Sum(x => x.GetFinishDamage);

            if (Properties.Settings.Default.SeparateFinish)
            {
                if (totalFinish > 0)
                {
                    Combatant finishHolder = new Combatant("99999995", "HTF Attacks", "HTF Attacks");
                    foreach (Combatant c in workingList)
                    {
                        if (c.IsAlly)
                        {
                            List <Attack> targetAttacks = c.Attacks.Where(a => Combatant.FinishAttackIDs.Contains(a.ID)).ToList();
                            finishHolder.Attacks.AddRange(targetAttacks);
                            c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        }
                    }
                    finishHolder.ActiveTime = elapsed;
                    workingList.Add(finishHolder);
                }
            }

            if (Properties.Settings.Default.SeparateZanverse)
            {
                if (totalZanverse > 0)
                {
                    Combatant zanverseHolder = new Combatant("99999997", "Zanverse", "Zanverse");
                    foreach (Combatant c in workingList)
                    {
                        if (c.IsAlly)
                        {
                            List <Attack> targetAttacks = c.Attacks.Where(a => a.ID == "2106601422").ToList();
                            zanverseHolder.Attacks.AddRange(targetAttacks);
                            c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        }
                    }
                    zanverseHolder.ActiveTime = elapsed;
                    workingList.Add(zanverseHolder);
                }
            }


            // get group damage totals
            int totalReadDamage = workingList.Where(c => (c.IsAlly || c.IsZanverse || c.IsFinish || c.IsAIS || c.IsPwp || c.IsDB || c.IsRide)).Sum(x => x.ReadDamage);

            // dps calcs!
            foreach (Combatant c in workingList)
            {
                if (c.IsAlly || c.IsZanverse || c.IsFinish)
                {
                    c.PercentReadDPS = c.ReadDamage / (float)totalReadDamage * 100;
                    c.AllyPct        = c.AllyDamage / (float)totalReadDamage * 100;
                    c.DBPct          = c.DBDamage / (float)totalReadDamage * 100;
                    c.LswPct         = c.LswDamage / (float)totalReadDamage * 100;
                    c.PwpPct         = c.PwpDamage / (float)totalReadDamage * 100;
                    c.AisPct         = c.AisDamage / (float)totalReadDamage * 100;
                    c.RidePct        = c.RideDamage / (float)totalReadDamage * 100;
                }
                else
                {
                    c.PercentDPS     = -1;
                    c.PercentReadDPS = -1;
                    c.AllyPct        = -1;
                    c.DBPct          = -1;
                    c.LswPct         = -1;
                    c.PwpPct         = -1;
                    c.AisPct         = -1;
                    c.RidePct        = -1;
                }
            }


            // damage graph stuff
            Combatant.maxShare = 0;
            foreach (Combatant c in workingList)
            {
                if ((c.IsAlly) && c.ReadDamage > Combatant.maxShare)
                {
                    Combatant.maxShare = c.ReadDamage;
                }

                bool filtered = true;
                if (Properties.Settings.Default.SeparateAIS || Properties.Settings.Default.SeparateDB || Properties.Settings.Default.SeparateRide || Properties.Settings.Default.SeparatePwp || Properties.Settings.Default.SeparateLsw)
                {
                    if (c.IsAlly && c.isTemporary == "no" && !HidePlayers.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.IsAlly && c.isTemporary == "AIS" && !HideAIS.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.IsAlly && c.isTemporary == "DB" && !HideDB.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.IsAlly && c.isTemporary == "Ride" && !HideRide.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.IsAlly && c.isTemporary == "Pwp" && !HidePwp.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.IsAlly && c.isTemporary == "Lsw" && !HideLsw.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.IsZanverse)
                    {
                        filtered = false;
                    }
                    if (c.IsFinish)
                    {
                        filtered = false;
                    }
                }
                else
                {
                    if ((c.IsAlly || c.IsZanverse || c.IsFinish || !FilterPlayers.IsChecked) && (c.Damage > 0))
                    {
                        filtered = false;
                    }
                }

                if (!filtered && c.Damage > 0)
                {
                    CombatantData.Items.Add(c);
                    AllyData.Items.Add(c);
                }

                if (c.DBDamage > 0)
                {
                    workingList.Sort((x, y) => y.DBDamage.CompareTo(x.DBDamage)); DBData.Items.Add(c);
                }
                if (c.LswDamage > 0)
                {
                    workingList.Sort((x, y) => y.LswDamage.CompareTo(x.LswDamage)); LswData.Items.Add(c);
                }
                if (c.PwpDamage > 0)
                {
                    workingList.Sort((x, y) => y.PwpDamage.CompareTo(x.PwpDamage)); PwpData.Items.Add(c);
                }
                if (c.AisDamage > 0)
                {
                    workingList.Sort((x, y) => y.AisDamage.CompareTo(x.AisDamage)); AisData.Items.Add(c);
                }
                if (c.RideDamage > 0)
                {
                    workingList.Sort((x, y) => y.RideDamage.CompareTo(x.RideDamage)); RideData.Items.Add(c);
                }
                workingList.Sort((x, y) => y.ReadDamage.CompareTo(x.ReadDamage));
            }


            // status pane updates
            EncounterIndicator.Fill = new SolidColorBrush(Color.FromArgb(192, 255, 128, 128));
            EncounterStatus.Content = encounterlog.LogStatus();

            if (encounterlog.valid && encounterlog.notEmpty)
            {
                EncounterIndicator.Fill = new SolidColorBrush(Color.FromArgb(192, 64, 192, 64));
                EncounterStatus.Content = $"Waiting - {lastStatus}";
                if (lastStatus == "")
                {
                    EncounterStatus.Content = "Waiting... - " + encounterlog.filename;
                }

                CombatantData.Items.Refresh();
                AllyData.Items.Refresh();
                DBData.Items.Refresh();
                LswData.Items.Refresh();
                PwpData.Items.Refresh();
                AisData.Items.Refresh();
                RideData.Items.Refresh();
            }

            if (encounterlog.running)
            {
                EncounterIndicator.Fill = new SolidColorBrush(Color.FromArgb(192, 0, 192, 255));

                TimeSpan timespan = TimeSpan.FromSeconds(elapsed);
                string   timer    = timespan.ToString(@"h\:mm\:ss");
                EncounterStatus.Content = $"{timer}";

                float totalDPS = totalReadDamage / (float)elapsed;

                if (totalDPS > 0)
                {
                    EncounterStatus.Content += $" - Total : {totalReadDamage.ToString("N0")}" + $" - {totalDPS.ToString("N0")} DPS";
                }

                //if (Properties.Settings.Default.CompactMode)
                //foreach (Combatant c in workingList)
                //if (c.IsYou)
                //EncounterStatus.Content += $" - MAX: {c.MaxHitNum.ToString("N0")}";

                if (!Properties.Settings.Default.SeparateZanverse)
                {
                    EncounterStatus.Content += $" - Zanverse : {totalZanverse.ToString("N0")}";
                }

                lastStatus = EncounterStatus.Content.ToString();
            }

            // autoend
            if (encounterlog.running)
            {
                if (Properties.Settings.Default.AutoEndEncounters)
                {
                    int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                    if ((unixTimestamp - encounterlog.newTimestamp) >= Properties.Settings.Default.EncounterTimeout)
                    {
                        //Automatically ending an encounter
                        EndEncounter_Click(null, null);
                    }
                }
            }
        }
コード例 #3
0
        public void UpdateLog(object sender, EventArgs e)
        {
            if (!valid || !notEmpty)
            {
                return;
            }

            string newLines = logReader.ReadToEnd();

            if (newLines != "")
            {
                string[] result = newLines.Split('\n');
                foreach (string str in result)
                {
                    if (str != "")
                    {
                        string[] parts         = str.Split(',');
                        string   lineTimestamp = parts[0];
                        string   sourceID      = parts[2];
                        string   targetID      = parts[4];
                        string   targetName    = parts[5];
                        string   sourceName    = parts[3];
                        int      hitDamage     = int.Parse(parts[7]);
                        string   attackID      = parts[6];
                        string   isMultiHit    = parts[10];
                        string   isMisc        = parts[11];
                        string   isMisc2       = parts[12];
                        int      index         = -1;

                        if (hitDamage < 1)
                        {
                            continue;
                        }
                        if (sourceID == "0" || attackID == "0")
                        {
                            continue;
                        }

                        foreach (Combatant x in combatants)
                        {
                            if (x.ID == sourceID)
                            {
                                index = combatants.IndexOf(x);
                            }
                        }

                        if (attackID == "2106601422" && Properties.Settings.Default.SeparateZanverse)
                        {
                            index = -1;
                            foreach (Combatant x in combatants)
                            {
                                if (x.ID == "94857493" && x.Name == "Zanverse")
                                {
                                    index = combatants.IndexOf(x);
                                }
                            }

                            sourceID   = "94857493";
                            sourceName = "Zanverse";
                        }

                        if (index == -1)
                        {
                            combatants.Add(new Combatant(sourceID, sourceName));
                            index = combatants.Count - 1;
                        }

                        Combatant source = combatants[index];

                        source.Damage += hitDamage;
                        newTimestamp   = int.Parse(lineTimestamp);
                        if (startTimestamp == 0)
                        {
                            Console.WriteLine($"FIRST ATTACK RECORDED: {hitDamage} dmg from {sourceID} ({sourceName}) with {attackID}, to {targetID} ({targetName})");
                            startTimestamp = newTimestamp;
                        }

                        source.Attacks.Add(new Attack(attackID, hitDamage, newTimestamp - startTimestamp));
                        running = true;

                        if (source.MaxHitNum < hitDamage)
                        {
                            source.MaxHitNum = hitDamage;
                            source.MaxHitID  = attackID;
                        }
                    }
                }

                combatants.Sort((x, y) => y.Damage.CompareTo(x.Damage));

                if (startTimestamp != 0)
                {
                    encounterData = "00:00 - ∞ DPS";
                }

                if (startTimestamp != 0 && newTimestamp != startTimestamp)
                {
                    int      elapsed              = newTimestamp - startTimestamp;
                    float    partyDPS             = 0;
                    float    zanverseCompensation = 0;
                    int      filtered             = 0;
                    TimeSpan timespan             = TimeSpan.FromSeconds(elapsed);
                    string   timer = timespan.ToString(@"mm\:ss");
                    encounterData = $"{timer}";

                    if (Properties.Settings.Default.CompactMode)
                    {
                        foreach (Combatant c in combatants)
                        {
                            if (c.Name == "YOU")
                            {
                                encounterData += $" - MAX: {c.MaxHitNum}";
                            }
                        }
                    }


                    foreach (Combatant x in combatants)
                    {
                        if (x.isAlly)
                        {
                            float dps = x.Damage / (newTimestamp - startTimestamp);
                            x.DPS     = dps;
                            partyDPS += dps;
                        }
                        else
                        {
                            filtered++;
                        }

                        if (x.Name == "Zanverse")
                        {
                            zanverseCompensation = x.DPS;
                        }
                    }

                    float workingPartyDPS = partyDPS - zanverseCompensation;


                    foreach (Combatant x in combatants)
                    {
                        if (x.isAlly && x.Name != "Zanverse")
                        {
                            x.PercentDPS = (x.DPS / workingPartyDPS * 100);
                        }
                        else
                        {
                            x.PercentDPS = -1;
                        }
                    }

                    encounterData += $" - {partyDPS.ToString("0.00")} DPS";
                }
            }
        }
コード例 #4
0
ファイル: Log.cs プロジェクト: Freyaday/OverParse
        public void GenerateFakeEntries()
        {
            float totalDPS = 0;
            for (int i = 0; i <= 12; i++)
            {
                Combatant temp = new Combatant("1000000" + i.ToString(), "TestPlayer_" + random.Next(0,99).ToString());
                totalDPS += temp.DPS = random.Next(0, 10000000);
                temp.Damage = random.Next(0, 1000000);
                temp.MaxHitNum = random.Next(0, 1000000);
                temp.MaxHitID = "2368738938";
                combatants.Add(temp);
            }

            foreach(Combatant c in combatants)
                c.PercentDPS=c.DPS/totalDPS*100;

            for (int i = 0; i <= 9; i++)
            {
                Combatant temp = new Combatant(i.ToString(), "TestEnemy_" + i.ToString());
                temp.PercentDPS = -1;
                temp.DPS = random.Next(0, 1000000);
                temp.Damage = random.Next(0, 10000000);
                temp.MaxHitNum = random.Next(0, 1000000);
                temp.MaxHitID = "1612949165";
                combatants.Add(temp);
            }

            valid = true;
            running = true;
        }
コード例 #5
0
        public void UpdateForm(object sender, EventArgs e)
        {
            encounterlog.UpdateLog(this, null);

            EncounterStatus.Content = encounterlog.logStatus();


            if (encounterlog.running)
            {
                SeparateZanverse.IsEnabled = false;

                CombatantData.Items.Clear();

                int       index   = -1; // there's probably a way better way of doing this, maybe someday i'll learn LINQ
                Combatant reorder = null;
                foreach (Combatant c in encounterlog.combatants)
                {
                    if (c.Name == "Zanverse")
                    {
                        index   = encounterlog.combatants.IndexOf(c);
                        reorder = c;
                    }
                }
                if (index != -1)
                {
                    encounterlog.combatants.RemoveAt(index);
                    encounterlog.combatants.Add(reorder);
                }


                DamageGraph.ColumnDefinitions.Clear();//Freyaday is responsible for the DamageGraph. Yell at him if it breaks.
                DamageGraph.Children.Clear();
                Combatant.maxShare = 0;

                foreach (Combatant c in encounterlog.combatants)
                {
                    if (c.isAlly || !FilterPlayers.IsChecked)
                    {
                        CombatantData.Items.Add(c);
                        if (c.PercentDPS > Combatant.maxShare)
                        {
                            Combatant.maxShare = c.PercentDPS;
                        }
                    }
                }

                foreach (Combatant c in CombatantData.Items)
                {
                    if (c.PercentDPS >= 0)
                    {
                        ColumnDefinition cd = new ColumnDefinition();
                        cd.Width    = new GridLength(c.PercentDPS / 100, GridUnitType.Star);
                        cd.ToolTip  = c.Name + ", " + c.DPSReadout + " DPS";
                        cd.MinWidth = 1;
                        DamageGraph.ColumnDefinitions.Add(cd);

                        Rectangle r = new Rectangle();
                        r.Visibility   = Visibility.Visible;
                        r.Fill         = c.BarBrush;
                        r.Height       = 2;
                        r.Width        = DamageGraph.ActualWidth;
                        r.ClipToBounds = true;
                        r.MinWidth     = 1;
                        r.Margin       = new Thickness(0);
                        Grid.SetColumn(r, DamageGraph.ColumnDefinitions.Count - 1);
                        Grid.SetRow(r, 0);
                        DamageGraph.Children.Add(r);
                        c.bar = r;
                    }
                }


                if (Properties.Settings.Default.AutoEndEncounters)
                {
                    int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                    if ((unixTimestamp - encounterlog.newTimestamp) >= Properties.Settings.Default.EncounterTimeout)
                    {
                        Console.WriteLine("Automatically ending an encounter");
                        EndEncounter_Click(null, null);
                    }
                }
            }
        }
コード例 #6
0
        public void UpdateForm(object sender, EventArgs e)
        {
            if (encounterlog == null)
            {
                return;
            }

            encounterlog.UpdateLog(this, null);

            EncounterStatus.Content = encounterlog.logStatus();

            // every part of this section is f*****g stupid

            // get a copy of the right combatants
            List <Combatant> targetList = (encounterlog.running ? encounterlog.combatants : lastCombatants);

            workingList = new List <Combatant>();
            foreach (Combatant c in targetList)
            {
                Combatant temp = new Combatant(c.ID, c.Name, c.isTemporary);
                foreach (Attack a in c.Attacks)
                {
                    temp.Attacks.Add(new Attack(a.ID, a.Damage, a.Timestamp));
                }
                temp.ActiveTime = c.ActiveTime;
                workingList.Add(temp);
            }

            // clear out the list
            CombatantData.Items.Clear();
            //workingList.RemoveAll(c => c.isTemporary != "no");

            // for zanverse dummy and status bar because WHAT IS GOOD STRUCTURE
            int       elapsed = 0;
            Combatant stealActiveTimeDummy = workingList.FirstOrDefault();

            if (stealActiveTimeDummy != null)
            {
                elapsed = stealActiveTimeDummy.ActiveTime;
            }

            // create and sort dummy AIS combatants
            if (Properties.Settings.Default.SeparateAIS)
            {
                List <Combatant> pendingCombatants = new List <Combatant>();

                foreach (Combatant c in workingList)
                {
                    if (!c.isAlly)
                    {
                        continue;
                    }
                    if (c.AISDamage > 0)
                    {
                        Combatant     AISHolder     = new Combatant(c.ID, "AIS|" + c.Name, "AIS");
                        List <Attack> targetAttacks = c.Attacks.Where(a => Combatant.AISAttackIDs.Contains(a.ID)).ToList();
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        AISHolder.Attacks.AddRange(targetAttacks);
                        AISHolder.ActiveTime = elapsed;
                        pendingCombatants.Add(AISHolder);
                    }
                }

                workingList.AddRange(pendingCombatants);
            }

            // force resort here to neatly shuffle AIS parses back into place
            workingList.Sort((x, y) => y.ReadDamage.CompareTo(x.ReadDamage));

            // make dummy zanverse combatant if necessary
            if (Properties.Settings.Default.SeparateZanverse)
            {
                int totalZanverse = workingList.Where(c => c.isAlly == true).Sum(x => x.ZanverseDamage);
                if (totalZanverse > 0)
                {
                    Combatant zanverseHolder = new Combatant("99999999", "Zanverse", "Zanverse");
                    foreach (Combatant c in workingList)
                    {
                        if (c.isAlly)
                        {
                            List <Attack> targetAttacks = c.Attacks.Where(a => a.ID == "2106601422").ToList();
                            zanverseHolder.Attacks.AddRange(targetAttacks);
                            c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        }
                    }
                    zanverseHolder.ActiveTime = elapsed;
                    workingList.Add(zanverseHolder);
                }
            }

            // get group damage totals
            int totalReadDamage = workingList.Where(c => (c.isAlly || c.isZanverse)).Sum(x => x.ReadDamage);

            // dps calcs!
            foreach (Combatant c in workingList)
            {
                if (c.isAlly || c.isZanverse)
                {
                    c.PercentReadDPS = c.ReadDamage / (float)totalReadDamage * 100;
                }
                else
                {
                    c.PercentDPS     = -1;
                    c.PercentReadDPS = -1;
                }
            }

            // damage graph stuff
            Combatant.maxShare = 0;
            foreach (Combatant c in workingList)
            {
                if ((c.isAlly) && c.ReadDamage > Combatant.maxShare)
                {
                    Combatant.maxShare = c.ReadDamage;
                }

                bool filtered = true;
                if (Properties.Settings.Default.SeparateAIS)
                {
                    if (c.isAlly && c.isTemporary == "no" && !HidePlayers.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.isAlly && c.isTemporary == "AIS" && !HideAIS.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.isZanverse)
                    {
                        filtered = false;
                    }
                }
                else
                {
                    if ((c.isAlly || c.isZanverse || !FilterPlayers.IsChecked) && (c.Damage > 0))
                    {
                        filtered = false;
                    }
                }

                if (!filtered && c.Damage > 0)
                {
                    CombatantData.Items.Add(c);
                }
            }

            // status pane updates
            EncounterIndicator.Fill = new SolidColorBrush(Color.FromArgb(255, 255, 100, 100));
            EncounterStatus.Content = encounterlog.logStatus();

            if (encounterlog.valid && encounterlog.notEmpty)
            {
                EncounterIndicator.Fill = new SolidColorBrush(Color.FromArgb(255, 255, 255, 0));
                EncounterStatus.Content = $"Waiting - {lastStatus}";
                if (lastStatus == "")
                {
                    EncounterStatus.Content = "Waiting for combat data...";
                }

                CombatantData.Items.Refresh();
            }

            if (encounterlog.running)
            {
                EncounterIndicator.Fill = new SolidColorBrush(Color.FromArgb(255, 100, 255, 100));

                TimeSpan timespan = TimeSpan.FromSeconds(elapsed);
                string   timer    = timespan.ToString(@"mm\:ss");
                EncounterStatus.Content = $"{timer}";

                float totalDPS = totalReadDamage / (float)elapsed;

                if (totalDPS > 0)
                {
                    EncounterStatus.Content += $" - {totalDPS.ToString("N2")} DPS";
                }

                if (Properties.Settings.Default.CompactMode)
                {
                    foreach (Combatant c in workingList)
                    {
                        if (c.isYou)
                        {
                            EncounterStatus.Content += $" - MAX: {c.MaxHitNum.ToString("N0")}";
                        }
                    }
                }

                lastStatus = EncounterStatus.Content.ToString();
            }

            // autoend
            if (encounterlog.running)
            {
                if (Properties.Settings.Default.AutoEndEncounters)
                {
                    int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                    if ((unixTimestamp - encounterlog.newTimestamp) >= Properties.Settings.Default.EncounterTimeout)
                    {
                        Console.WriteLine("Automatically ending an encounter");
                        EndEncounter_Click(null, null);
                    }
                }
            }
        }
コード例 #7
0
        // Writes combat data to log file
        public string WriteLog()
        {
            if (combatants.Count != 0) // Players found
            {
                int      elapsed  = newTimestamp - startTimestamp;
                TimeSpan timespan = TimeSpan.FromSeconds(elapsed);

                // Logging the total time occured through out the encounter
                int    totalDamage = combatants.Where(c => c.IsAlly || c.IsStatus || c.IsZanverse || c.IsFinish).Sum(x => x.Damage);
                double totalDPS    = combatants.Where(c => c.IsAlly || c.IsStatus || c.IsZanverse || c.IsFinish).Sum(x => x.DPS);

                string timer = timespan.ToString(@"mm\:ss");
                string log   = DateTime.Now.ToString("F") + " | " + timer + " | Total Damage: " + totalDamage.ToString("N0") + " dmg" + " | " + "Total DPS: " + totalDPS.ToString("N0") + Environment.NewLine + Environment.NewLine;

                log += "[ Encounter Overview ]" + Environment.NewLine; // Title

                foreach (Combatant c in combatants)
                {
                    if (c.IsAlly || c.IsStatus || c.IsZanverse || c.IsFinish)
                    {
                        log += Environment.NewLine + $"# {c.Name}" + Environment.NewLine + $"# Contrib: {c.PercentReadDPSReadout}% | Dealt: {c.ReadDamage.ToString("N0")} dmg | Taken: {c.Damaged.ToString("N0")} dmgd | {c.DPS.ToString("N0")} DPS | JA: {c.WJAPercent}% | Critical: {c.WCRIPercent}% | Max: {c.MaxHitdmg} ({c.MaxHit})" + Environment.NewLine;
                    }
                }

                log += Environment.NewLine + Environment.NewLine;

                foreach (Combatant c in combatants)
                {
                    if (c.IsAlly || c.IsStatus || c.IsZanverse || c.IsFinish)
                    {
                        string header = $"[ {c.Name} - {c.PercentReadDPSReadout}% - {c.ReadDamage.ToString("N0")} dmg ]";
                        log += header + Environment.NewLine + Environment.NewLine;

                        List <string> attackNames = new List <string>();
                        List <string> finishNames = new List <string>();
                        List <string> statusNames = new List <string>();

                        List <Tuple <string, List <int>, List <int>, List <int> > > attackData = new List <Tuple <string, List <int>, List <int>, List <int> > >();

                        if (c.IsZanverse && Properties.Settings.Default.SeparateZanverse)
                        {
                            foreach (Combatant c2 in backupCombatants)
                            {
                                if (c2.ZvsDamage > 0)
                                {
                                    attackNames.Add(c2.ID);
                                }
                            }

                            foreach (string s in attackNames)
                            {
                                Combatant  targetCombatant = backupCombatants.First(x => x.ID == s);
                                List <int> matchingAttacks = targetCombatant.Attacks.Where(a => a.ID == "2106601422").Select(a => a.Damage).ToList();
                                List <int> jaPercents      = c.Attacks.Where(a => a.ID == "2106601422").Select(a => a.JA).ToList();
                                List <int> criPercents     = c.Attacks.Where(a => a.ID == "2106601422").Select(a => a.Cri).ToList();
                                attackData.Add(new Tuple <string, List <int>, List <int>, List <int> >(targetCombatant.Name, matchingAttacks, jaPercents, criPercents));
                            }
                        }

                        else if (c.IsFinish && Properties.Settings.Default.SeparateFinish)
                        {
                            foreach (Combatant c3 in backupCombatants)
                            {
                                if (c3.HTFDamage > 0)
                                {
                                    finishNames.Add(c3.ID);
                                }
                            }

                            foreach (string htf in finishNames)
                            {
                                Combatant  tCombatant       = backupCombatants.First(x => x.ID == htf);
                                List <int> fmatchingAttacks = tCombatant.Attacks.Where(a => Combatant.FinishAttackIDs.Contains(a.ID)).Select(a => a.Damage).ToList();
                                List <int> jaPercents       = c.Attacks.Where(a => Combatant.FinishAttackIDs.Contains(a.ID)).Select(a => a.JA).ToList();
                                List <int> criPercents      = c.Attacks.Where(a => Combatant.FinishAttackIDs.Contains(a.ID)).Select(a => a.Cri).ToList();
                                attackData.Add(new Tuple <string, List <int>, List <int>, List <int> >(tCombatant.Name, fmatchingAttacks, jaPercents, criPercents));
                            }
                        }
                        else if (c.IsStatus && Properties.Settings.Default.SeparateStatus)
                        {
                            foreach (Combatant c4 in backupCombatants)
                            {
                                if (c4.DotDamage > 0)
                                {
                                    statusNames.Add(c4.ID);
                                }
                            }

                            foreach (string dot in statusNames)
                            {
                                Combatant  tCombatant      = backupCombatants.First(x => x.ID == dot);
                                List <int> matchingAttacks = tCombatant.Attacks.Where(a => Combatant.StatusAttackIDs.Contains(a.ID)).Select(a => a.Damage).ToList();
                                List <int> jaPercents      = c.Attacks.Where(a => Combatant.StatusAttackIDs.Contains(a.ID)).Select(a => a.JA).ToList();
                                List <int> criPercents     = c.Attacks.Where(a => Combatant.StatusAttackIDs.Contains(a.ID)).Select(a => a.Cri).ToList();
                                attackData.Add(new Tuple <string, List <int>, List <int>, List <int> >(tCombatant.Name, matchingAttacks, jaPercents, criPercents));
                            }
                        }
                        else
                        {
                            foreach (Attack a in c.Attacks)
                            {
                                if ((a.ID == "2106601422" && Properties.Settings.Default.SeparateZanverse) ||
                                    (Combatant.FinishAttackIDs.Contains(a.ID) && Properties.Settings.Default.SeparateFinish) ||
                                    (Combatant.StatusAttackIDs.Contains(a.ID) && Properties.Settings.Default.SeparateStatus))
                                {
                                    continue; // Don't do anything
                                }
                                if (MainWindow.skillDict.ContainsKey(a.ID))
                                {
                                    a.ID = MainWindow.skillDict[a.ID]; // these are getting disposed anyway, no 1 cur
                                }
                                if (!attackNames.Contains(a.ID))
                                {
                                    attackNames.Add(a.ID);
                                }
                            }

                            foreach (string s in attackNames)
                            {
                                // Choose damage from matching attacks
                                List <int> matchingAttacks = c.Attacks.Where(a => a.ID == s).Select(a => a.Damage).ToList();
                                List <int> jaPercents      = c.Attacks.Where(a => a.ID == s).Select(a => a.JA).ToList();
                                List <int> criPercents     = c.Attacks.Where(a => a.ID == s).Select(a => a.Cri).ToList();
                                attackData.Add(new Tuple <string, List <int>, List <int>, List <int> >(s, matchingAttacks, jaPercents, criPercents));
                            }
                        }

                        attackData = attackData.OrderByDescending(x => x.Item2.Sum()).ToList();

                        foreach (var i in attackData)
                        {
                            if (i.Item1 != "Taken")
                            {
                                double percent = i.Item2.Sum() * 100d / c.ReadDamage;

                                string spacer        = (percent >= 9) ? "" : " ";
                                string paddedPercent = percent.ToString("00.00");

                                string hits = i.Item2.Count().ToString("N0");
                                string sum  = i.Item2.Sum().ToString("N0");
                                string min  = i.Item2.Min().ToString("N0");
                                string max  = i.Item2.Max().ToString("N0");
                                string avg  = i.Item2.Average().ToString("N0");
                                string ja   = (i.Item3.Average() * 100).ToString("N2") ?? "null";
                                string cri  = (i.Item4.Average() * 100).ToString("N2") ?? "null";

                                log += $"{paddedPercent}% | {i.Item1} ({sum} dmg)" + Environment.NewLine;
                                log += $"       |   JA : {ja}% - Critical : {cri}%" + Environment.NewLine;
                                log += $"       |   {hits} hits - {min} min, {avg} avg, {max} max" + Environment.NewLine;
                            }
                            else
                            {
                                string hits = i.Item2.Count().ToString("N0");

                                log += "Number of hits taken: " + hits + Environment.NewLine;
                            }
                        }

                        log += Environment.NewLine;
                    }
                }

                log += "Instance IDs: " + String.Join(", ", instances.ToArray());

                DateTime thisDate  = DateTime.Now;
                string   directory = string.Format("{0:yyyy-MM-dd}", DateTime.Now);

                Directory.CreateDirectory($"Logs/{directory}");
                string datetime = string.Format("{0:yyyy-MM-dd_HH-mm-ss}", DateTime.Now);
                string filename = $"Logs/{directory}/OverParse - {datetime}.txt";

                File.WriteAllText(filename, log);

                return(filename);
            }

            return(null);
        }
コード例 #8
0
        // Updates the logging display
        public void UpdateLog(object sender, EventArgs e)
        {
            if (!valid || !notEmpty)
            {
                return;
            }

            string newLines = logReader.ReadToEnd();

            if (newLines != "")
            {
                string[] result = newLines.Split('\n');
                foreach (string str in result)
                {
                    if (str != "")
                    {
                        string[] parts = str.Split(',');

                        string sourceID   = parts[2];
                        string sourceName = parts[3];
                        string targetID   = parts[4];
                        string targetName = parts[5];
                        string attackID   = parts[6];

                        // string isMultiHit = parts[10];
                        // string isMisc = parts[11];
                        // string isMisc2 = parts[12];

                        int lineTimestamp = int.Parse(parts[0]);
                        int instanceID    = int.Parse(parts[1]);
                        int hitDamage     = int.Parse(parts[7]);
                        int justAttack    = int.Parse(parts[8]);
                        int critical      = int.Parse(parts[9]);

                        int index = -1;

                        if (lineTimestamp == 0 && parts[3] == "YOU")
                        {
                            Hacks.currentPlayerID = parts[2];
                            continue;
                        }

                        if (sourceID != Hacks.currentPlayerID && Properties.Settings.Default.Onlyme)
                        {
                            continue;
                        }

                        if (!instances.Contains(instanceID))
                        {
                            instances.Add(instanceID);
                        }

                        if (hitDamage < 1)
                        {
                            continue;
                        }

                        if (sourceID == "0" || attackID == "0")
                        {
                            continue;
                        }

                        // Process start

                        if (10000000 < int.Parse(sourceID))
                        {
                            foreach (Combatant x in combatants)
                            {
                                if (x.ID == sourceID && x.isTemporary == "no")
                                {
                                    index = combatants.IndexOf(x);
                                }
                            }

                            if (index == -1)
                            {
                                combatants.Add(new Combatant(sourceID, sourceName));
                                index = combatants.Count - 1;
                            }

                            Combatant source = combatants[index];

                            newTimestamp = lineTimestamp;
                            if (startTimestamp == 0)
                            {
                                startTimestamp = newTimestamp;
                            }

                            source.Attacks.Add(new Attack(attackID, hitDamage, justAttack, critical));
                            running = true;
                        }
                        else
                        {
                            foreach (Combatant x in combatants)
                            {
                                if (x.ID == targetID && x.isTemporary == "no")
                                {
                                    index = combatants.IndexOf(x);
                                }
                            }

                            if (index == -1)
                            {
                                combatants.Add(new Combatant(targetID, targetName));
                                index = combatants.Count - 1;
                            }

                            Combatant source = combatants[index];

                            newTimestamp = lineTimestamp;

                            if (startTimestamp == 0)
                            {
                                startTimestamp = newTimestamp;
                            }

                            source.Damaged += hitDamage;
                            running         = true;
                        }
                    }
                }

                combatants.Sort((x, y) => y.ReadDamage.CompareTo(x.ReadDamage));

                if (startTimestamp != 0)
                {
                    encounterData = "0:00:00 - ∞ DPS";
                }

                if (startTimestamp != 0 && newTimestamp != startTimestamp)
                {
                    foreach (Combatant x in combatants)
                    {
                        if (x.IsAlly || x.IsZanverse)
                        {
                            x.ActiveTime = (newTimestamp - startTimestamp);
                        }
                    }
                }
            }
        }
コード例 #9
0
        public string WriteLog()
        {
            Console.WriteLine("Logging encounter information to file");

            foreach (Combatant c in combatants) // Debug for ID mapping
            {
                if (c.isAlly)
                {
                    foreach (Attack a in c.Attacks)
                    {
                        if (!MainWindow.skillDict.ContainsKey(a.ID))
                        {
                            TimeSpan t = TimeSpan.FromSeconds(a.Timestamp);
                            Console.WriteLine($"{t.ToString(@"dd\.hh\:mm\:ss")} unmapped: {a.ID} ({a.Damage} dmg from {c.Name})");
                        }
                    }
                }
            }

            if (combatants.Count != 0)
            {
                int      elapsed  = newTimestamp - startTimestamp;
                TimeSpan timespan = TimeSpan.FromSeconds(elapsed);
                string   timer    = timespan.ToString(@"mm\:ss");
                string   log      = DateTime.Now.ToString("F") + " | " + timer + Environment.NewLine;

                log += Environment.NewLine;

                foreach (Combatant c in combatants)
                {
                    if (c.isAlly || c.isZanverse)
                    {
                        log += $"{c.Name} | {c.ReadDamage.ToString("N0")} dmg | {c.PercentReadDPSReadout} contrib | {c.DPS} DPS | Max: {c.MaxHit}" + Environment.NewLine;
                    }
                }

                log += Environment.NewLine + Environment.NewLine;

                foreach (Combatant c in combatants)
                {
                    if (c.isAlly || c.isZanverse)
                    {
                        string header = $"###### {c.Name} - {c.ReadDamage.ToString("N0")} dmg ({c.PercentReadDPSReadout}) ######";
                        log += header + Environment.NewLine + Environment.NewLine;

                        List <string> attackNames = new List <string>();
                        List <Tuple <string, List <int> > > attackData = new List <Tuple <string, List <int> > >();

                        if (c.isZanverse && Properties.Settings.Default.SeparateZanverse)
                        {
                            foreach (Combatant c2 in backupCombatants)
                            {
                                if (c2.ZanverseDamage > 0)
                                {
                                    attackNames.Add(c2.ID);
                                }
                            }

                            foreach (string s in attackNames)
                            {
                                Combatant  targetCombatant = backupCombatants.First(x => x.ID == s);
                                List <int> matchingAttacks = targetCombatant.Attacks.Where(a => a.ID == "2106601422").Select(a => a.Damage).ToList();
                                attackData.Add(new Tuple <string, List <int> >(targetCombatant.Name, matchingAttacks));
                            }
                        }
                        else
                        {
                            foreach (Attack a in c.Attacks)
                            {
                                if (a.ID == "2106601422" && Properties.Settings.Default.SeparateZanverse)
                                {
                                    continue;
                                }
                                if (MainWindow.skillDict.ContainsKey(a.ID))
                                {
                                    a.ID = MainWindow.skillDict[a.ID]; // these are getting disposed anyway, no 1 cur
                                }
                                if (!attackNames.Contains(a.ID))
                                {
                                    attackNames.Add(a.ID);
                                }
                            }

                            foreach (string s in attackNames)
                            {
                                List <int> matchingAttacks = c.Attacks.Where(a => a.ID == s).Select(a => a.Damage).ToList();
                                attackData.Add(new Tuple <string, List <int> >(s, matchingAttacks));
                            }
                        }

                        attackData = attackData.OrderByDescending(x => x.Item2.Sum()).ToList();

                        foreach (var i in attackData)
                        {
                            double percent = i.Item2.Sum() * 100d / c.ReadDamage;
                            string spacer  = (percent >= 9) ? "" : " ";

                            string paddedPercent = percent.ToString("00.00").Substring(0, 5);
                            string hits          = i.Item2.Count().ToString("N0");
                            string sum           = i.Item2.Sum().ToString("N0");
                            string min           = i.Item2.Min().ToString("N0");
                            string max           = i.Item2.Max().ToString("N0");
                            string avg           = i.Item2.Average().ToString("N0");

                            log += $"{paddedPercent}% | {i.Item1} ({sum} dmg)" + Environment.NewLine;
                            log += $"       |   {hits} hits - {min} min, {avg} avg, {max} max" + Environment.NewLine;
                        }

                        log += Environment.NewLine;
                    }
                }

                log += "Instance IDs: " + String.Join(", ", instances.ToArray());

                DateTime thisDate  = DateTime.Now;
                string   directory = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
                Directory.CreateDirectory($"Logs/{directory}");
                string datetime = string.Format("{0:yyyy-MM-dd_HH-mm-ss}", DateTime.Now);
                string filename = $"Logs/{directory}/OverParse - {datetime}.txt";
                File.WriteAllText(filename, log);

                return(filename);
            }

            return(null);
        }
コード例 #10
0
        public void UpdateLog(object sender, EventArgs e)
        {
            if (!valid || !notEmpty)
            {
                return;
            }

            string newLines = logReader.ReadToEnd();

            if (newLines != "")
            {
                string[] result = newLines.Split('\n');
                foreach (string str in result)
                {
                    if (str != "")
                    {
                        string[] parts         = str.Split(',');
                        string   lineTimestamp = parts[0];
                        string   instanceID    = parts[1];
                        string   sourceID      = parts[2];
                        string   targetID      = parts[4];
                        string   targetName    = parts[5];
                        string   sourceName    = parts[3];
                        int      hitDamage     = int.Parse(parts[7]);
                        string   attackID      = parts[6];
                        string   isMultiHit    = parts[10];
                        string   isMisc        = parts[11];
                        string   isMisc2       = parts[12];
                        int      index         = -1;

                        if (lineTimestamp == "0" && sourceName == "YOU")
                        {
                            Hacks.currentPlayerID = parts[2];
                            Console.WriteLine("Found new active player ID: " + parts[2]);
                            continue;
                        }

                        if (!instances.Contains(instanceID))
                        {
                            instances.Add(instanceID);
                        }

                        if (hitDamage < 1)
                        {
                            continue;
                        }
                        if (sourceID == "0" || attackID == "0")
                        {
                            continue;
                        }

                        foreach (Combatant x in combatants)
                        {
                            if (x.ID == sourceID && x.isTemporary == "no")
                            {
                                index = combatants.IndexOf(x);
                            }
                        }

                        if (index == -1)
                        {
                            combatants.Add(new Combatant(sourceID, sourceName));
                            index = combatants.Count - 1;
                        }

                        Combatant source = combatants[index];

                        newTimestamp = int.Parse(lineTimestamp);
                        if (startTimestamp == 0)
                        {
                            Console.WriteLine($"FIRST ATTACK RECORDED: {hitDamage} dmg from {sourceID} ({sourceName}) with {attackID}, to {targetID} ({targetName})");
                            startTimestamp = newTimestamp;
                        }

                        source.Attacks.Add(new Attack(attackID, hitDamage, newTimestamp - startTimestamp));
                        running = true;
                    }
                }

                combatants.Sort((x, y) => y.ReadDamage.CompareTo(x.ReadDamage));

                if (startTimestamp != 0)
                {
                    encounterData = "00:00 - ∞ DPS";
                }

                if (startTimestamp != 0 && newTimestamp != startTimestamp)
                {
                    foreach (Combatant x in combatants)
                    {
                        if (x.isAlly || x.isZanverse)
                        {
                            x.ActiveTime = (newTimestamp - startTimestamp);
                        }
                    }
                }
            }
        }
コード例 #11
0
        public string WriteLog()
        {
            /*
             * foreach (Combatant c in combatants) // Debug for ID mapping
             * {
             *  if (c.IsAlly)
             *  {
             *      foreach (Attack a in c.Attacks)
             *      {
             *          if (!MainWindow.skillDict.ContainsKey(a.ID))
             *          {
             *              TimeSpan t = TimeSpan.FromSeconds(a.Timestamp);
             *              //Console.WriteLine($"{t.ToString(@"dd\.hh\:mm\:ss")} unmapped: {a.ID} ({a.Damage} dmg from {c.Name})");
             *          }
             *      }
             *  }
             * } */

            if (combatants.Count != 0)
            {
                int      elapsed  = newTimestamp - startTimestamp;
                TimeSpan timespan = TimeSpan.FromSeconds(elapsed);
                string   timer    = timespan.ToString(@"mm\:ss");
                string   log      = DateTime.Now.ToString("F") + " | " + timer + " | " + Environment.NewLine + Environment.NewLine;

                foreach (Combatant c in combatants)
                {
                    try
                    {
                        if (c.IsAlly || c.IsZanverse || c.IsFinish)
                        {
                            log += $"{c.Name} | {c.PercentReadDPSReadout}% | {c.ReadDamage.ToString("N0")} dmg | {c.Damaged} dmgd | {c.DPS} DPS | JA : {c.WJAPercent}% | Critical : {c.WCRIPercent}% | Max:{c.MaxHitdmg} ({c.MaxHit})" + Environment.NewLine;
                        }
                    }
                    catch { /* 今の所何もしないっぽい */ }
                }

                log += Environment.NewLine + Environment.NewLine;

                foreach (Combatant c in combatants)
                {
                    if (c.IsAlly || c.IsZanverse || c.IsFinish)
                    {
                        string header = $"[ {c.Name} - {c.PercentReadDPSReadout}% - {c.ReadDamage.ToString("N0")} dmg ]";
                        log += header + Environment.NewLine + Environment.NewLine;

                        List <string> attackNames = new List <string>();
                        List <string> finishNames = new List <string>();
                        List <Tuple <string, List <int> > > attackData = new List <Tuple <string, List <int> > >();

                        if (c.IsZanverse && Properties.Settings.Default.SeparateZanverse)
                        {
                            foreach (Combatant c2 in backupCombatants)
                            {
                                if (c2.GetZanverseDamage > 0)
                                {
                                    attackNames.Add(c2.ID);
                                }
                            }

                            foreach (string s in attackNames)
                            {
                                Combatant  targetCombatant = backupCombatants.First(x => x.ID == s);
                                List <int> matchingAttacks = targetCombatant.Attacks.Where(a => a.ID == "2106601422").Select(a => a.Damage).ToList();
                                //List<int> jaPercents = c.Attacks.Where(a => a.ID == s).Select(a => a.JA).ToList();
                                //List<int> criPercents = c.Attacks.Where(a => a.ID == s).Select(a => a.Cri).ToList();
                                attackData.Add(new Tuple <string, List <int> >(targetCombatant.Name, matchingAttacks));
                            }
                        }

                        else if (c.IsFinish && Properties.Settings.Default.SeparateFinish)
                        {
                            foreach (Combatant c3 in backupCombatants)
                            {
                                if (c3.GetFinishDamage > 0)
                                {
                                    finishNames.Add(c3.ID);
                                }
                            }

                            foreach (string htf in finishNames)
                            {
                                Combatant  tCombatant       = backupCombatants.First(x => x.ID == htf);
                                List <int> fmatchingAttacks = tCombatant.Attacks.Where(a => Combatant.FinishAttackIDs.Contains(a.ID)).Select(a => a.Damage).ToList();
                                attackData.Add(new Tuple <string, List <int> >(tCombatant.Name, fmatchingAttacks));
                            }
                        }
                        else
                        {
                            foreach (Attack a in c.Attacks)
                            {
                                if ((a.ID == "2106601422" && Properties.Settings.Default.SeparateZanverse) || (Combatant.FinishAttackIDs.Contains(a.ID) && Properties.Settings.Default.SeparateFinish))
                                {
                                    continue; //ザンバースの場合に何もしない
                                }
                                if (MainWindow.skillDict.ContainsKey(a.ID))
                                {
                                    a.ID = MainWindow.skillDict[a.ID]; // these are getting disposed anyway, no 1 cur
                                }
                                if (!attackNames.Contains(a.ID))
                                {
                                    attackNames.Add(a.ID);
                                }
                            }

                            foreach (string s in attackNames)
                            {
                                //マッチングアタックからダメージを選択するだけ
                                List <int> matchingAttacks = c.Attacks.Where(a => a.ID == s).Select(a => a.Damage).ToList();
                                //List<int> jaPercents = c.Attacks.Where(a => a.ID == s).Select(a => a.JA).ToList();
                                //List<int> criPercents = c.Attacks.Where(a => a.ID == s).Select(a => a.Cri).ToList();
                                attackData.Add(new Tuple <string, List <int> >(s, matchingAttacks));
                            }
                        }

                        attackData = attackData.OrderByDescending(x => x.Item2.Sum()).ToList();

                        foreach (var i in attackData)
                        {
                            double percent = i.Item2.Sum() * 100d / c.ReadDamage;
                            string spacer  = (percent >= 9) ? "" : " ";

                            string paddedPercent = percent.ToString("00.00").Substring(0, 5);
                            string hits          = i.Item2.Count().ToString("N0");
                            string sum           = i.Item2.Sum().ToString("N0");
                            string min           = i.Item2.Min().ToString("N0");
                            string max           = i.Item2.Max().ToString("N0");
                            string avg           = i.Item2.Average().ToString("N0");
                            //string ja = (i.Item3.Average() * 100).ToString("N2") ?? "null";
                            //string cri = (i.Item4.Average() * 100).ToString("N2") ?? "null" ;
                            log += $"{paddedPercent}%	| {i.Item1} - {sum} dmg";
                            //log += $" - JA : {ja}% - Critical : {cri}%";
                            log += Environment.NewLine;
                            log += $"	|   {hits} hits - {min} min, {avg} avg, {max} max"+ Environment.NewLine;
                        }

                        log += Environment.NewLine;
                    }
                }


                log += "Instance IDs: " + String.Join(", ", instances.ToArray());

                DateTime thisDate  = DateTime.Now;
                string   directory = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
                Directory.CreateDirectory($"Logs/{directory}");
                string datetime = string.Format("{0:yyyy-MM-dd_HH-mm-ss}", DateTime.Now);
                string filename = $"Logs/{directory}/OverParse - {datetime}.txt";
                File.WriteAllText(filename, log);

                return(filename);
            }
            return(null);
        }
コード例 #12
0
        public void UpdateLog(object sender, EventArgs e)
        {
            if (!valid || !notEmpty)
            {
                return;
            }

            string newLines = logReader.ReadToEnd();

            if (newLines != "")
            {
                string[] result = newLines.Split('\n');
                foreach (string str in result)
                {
                    if (str != "")
                    {
                        string[] parts         = str.Split(',');
                        long     lineTimestamp = long.Parse(parts[0]);
                        long     instanceID    = long.Parse(parts[1]);
                        string   sourceID      = parts[2];
                        string   sourceName    = parts[3];
                        string   targetID      = parts[4];
                        string   targetName    = parts[5];
                        string   attackID      = parts[6];
                        long     hitDamage     = long.Parse(parts[7]);
                        long     justAttack    = long.Parse(parts[8]);
                        long     critical      = long.Parse(parts[9]);

                        int index = -1;

                        if (lineTimestamp == 0 && parts[3] == "YOU")
                        {
                            Hacks.currentPlayerID = parts[2];
                            continue;
                        }


                        if (sourceID != Hacks.currentPlayerID && Properties.Settings.Default.Onlyme)
                        {
                            continue;
                        }

                        if (!instances.Contains(instanceID))
                        {
                            instances.Add(instanceID);
                        }

                        if (hitDamage < 1)
                        {
                            continue;
                        }

                        if (sourceID == "0" || attackID == "0")
                        {
                            continue;
                        }

                        //Add different attacks if a new attack is found
                        if (10000000 < long.Parse(sourceID))
                        {
                            foreach (Combatant x in combatants)
                            {
                                if (x.ID == sourceID && x.isTemporary == "no")
                                {
                                    index = combatants.IndexOf(x);
                                }
                            }

                            if (index == -1)
                            {
                                combatants.Add(new Combatant(sourceID, sourceName));
                                index = combatants.Count - 1;
                            }

                            Combatant source = combatants[index];

                            newTimestamp = lineTimestamp;
                            if (startTimestamp == 0)
                            {
                                startTimestamp = newTimestamp;
                            }

                            source.Attacks.Add(new Attack(attackID, hitDamage, justAttack, critical));
                            running = true;
                        }
                        else //Add Damage Taken if combatant takes damage
                        {
                            foreach (Combatant x in combatants)
                            {
                                if (x.ID == targetID && x.isTemporary == "no")
                                {
                                    index = combatants.IndexOf(x);
                                }
                            }

                            if (index == -1)
                            {
                                combatants.Add(new Combatant(targetID, targetName));
                                index = combatants.Count - 1;
                            }

                            Combatant source = combatants[index];

                            newTimestamp = lineTimestamp;
                            if (startTimestamp == 0)
                            {
                                //Console.WriteLine($"FIRST ATTACK RECORDED: {hitDamage} dmg from {sourceID} ({sourceName}) with {attackID}, to {targetID} ({targetName})");
                                startTimestamp = newTimestamp;
                            }

                            source.Damaged += hitDamage;
                            running         = true;
                        }
                    }
                }

                combatants.Sort((x, y) => y.ReadDamage.CompareTo(x.ReadDamage));

                if (startTimestamp != 0)
                {
                    encounterData = "0:00:00 - ∞ DPS";
                }

                if (startTimestamp != 0 && newTimestamp != startTimestamp)
                {
                    foreach (Combatant x in combatants)
                    {
                        if (x.IsAlly || x.IsZanverse)
                        {
                            x.ActiveTime = (newTimestamp - startTimestamp);
                        }
                    }
                }
            }
        }
コード例 #13
0
        public void UpdateForm(object sender, EventArgs e)
        {
            if (encounterlog == null)
            {
                return;
            }
            if (Properties.Settings.Default.Clock)
            {
                Datetime.Content = DateTime.Now.ToString("HH:mm:ss.ff");
            }

            encounterlog.UpdateLog(this, null);

            // get a copy of the right combatants
            List <Combatant> targetList = (encounterlog.running ? encounterlog.combatants : lastCombatants);

            workingList.Clear();
            foreach (Combatant c in targetList)
            {
                Combatant temp = new Combatant(c.ID, c.Name, c.isTemporary);
                foreach (Attack a in c.Attacks)
                {
                    temp.Attacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                foreach (Attack a in c.AllyAttacks)
                {
                    temp.AllyAttacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                foreach (Attack a in c.DBAttacks)
                {
                    temp.DBAttacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                foreach (Attack a in c.LswAttacks)
                {
                    temp.LswAttacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                foreach (Attack a in c.PwpAttacks)
                {
                    temp.PwpAttacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                foreach (Attack a in c.AisAttacks)
                {
                    temp.AisAttacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                foreach (Attack a in c.RideAttacks)
                {
                    temp.RideAttacks.Add(new Attack(a.TimeID, a.ID, a.Damage, a.JA, a.Cri));
                }
                temp.Damaged        = c.Damaged;
                temp.AllyDamage     = c.AllyDamage;
                temp.DBDamage       = c.DBDamage;
                temp.LswDamage      = c.LswDamage;
                temp.PwpDamage      = c.PwpDamage;
                temp.AisDamage      = c.AisDamage;
                temp.RideDamage     = c.RideDamage;
                temp.PercentReadDPS = c.PercentReadDPS;
                temp.Heal           = c.Heal;
                temp.Recovery       = c.Recovery;
                workingList.Add(temp);
            }

            // clear out the list
            CombatantData.Items.Clear();
            AllyData.Items.Clear();
            HealData.Items.Clear();
            DBData.Items.Clear();
            LswData.Items.Clear();
            PwpData.Items.Clear();
            AisData.Items.Clear();
            RideData.Items.Clear();

            int elapsed = Log.ActiveTime;

            //Separate Part

            if (Properties.Settings.Default.SeparateDB)
            {
                List <Combatant> pendingDBCombatants = new List <Combatant>();
                foreach (Combatant c in workingList)
                {
                    if (!c.IsAlly)
                    {
                        continue;
                    }
                    if (0 < c.DBDamage)
                    {
                        Combatant     DBHolder      = new Combatant(c.ID, "DB|" + c.Name, "DB");
                        List <Attack> targetAttacks = c.Attacks.Where(a => Sepid.DBAtkID.Contains(a.ID)).ToList();
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        DBHolder.Attacks.AddRange(targetAttacks);
                        pendingDBCombatants.Add(DBHolder);
                    }
                }
                workingList.AddRange(pendingDBCombatants);
            }

            if (Properties.Settings.Default.SeparateLsw)
            {
                List <Combatant> pendingLswCombatants = new List <Combatant>();
                foreach (Combatant c in workingList)
                {
                    if (!c.IsAlly)
                    {
                        continue;
                    }
                    if (0 < c.LswDamage)
                    {
                        Combatant     LswHolder     = new Combatant(c.ID, "Lsw|" + c.Name, "Lsw");
                        List <Attack> targetAttacks = c.Attacks.Where(a => Sepid.LswAtkID.Contains(a.ID)).ToList();
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        LswHolder.Attacks.AddRange(targetAttacks);
                        pendingLswCombatants.Add(LswHolder);
                    }
                }
                workingList.AddRange(pendingLswCombatants);
            }

            if (Properties.Settings.Default.SeparatePwp)
            {
                List <Combatant> pendingPwpCombatants = new List <Combatant>();

                foreach (Combatant c in workingList)
                {
                    if (!c.IsAlly)
                    {
                        continue;
                    }
                    if (0 < c.PwpDamage)
                    {
                        Combatant     PhotonHolder  = new Combatant(c.ID, "Pwp|" + c.Name, "Pwp");
                        List <Attack> targetAttacks = c.Attacks.Where(a => Sepid.PwpAtkID.Contains(a.ID)).ToList();
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        PhotonHolder.Attacks.AddRange(targetAttacks);
                        pendingPwpCombatants.Add(PhotonHolder);
                    }
                }
                workingList.AddRange(pendingPwpCombatants);
            }

            if (Properties.Settings.Default.SeparateAIS)
            {
                List <Combatant> pendingCombatants = new List <Combatant>();
                foreach (Combatant c in workingList)
                {
                    if (!c.IsAlly)
                    {
                        continue;
                    }
                    if (0 < c.AisDamage)
                    {
                        Combatant     AISHolder     = new Combatant(c.ID, "AIS|" + c.Name, "AIS");
                        List <Attack> targetAttacks = c.Attacks.Where(a => Sepid.AISAtkID.Contains(a.ID)).ToList();
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        AISHolder.Attacks.AddRange(targetAttacks);
                        pendingCombatants.Add(AISHolder);
                    }
                }
                workingList.AddRange(pendingCombatants);
            }

            if (Properties.Settings.Default.SeparateRide)
            {
                List <Combatant> pendingRideCombatants = new List <Combatant>();
                foreach (Combatant c in workingList)
                {
                    if (!c.IsAlly)
                    {
                        continue;
                    }
                    if (0 < c.RideDamage)
                    {
                        Combatant     RideHolder    = new Combatant(c.ID, "Ride|" + c.Name, "Ride");
                        List <Attack> targetAttacks = c.Attacks.Where(a => Sepid.RideAtkID.Contains(a.ID)).ToList();
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                        RideHolder.Attacks.AddRange(targetAttacks);
                        pendingRideCombatants.Add(RideHolder);
                    }
                }
                workingList.AddRange(pendingRideCombatants);
            }


            //分けたものを含めて再ソート
            if (SeparateTab.SelectedIndex == 0)
            {
                workingList.Sort((x, y) => y.ReadDamage.CompareTo(x.ReadDamage));
            }

            Int64 totalZanverse = workingList.Sum(x => x.ZvsDamage);
            Int64 totalFinish   = workingList.Sum(x => x.HTFDamage);

            if (Properties.Settings.Default.SeparateFinish && 0 < totalFinish)
            {
                Combatant finishHolder = new Combatant("99999998", "HTF Attacks", "HTF Attacks");
                foreach (Combatant c in workingList)
                {
                    if (c.IsAlly)
                    {
                        List <Attack> targetAttacks = c.Attacks.Where(a => Sepid.HTFAtkID.Contains(a.ID)).ToList();
                        finishHolder.Attacks.AddRange(targetAttacks);
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                    }
                }
                workingList.Add(finishHolder);
            }

            if (Properties.Settings.Default.SeparateZanverse && 0 < totalZanverse)
            {
                Combatant zanverseHolder = new Combatant("99999999", "Zanverse", "Zanverse");
                foreach (Combatant c in workingList)
                {
                    if (c.IsAlly)
                    {
                        List <Attack> targetAttacks = c.Attacks.Where(a => a.ID == "2106601422").ToList();
                        zanverseHolder.Attacks.AddRange(targetAttacks);
                        c.Attacks = c.Attacks.Except(targetAttacks).ToList();
                    }
                }
                workingList.Add(zanverseHolder);
            }

            // get group damage totals
            Int64 totalDamage     = workingList.Sum(x => x.Damage);
            Int64 totalReadDamage = workingList.Sum(x => x.ReadDamage);
            Int64 totalAllyDamage = workingList.Sum(x => x.AllyDamage);
            Int64 totalDBDamage   = workingList.Sum(x => x.DBDamage);
            Int64 totalLswDamage  = workingList.Sum(x => x.LswDamage);
            Int64 totalPwpDamage  = workingList.Sum(x => x.PwpDamage);
            Int64 totalAisDamage  = workingList.Sum(x => x.AisDamage);
            Int64 totalRideDamage = workingList.Sum(x => x.RideDamage);

            // dps calcs!
            foreach (Combatant c in workingList)
            {
                c.PercentReadDPS = c.ReadDamage / (float)totalReadDamage * 100;
                c.AllyPct        = c.AllyDamage / (float)totalAllyDamage * 100;
                c.DBPct          = c.DBDamage / (float)totalDBDamage * 100;
                c.LswPct         = c.LswDamage / (float)totalLswDamage * 100;
                c.PwpPct         = c.PwpDamage / (float)totalPwpDamage * 100;
                c.AisPct         = c.AisDamage / (float)totalAisDamage * 100;
                c.RidePct        = c.RideDamage / (float)totalRideDamage * 100;
            }

            // status pane updates
            StatusUpdate(totalDamage, totalZanverse);

            // damage graph stuff
            Combatant.maxShare = 0;

            foreach (Combatant c in workingList)
            {
                if ((c.IsAlly) && c.ReadDamage > Combatant.maxShare)
                {
                    Combatant.maxShare = c.ReadDamage;
                }

                bool filtered = true;
                if (Properties.Settings.Default.SeparateAIS || Properties.Settings.Default.SeparateDB || Properties.Settings.Default.SeparateRide || Properties.Settings.Default.SeparatePwp || Properties.Settings.Default.SeparateLsw)
                {
                    if (c.IsAlly && c.isTemporary == "raw" && !HidePlayers.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.IsAlly && c.isTemporary == "AIS" && !HideAIS.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.IsAlly && c.isTemporary == "DB" && !HideDB.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.IsAlly && c.isTemporary == "Ride" && !HideRide.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.IsAlly && c.isTemporary == "Pwp" && !HidePwp.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.IsAlly && c.isTemporary == "Lsw" && !HideLsw.IsChecked)
                    {
                        filtered = false;
                    }
                    if (c.IsZanverse)
                    {
                        filtered = false;
                    }
                    if (c.IsFinish)
                    {
                        filtered = false;
                    }
                }
                else
                {
                    if (c.IsAlly || c.IsZanverse || c.IsFinish)
                    {
                        filtered = false;
                    }
                }

                if (!filtered && (0 < c.Damage) && (SeparateTab.SelectedIndex == 0))
                {
                    CombatantData.Items.Add(c);
                }
                if ((0 < c.AllyDamage) && (SeparateTab.SelectedIndex == 1))
                {
                    workingList.Sort((x, y) => y.AllyDamage.CompareTo(x.AllyDamage)); AllyData.Items.Add(c);
                }
                if ((0 < c.Damage) && (SeparateTab.SelectedIndex == 2))
                {
                    workingList.Sort((x, y) => y.ReadDamage.CompareTo(x.ReadDamage)); HealData.Items.Add(c);
                }
                if ((0 < c.DBDamage) && (SeparateTab.SelectedIndex == 3))
                {
                    workingList.Sort((x, y) => y.DBDamage.CompareTo(x.DBDamage)); DBData.Items.Add(c);
                }
                if ((0 < c.LswDamage) && (SeparateTab.SelectedIndex == 4))
                {
                    workingList.Sort((x, y) => y.LswDamage.CompareTo(x.LswDamage)); LswData.Items.Add(c);
                }
                if ((0 < c.PwpDamage) && (SeparateTab.SelectedIndex == 5))
                {
                    workingList.Sort((x, y) => y.PwpDamage.CompareTo(x.PwpDamage)); PwpData.Items.Add(c);
                }
                if ((0 < c.AisDamage) && (SeparateTab.SelectedIndex == 6))
                {
                    workingList.Sort((x, y) => y.AisDamage.CompareTo(x.AisDamage)); AisData.Items.Add(c);
                }
                if ((0 < c.RideDamage) && (SeparateTab.SelectedIndex == 7))
                {
                    workingList.Sort((x, y) => y.RideDamage.CompareTo(x.RideDamage)); RideData.Items.Add(c);
                }
            }

            // autoend
            if (Properties.Settings.Default.AutoEndEncounters && encounterlog.running)
            {
                int unixTimestamp = (int)DateTimeOffset.UtcNow.ToUnixTimeSeconds();
                if ((unixTimestamp - Log.newTimestamp) >= Properties.Settings.Default.EncounterTimeout)
                {
                    EndEncounter_Click(null, null);
                }
            }
        }
コード例 #14
0
ファイル: Log.cs プロジェクト: KagefumiMerry/OverParse
        public void UpdateLog(object sender, EventArgs e)
        {
            if (!valid || !notEmpty)
            {
                return;
            }
            string newLines = logReader.ReadToEnd();

            if (newLines != "")
            {
                string[] result = newLines.Split('\n');
                foreach (string str in result)
                {
                    if (str != "")
                    {
                        string[] parts         = str.Split(',');
                        int      lineTimestamp = int.Parse(parts[0]);
                        int      instanceID    = int.Parse(parts[1]);
                        string   sourceID      = parts[2];
                        string   sourceName    = parts[3];
                        string   targetID      = parts[4];
                        string   targetName    = parts[5];
                        string   attackID      = parts[6]; //WriteLog部分にてID<->Nameの相互変換がある為int化が無理
                        Int64    hitDamage     = Int64.Parse(parts[7]);
                        int      JA            = int.Parse(parts[8]);
                        int      Cri           = int.Parse(parts[9]);
                        //string isMultiHit = parts[10];
                        //string isMisc = parts[11];
                        //string isMisc2 = parts[12];
                        int index = -1;

                        if (lineTimestamp == 0 && parts[3] == "YOU")
                        {
                            Combatant.currentPlayerID = parts[2];
                            continue;
                        }

                        if (sourceID != Combatant.currentPlayerID && Properties.Settings.Default.Onlyme)
                        {
                            continue;
                        }
                        if (!instances.Contains(instanceID))
                        {
                            instances.Add(instanceID);
                        }
                        if (sourceID == "0" || attackID == "0")
                        {
                            continue;
                        }

                        //処理スタート

                        if (10000000 < int.Parse(sourceID))
                        {
                            if (0 < hitDamage)
                            {
                                newTimestamp = lineTimestamp;
                                if (startTimestamp == 0)
                                {
                                    startTimestamp = newTimestamp;
                                    nowTimestamp   = newTimestamp;
                                }

                                if (newTimestamp - nowTimestamp >= 1)
                                {
                                    diffTime     = diffTime + 1;
                                    nowTimestamp = newTimestamp;
                                }

                                if (Properties.Settings.Default.QuestTime)
                                {
                                    ActiveTime = diffTime;
                                }
                                else
                                {
                                    ActiveTime = newTimestamp - startTimestamp;
                                }
                            }

                            foreach (Combatant x in combatants)
                            {
                                if (x.ID == sourceID && x.isTemporary == "raw")
                                {
                                    index = combatants.IndexOf(x);
                                }
                            }

                            if (index == -1)
                            {
                                combatants.Add(new Combatant(sourceID, sourceName, "raw"));
                                index = combatants.Count - 1;
                            }

                            Combatant source = combatants[index];
                            if (0 < hitDamage)
                            {
                                if (Sepid.DBAtkID.Contains(attackID))
                                {
                                    source.DBDamage += hitDamage; source.DBAttacks.Add(new Attack(lineTimestamp, attackID, hitDamage, JA, Cri));
                                }
                                else if (Sepid.LswAtkID.Contains(attackID))
                                {
                                    source.LswDamage += hitDamage; source.LswAttacks.Add(new Attack(lineTimestamp, attackID, hitDamage, JA, Cri));
                                }
                                else if (Sepid.PwpAtkID.Contains(attackID))
                                {
                                    source.PwpDamage += hitDamage; source.PwpAttacks.Add(new Attack(lineTimestamp, attackID, hitDamage, JA, Cri));
                                }
                                else if (Sepid.AISAtkID.Contains(attackID))
                                {
                                    source.AisDamage += hitDamage; source.AisAttacks.Add(new Attack(lineTimestamp, attackID, hitDamage, JA, Cri));
                                }
                                else if (Sepid.RideAtkID.Contains(attackID))
                                {
                                    source.RideDamage += hitDamage; source.RideAttacks.Add(new Attack(lineTimestamp, attackID, hitDamage, JA, Cri));
                                }
                                else
                                {
                                    source.AllyDamage += hitDamage; source.AllyAttacks.Add(new Attack(lineTimestamp, attackID, hitDamage, JA, Cri));
                                }
                                source.Attacks.Add(new Attack(lineTimestamp, attackID, hitDamage, JA, Cri));
                            }
                            else
                            {
                                if (hitDamage < 0)
                                {
                                    source.Recovery += Math.Abs(hitDamage);
                                }
                            }
                            running = true;
                        }

                        if (10000000 < int.Parse(targetID))
                        {
                            foreach (Combatant x in combatants)
                            {
                                if (x.ID == targetID && x.isTemporary == "raw")
                                {
                                    index = combatants.IndexOf(x);
                                }
                            }
                            if (index == -1)
                            {
                                combatants.Add(new Combatant(targetID, targetName, "raw"));
                                index = combatants.Count - 1;
                            }
                            Combatant source = combatants[index];
                            if (0 < hitDamage)
                            {
                                source.Damaged += hitDamage;
                            }
                            if (hitDamage < 0)
                            {
                                source.Heal += Math.Abs(hitDamage);
                            }
                            running = true;
                        }
                    }
                }
            }

            combatants.Sort((x, y) => y.ReadDamage.CompareTo(x.ReadDamage));

            if (startTimestamp != 0)
            {
                encounterData = "0:00:00 - ∞ DPS";
            }
        }
コード例 #15
0
        public void UpdateForm(object sender, EventArgs e)
        {
            encounterlog.UpdateLog(this, null);

            EncounterStatus.Content = encounterlog.logStatus();

            // every part of this section is f*****g stupid

            EncounterIndicator.Fill = new SolidColorBrush(Color.FromArgb(255, 255, 100, 100));
            EncounterStatus.Content = encounterlog.logStatus();

            if (encounterlog.valid && encounterlog.notEmpty)
            {
                EncounterIndicator.Fill = new SolidColorBrush(Color.FromArgb(255, 255, 255, 0));
                EncounterStatus.Content = $"Waiting - {lastStatus}";
                if (lastStatus == "")
                {
                    EncounterStatus.Content = "Waiting for combat data...";
                }
            }

            if (encounterlog.running)
            {
                EncounterIndicator.Fill = new SolidColorBrush(Color.FromArgb(255, 100, 255, 100));
                EncounterStatus.Content = encounterlog.logStatus();
                lastStatus = encounterlog.logStatus();
            }

            if (encounterlog.running)
            {
                SeparateZanverse.IsEnabled  = false;
                SeparateAuxDamage.IsEnabled = false;

                CombatantData.Items.Clear();

                int       index   = -1; // there's probably a way better way of doing this, maybe someday i'll learn LINQ
                Combatant reorder = null;
                foreach (Combatant c in encounterlog.combatants)
                {
                    if (c.Name == "Zanverse")
                    {
                        index   = encounterlog.combatants.IndexOf(c);
                        reorder = c;
                    }
                }
                if (index != -1)
                {
                    encounterlog.combatants.RemoveAt(index);
                    encounterlog.combatants.Add(reorder);
                }


                Combatant.maxShare = 0;

                foreach (Combatant c in encounterlog.combatants)
                {
                    if (c.isAlly || !FilterPlayers.IsChecked)
                    {
                        CombatantData.Items.Add(c);
                        if (c.PercentDPS > Combatant.maxShare)
                        {
                            Combatant.maxShare = c.PercentDPS;
                        }
                    }
                }

                if (Properties.Settings.Default.AutoEndEncounters)
                {
                    int unixTimestamp = (int)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
                    if ((unixTimestamp - encounterlog.newTimestamp) >= Properties.Settings.Default.EncounterTimeout)
                    {
                        Console.WriteLine("Automatically ending an encounter");
                        EndEncounter_Click(null, null);
                    }
                }
            }
        }