예제 #1
0
 public static void SendMessage(ParsedLog log, string[] uploadresult)
 {
     if (Properties.Settings.Default.WebhookURL != null && Properties.Settings.Default.WebhookURL.Length > 0)
     {
         if (!uploadresult[0].Contains("https"))
         {
             log.UpdateProgressWithCancellationCheck("Nothing to send to Webhook");
             return;
         }
         try
         {
             var client = new DiscordWebhookClient(Properties.Settings.Default.WebhookURL);
             try
             {
                 if (Properties.Settings.Default.SendSimpleMessageToWebhook)
                 {
                     _ = client.SendMessageAsync(text: uploadresult[0]).Result;
                 }
                 else
                 {
                     _ = client.SendMessageAsync(embeds: new[] { GetEmbed(log, uploadresult) }).Result;
                 }
                 log.UpdateProgressWithCancellationCheck("Sent Embed");
             }
             finally
             {
                 client.Dispose();
             }
         }
         catch (Exception e)
         {
             log.UpdateProgressWithCancellationCheck("Couldn't send embed: " + e.GetFinalException().Message);
         }
     }
 }
예제 #2
0
        public JsonLog(ParsedLog log, string[] uploadLinks)
        {
            //
            log.UpdateProgressWithCancellationCheck("Raw Format: Building Meta Data");
            TriggerID            = log.FightData.TriggerID;
            FightName            = log.FightData.Name;
            FightIcon            = log.FightData.Logic.Icon;
            EliteInsightsVersion = Application.ProductVersion;
            ArcVersion           = log.LogData.BuildVersion;
            RecordedBy           = log.LogData.PoVName;
            TimeStart            = log.LogData.LogStart;
            TimeEnd      = log.LogData.LogEnd;
            TimeStartStd = log.LogData.LogStartStd;
            TimeEndStd   = log.LogData.LogEndStd;
            Duration     = log.FightData.DurationString;
            Success      = log.FightData.Success;
            GW2Build     = log.LogData.GW2Version;
            UploadLinks  = uploadLinks;
            Language     = log.LogData.Language;
            LanguageID   = (byte)log.LogData.LanguageID;
            IsCM         = log.FightData.IsCM;
            //
            log.UpdateProgressWithCancellationCheck("Raw Format: Building Mechanics");
            MechanicData mechanicData = log.MechanicData;
            var          mechanicLogs = new List <MechanicEvent>();

            foreach (List <MechanicEvent> mLog in mechanicData.GetAllMechanics(log))
            {
                mechanicLogs.AddRange(mLog);
            }
            if (mechanicLogs.Any())
            {
                Mechanics = GetJsonMechanicsList(mechanicLogs);
            }
            //
            log.UpdateProgressWithCancellationCheck("Raw Format: Building Phases");
            Phases = log.FightData.GetPhases(log).Select(x => new JsonPhase(x, log)).ToList();
            //
            log.UpdateProgressWithCancellationCheck("Raw Format: Building Targets");
            Targets = log.FightData.Logic.Targets.Select(x => new JsonNPC(x, log, SkillMap, BuffMap)).ToList();
            //
            log.UpdateProgressWithCancellationCheck("Raw Format: Building Players");
            Players = log.PlayerList.Select(x => new JsonPlayer(x, log, SkillMap, BuffMap, DamageModMap, PersonalBuffs)).ToList();
        }
예제 #3
0
        public void CreateHTML(StreamWriter sw, string path)
        {
            string html = Properties.Resources.template_html;

            _log.UpdateProgressWithCancellationCheck("HTML: replacing global variables");
            html = ReplaceVariables(html);

            _log.UpdateProgressWithCancellationCheck("HTML: building CSS");
            html = html.Replace("<!--${Css}-->", BuildCss(path));
            _log.UpdateProgressWithCancellationCheck("HTML: building JS");
            html = html.Replace("<!--${Js}-->", BuildEIJs(path));
            _log.UpdateProgressWithCancellationCheck("HTML: building Combat Replay link");
            html = html.Replace("<!--${JsCRLink}-->", BuildCRLinkJs(path));

            html = html.Replace("'${logDataJson}'", ToJson(LogDataDto.BuildLogData(_log, _usedSkills, _usedBuffs, _usedDamageMods, _cr, _light)));
#if DEBUG
            html = html.Replace("<!--${Vue}-->", "<script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.js\"></script>");
#else
            html = html.Replace("<!--${Vue}-->", "<script src=\"https://cdn.jsdelivr.net/npm/[email protected]/dist/vue.min.js\"></script>");
#endif

            _log.UpdateProgressWithCancellationCheck("HTML: building Graph Data");
            html = html.Replace("'${graphDataJson}'", ToJson(ChartDataDto.BuildChartData(_log)));

            _log.UpdateProgressWithCancellationCheck("HTML: building Combat Replay JS");
            html = html.Replace("<!--${CombatReplayScript}-->", BuildCombatReplayScript(path));
            sw.Write(html);
            return;
        }
        //Creating CSV---------------------------------------------------------------------------------
        public void CreateCSV()
        {
            //header
            _log.UpdateProgressWithCancellationCheck("CSV: Building Meta Data");
            WriteLine(new[] { "Elite Insights Version", Application.ProductVersion });
            WriteLine(new[] { "ARC Version", _log.LogData.BuildVersion });
            WriteLine(new[] { "Fight ID", _log.FightData.TriggerID.ToString() });
            WriteLine(new[] { "Recorded By", _log.LogData.PoVName });
            WriteLine(new[] { "Time Start", _log.LogData.LogStartStd });
            WriteLine(new[] { "Time End", _log.LogData.LogEndStd });
            if (_uploadResult.Any(x => x != null && x.Length > 0))
            {
                WriteLine(new[] { "Links", _uploadResult[0], _uploadResult[1], _uploadResult[2] });
            }
            else
            {
                NewLine();
            }
            NewLine();
            NewLine();
            NewLine();
            //Boss card
            WriteLine(new[] { "Boss", _log.FightData.Name });
            WriteLine(new[] { "Success", _log.FightData.Success.ToString() });
            WriteLine(new[] { "Total Boss Health", _legacyTarget.GetHealth(_log.CombatData).ToString() });
            List <HealthUpdateEvent> hpUpdates = _log.CombatData.GetHealthUpdateEvents(_legacyTarget.AgentItem);
            double hpLeft = hpUpdates.Count > 0
                ? hpUpdates.Last().HPPercent
                : 100.0;

            WriteLine(new[] { "Final Boss Health", (_legacyTarget.GetHealth(_log.CombatData) * hpLeft).ToString() });
            WriteLine(new[] { "Boss Health Burned %", (100.0 - hpLeft).ToString() });
            WriteLine(new[] { "Duration", _log.FightData.DurationString });

            //DPSStats
            _log.UpdateProgressWithCancellationCheck("CSV: Building DPS Data");
            CreateDPSTable(0);

            //DMGStatsBoss
            _log.UpdateProgressWithCancellationCheck("CSV: Building Boss Damage Data");
            CreateBossDMGStatsTable(0);

            //DMGStats All
            _log.UpdateProgressWithCancellationCheck("CSV: Building Damage Data");
            CreateDmgStatsTable(0);

            //Defensive Stats
            _log.UpdateProgressWithCancellationCheck("CSV: Building Defense Data");
            CreateDefTable(0);

            //Support Stats
            _log.UpdateProgressWithCancellationCheck("CSV: Building Support Data");
            CreateSupTable(0);

            // boons
            _log.UpdateProgressWithCancellationCheck("CSV: Building Boon Data");
            CreateUptimeTable(_statistics.PresentBoons, 0);

            //boonGenSelf
            CreateGenSelfTable(_statistics.PresentBoons, 0);

            // boonGenGroup
            CreateGenGroupTable(_statistics.PresentBoons, 0);

            // boonGenOGroup
            CreateGenOGroupTable(_statistics.PresentBoons, 0);

            //  boonGenSquad
            CreateGenSquadTable(_statistics.PresentBoons, 0);

            //Offensive Buffs stats
            _log.UpdateProgressWithCancellationCheck("CSV: Building Offensive Buff Data");
            // boons
            CreateUptimeTable(_statistics.PresentOffbuffs, 0);

            //boonGenSelf
            CreateGenSelfTable(_statistics.PresentOffbuffs, 0);

            // boonGenGroup
            CreateGenGroupTable(_statistics.PresentOffbuffs, 0);

            // boonGenOGroup
            CreateGenOGroupTable(_statistics.PresentOffbuffs, 0);

            //  boonGenSquad
            CreateGenSquadTable(_statistics.PresentOffbuffs, 0);

            //Defensive Buffs stats
            _log.UpdateProgressWithCancellationCheck("CSV: Building Defensive Buff Data");
            // boons
            CreateUptimeTable(_statistics.PresentDefbuffs, 0);

            //boonGenSelf
            CreateGenSelfTable(_statistics.PresentDefbuffs, 0);

            // boonGenGroup
            CreateGenGroupTable(_statistics.PresentDefbuffs, 0);

            // boonGenOGroup
            CreateGenOGroupTable(_statistics.PresentDefbuffs, 0);

            //  boonGenSquad
            CreateGenSquadTable(_statistics.PresentDefbuffs, 0);

            //Mechanics
            _log.UpdateProgressWithCancellationCheck("CSV: Building Mechanics Data");
            CreateMechanicTable(0);

            //Mech List
            CreateMechList();

            //Condi Uptime
            _log.UpdateProgressWithCancellationCheck("CSV: Building Boss Condition Data");
            CreateBossCondiUptime(0);
            //Condi Gen
            CreateCondiGen(0);
            //Boss boons
            _log.UpdateProgressWithCancellationCheck("CSV: Building Boss Boon Data");
            CreateBossBoonUptime(0);
        }
        public static LogDataDto BuildLogData(ParsedLog log, Dictionary <long, SkillItem> usedSkills, Dictionary <long, Buff> usedBuffs, HashSet <DamageModifier> usedDamageMods, bool cr, bool light)
        {
            GeneralStatistics statistics = log.Statistics;

            log.UpdateProgressWithCancellationCheck("HTML: building Log Data");
            var logData = new LogDataDto();

            if (cr)
            {
                logData.CrData = new CombatReplayDto(log);
            }
            log.UpdateProgressWithCancellationCheck("HTML: building Players");
            foreach (Player player in log.PlayerList)
            {
                logData.HasCommander = logData.HasCommander || player.HasCommanderTag;
                logData.Players.Add(new PlayerDto(player, log, cr, ActorDetailsDto.BuildPlayerData(log, player, usedSkills, usedBuffs)));
            }

            log.UpdateProgressWithCancellationCheck("HTML: building Enemies");
            foreach (AbstractActor enemy in log.MechanicData.GetEnemyList(log, 0))
            {
                logData.Enemies.Add(new EnemyDto()
                {
                    Name = enemy.Character
                });
            }

            log.UpdateProgressWithCancellationCheck("HTML: building Targets");
            foreach (NPC target in log.FightData.Logic.Targets)
            {
                var targetDto = new TargetDto(target, log, cr, ActorDetailsDto.BuildTargetData(log, target, usedSkills, usedBuffs, cr));
                logData.Targets.Add(targetDto);
            }
            //
            log.UpdateProgressWithCancellationCheck("HTML: building Skill/Buff dictionaries");
            Dictionary <string, List <Buff> >           persBuffDict      = BuildPersonalBoonData(log, logData.PersBuffs, usedBuffs);
            Dictionary <string, List <DamageModifier> > persDamageModDict = BuildPersonalDamageModData(log, logData.DmgModifiersPers, usedDamageMods);
            var allDamageMods = new HashSet <string>();

            foreach (Player p in log.PlayerList)
            {
                allDamageMods.UnionWith(p.GetPresentDamageModifier(log));
            }
            var commonDamageModifiers = new List <DamageModifier>();

            if (log.DamageModifiers.DamageModifiersPerSource.TryGetValue(GeneralHelper.Source.Common, out List <DamageModifier> list))
            {
                foreach (DamageModifier dMod in list)
                {
                    if (allDamageMods.Contains(dMod.Name))
                    {
                        commonDamageModifiers.Add(dMod);
                        logData.DmgModifiersCommon.Add(dMod.Name.GetHashCode());
                        usedDamageMods.Add(dMod);
                    }
                }
            }
            if (log.DamageModifiers.DamageModifiersPerSource.TryGetValue(GeneralHelper.Source.FightSpecific, out list))
            {
                foreach (DamageModifier dMod in list)
                {
                    if (allDamageMods.Contains(dMod.Name))
                    {
                        commonDamageModifiers.Add(dMod);
                        logData.DmgModifiersCommon.Add(dMod.Name.GetHashCode());
                        usedDamageMods.Add(dMod);
                    }
                }
            }
            var itemDamageModifiers = new List <DamageModifier>();

            if (log.DamageModifiers.DamageModifiersPerSource.TryGetValue(GeneralHelper.Source.Item, out list))
            {
                foreach (DamageModifier dMod in list)
                {
                    if (allDamageMods.Contains(dMod.Name))
                    {
                        itemDamageModifiers.Add(dMod);
                        logData.DmgModifiersItem.Add(dMod.Name.GetHashCode());
                        usedDamageMods.Add(dMod);
                    }
                }
            }
            foreach (Buff boon in statistics.PresentBoons)
            {
                logData.Boons.Add(boon.ID);
                usedBuffs[boon.ID] = boon;
            }
            foreach (Buff boon in statistics.PresentConditions)
            {
                logData.Conditions.Add(boon.ID);
                usedBuffs[boon.ID] = boon;
            }
            foreach (Buff boon in statistics.PresentOffbuffs)
            {
                logData.OffBuffs.Add(boon.ID);
                usedBuffs[boon.ID] = boon;
            }
            foreach (Buff boon in statistics.PresentDefbuffs)
            {
                logData.DefBuffs.Add(boon.ID);
                usedBuffs[boon.ID] = boon;
            }
            foreach (Buff boon in statistics.PresentFractalInstabilities)
            {
                logData.FractalInstabilities.Add(boon.ID);
                usedBuffs[boon.ID] = boon;
            }
            //
            log.UpdateProgressWithCancellationCheck("HTML: building Phases");
            List <PhaseData> phases = log.FightData.GetPhases(log);

            for (int i = 0; i < phases.Count; i++)
            {
                PhaseData phaseData = phases[i];
                var       phaseDto  = new PhaseDto(phaseData, phases, log)
                {
                    DpsStats        = PhaseDto.BuildDPSData(log, i),
                    DpsStatsTargets = PhaseDto.BuildDPSTargetsData(log, i),
                    DmgStatsTargets = PhaseDto.BuildDMGStatsTargetsData(log, i),
                    DmgStats        = PhaseDto.BuildDMGStatsData(log, i),
                    DefStats        = PhaseDto.BuildDefenseData(log, i),
                    SupportStats    = PhaseDto.BuildSupportData(log, i),
                    //
                    BoonStats             = BuffData.BuildBuffUptimeData(log, statistics.PresentBoons, i),
                    OffBuffStats          = BuffData.BuildBuffUptimeData(log, statistics.PresentOffbuffs, i),
                    DefBuffStats          = BuffData.BuildBuffUptimeData(log, statistics.PresentDefbuffs, i),
                    PersBuffStats         = BuffData.BuildPersonalBuffUptimeData(log, persBuffDict, i),
                    BoonGenSelfStats      = BuffData.BuildBuffGenerationData(log, statistics.PresentBoons, i, BuffEnum.Self),
                    BoonGenGroupStats     = BuffData.BuildBuffGenerationData(log, statistics.PresentBoons, i, BuffEnum.Group),
                    BoonGenOGroupStats    = BuffData.BuildBuffGenerationData(log, statistics.PresentBoons, i, BuffEnum.OffGroup),
                    BoonGenSquadStats     = BuffData.BuildBuffGenerationData(log, statistics.PresentBoons, i, BuffEnum.Squad),
                    OffBuffGenSelfStats   = BuffData.BuildBuffGenerationData(log, statistics.PresentOffbuffs, i, BuffEnum.Self),
                    OffBuffGenGroupStats  = BuffData.BuildBuffGenerationData(log, statistics.PresentOffbuffs, i, BuffEnum.Group),
                    OffBuffGenOGroupStats = BuffData.BuildBuffGenerationData(log, statistics.PresentOffbuffs, i, BuffEnum.OffGroup),
                    OffBuffGenSquadStats  = BuffData.BuildBuffGenerationData(log, statistics.PresentOffbuffs, i, BuffEnum.Squad),
                    DefBuffGenSelfStats   = BuffData.BuildBuffGenerationData(log, statistics.PresentDefbuffs, i, BuffEnum.Self),
                    DefBuffGenGroupStats  = BuffData.BuildBuffGenerationData(log, statistics.PresentDefbuffs, i, BuffEnum.Group),
                    DefBuffGenOGroupStats = BuffData.BuildBuffGenerationData(log, statistics.PresentDefbuffs, i, BuffEnum.OffGroup),
                    DefBuffGenSquadStats  = BuffData.BuildBuffGenerationData(log, statistics.PresentDefbuffs, i, BuffEnum.Squad),
                    //
                    BoonActiveStats             = BuffData.BuildActiveBuffUptimeData(log, statistics.PresentBoons, i),
                    OffBuffActiveStats          = BuffData.BuildActiveBuffUptimeData(log, statistics.PresentOffbuffs, i),
                    DefBuffActiveStats          = BuffData.BuildActiveBuffUptimeData(log, statistics.PresentDefbuffs, i),
                    PersBuffActiveStats         = BuffData.BuildActivePersonalBuffUptimeData(log, persBuffDict, i),
                    BoonGenActiveSelfStats      = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentBoons, i, BuffEnum.Self),
                    BoonGenActiveGroupStats     = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentBoons, i, BuffEnum.Group),
                    BoonGenActiveOGroupStats    = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentBoons, i, BuffEnum.OffGroup),
                    BoonGenActiveSquadStats     = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentBoons, i, BuffEnum.Squad),
                    OffBuffGenActiveSelfStats   = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentOffbuffs, i, BuffEnum.Self),
                    OffBuffGenActiveGroupStats  = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentOffbuffs, i, BuffEnum.Group),
                    OffBuffGenActiveOGroupStats = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentOffbuffs, i, BuffEnum.OffGroup),
                    OffBuffGenActiveSquadStats  = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentOffbuffs, i, BuffEnum.Squad),
                    DefBuffGenActiveSelfStats   = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentDefbuffs, i, BuffEnum.Self),
                    DefBuffGenActiveGroupStats  = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentDefbuffs, i, BuffEnum.Group),
                    DefBuffGenActiveOGroupStats = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentDefbuffs, i, BuffEnum.OffGroup),
                    DefBuffGenActiveSquadStats  = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentDefbuffs, i, BuffEnum.Squad),
                    //
                    DmgModifiersCommon = DamageModData.BuildDmgModifiersData(log, i, commonDamageModifiers),
                    DmgModifiersItem   = DamageModData.BuildDmgModifiersData(log, i, itemDamageModifiers),
                    DmgModifiersPers   = DamageModData.BuildPersonalDmgModifiersData(log, i, persDamageModDict),
                    TargetsCondiStats  = new List <List <BuffData> >(),
                    TargetsCondiTotals = new List <BuffData>(),
                    TargetsBoonTotals  = new List <BuffData>(),
                    MechanicStats      = MechanicDto.BuildPlayerMechanicData(log, i),
                    EnemyMechanicStats = MechanicDto.BuildEnemyMechanicData(log, i)
                };
                foreach (NPC target in phaseData.Targets)
                {
                    phaseDto.TargetsCondiStats.Add(BuffData.BuildTargetCondiData(log, i, target));
                    phaseDto.TargetsCondiTotals.Add(BuffData.BuildTargetCondiUptimeData(log, i, target));
                    phaseDto.TargetsBoonTotals.Add(HasBoons(log, i, target) ? BuffData.BuildTargetBoonData(log, i, target) : null);
                }
                logData.Phases.Add(phaseDto);
            }
            //
            log.UpdateProgressWithCancellationCheck("HTML: building Meta Data");
            logData.EncounterDuration = log.FightData.DurationString;
            logData.Success           = log.FightData.Success;
            logData.Wvw         = log.FightData.Logic.Mode == FightLogic.ParseMode.WvW;
            logData.Targetless  = log.FightData.Logic.Targetless;
            logData.FightName   = log.FightData.GetFightName(log);
            logData.FightIcon   = log.FightData.Logic.Icon;
            logData.LightTheme  = light;
            logData.SingleGroup = log.PlayerList.Where(x => !x.IsFakeActor).Select(x => x.Group).Distinct().Count() == 1;
            logData.NoMechanics = log.FightData.Logic.HasNoFightSpecificMechanics;
            if (log.LogData.LogErrors.Count > 0)
            {
                logData.LogErrors = new List <string>(log.LogData.LogErrors);
            }
            //
            SkillDto.AssembleSkills(usedSkills.Values, logData.SkillMap);
            DamageModDto.AssembleDamageModifiers(usedDamageMods, logData.DamageModMap);
            BuffDto.AssembleBoons(usedBuffs.Values, logData.BuffMap, log);
            MechanicDto.BuildMechanics(log.MechanicData.GetPresentMechanics(log, 0), logData.MechanicMap);
            return(logData);
        }