internal override List <PhaseData> GetPhases(ParsedEvtcLog log, bool requirePhases)
        {
            List <PhaseData>    phases     = GetInitialPhase(log);
            AbstractSingleActor mainTarget = Targets.FirstOrDefault(x => x.ID == (int)ArcDPSEnums.TargetID.Adina);

            if (mainTarget == null)
            {
                throw new MissingKeyActorsException("Adina not found");
            }
            phases[0].AddTarget(mainTarget);
            if (!requirePhases)
            {
                return(phases);
            }
            // Split phases
            List <AbstractBuffEvent> invuls = GetFilteredList(log.CombatData, 762, mainTarget, true, true);
            long start          = 0;
            var  splitPhases    = new List <PhaseData>();
            var  splitPhaseEnds = new List <long>();

            for (int i = 0; i < invuls.Count; i++)
            {
                PhaseData         splitPhase;
                AbstractBuffEvent be = invuls[i];
                if (be is BuffApplyEvent)
                {
                    start = be.Time;
                    if (i == invuls.Count - 1)
                    {
                        splitPhase = new PhaseData(start, log.FightData.FightEnd, "Split " + (i / 2 + 1));
                        splitPhaseEnds.Add(log.FightData.FightEnd);
                        AddTargetsToPhaseAndFit(splitPhase, new List <int> {
                            (int)ArcDPSEnums.TrashID.HandOfErosion, (int)ArcDPSEnums.TrashID.HandOfEruption
                        }, log);
                        splitPhases.Add(splitPhase);
                    }
                }
                else
                {
                    long end = be.Time;
                    splitPhase = new PhaseData(start, end, "Split " + (i / 2 + 1));
                    splitPhaseEnds.Add(end);
                    AddTargetsToPhaseAndFit(splitPhase, new List <int> {
                        (int)ArcDPSEnums.TrashID.HandOfErosion, (int)ArcDPSEnums.TrashID.HandOfEruption
                    }, log);
                    splitPhases.Add(splitPhase);
                }
            }
            // Main phases
            var mainPhases    = new List <PhaseData>();
            var pillarApplies = log.CombatData.GetBuffData(56204).OfType <BuffApplyEvent>().Where(x => x.To == mainTarget.AgentItem).ToList();
            Dictionary <long, List <BuffApplyEvent> > pillarAppliesGroupByTime = ParserHelper.GroupByTime(pillarApplies);
            var mainPhaseEnds = new List <long>();

            foreach (KeyValuePair <long, List <BuffApplyEvent> > pair in pillarAppliesGroupByTime)
            {
                if (pair.Value.Count == 6)
                {
                    mainPhaseEnds.Add(pair.Key);
                }
            }
            AbstractCastEvent boulderBarrage = mainTarget.GetCastEvents(log, 0, log.FightData.FightEnd).FirstOrDefault(x => x.SkillId == 56648 && x.Time < 6000);

            start = boulderBarrage == null ? 0 : boulderBarrage.EndTime;
            if (mainPhaseEnds.Any())
            {
                int phaseIndex = 1;
                foreach (long quantumQake in mainPhaseEnds)
                {
                    long curPhaseStart = splitPhaseEnds.LastOrDefault(x => x < quantumQake);
                    if (curPhaseStart == 0)
                    {
                        curPhaseStart = start;
                    }
                    long nextPhaseStart = splitPhaseEnds.FirstOrDefault(x => x > quantumQake);
                    if (nextPhaseStart != 0)
                    {
                        start      = nextPhaseStart;
                        phaseIndex = splitPhaseEnds.IndexOf(start) + 1;
                    }
                    mainPhases.Add(new PhaseData(curPhaseStart, quantumQake, "Phase " + phaseIndex));
                }
                if (start != mainPhases.Last().Start)
                {
                    mainPhases.Add(new PhaseData(start, log.FightData.FightEnd, "Phase " + (phaseIndex + 1)));
                }
            }
            else if (start > 0 && !invuls.Any())
            {
                // no split
                mainPhases.Add(new PhaseData(start, log.FightData.FightEnd, "Phase 1"));
            }

            foreach (PhaseData phase in mainPhases)
            {
                phase.AddTarget(mainTarget);
            }
            phases.AddRange(mainPhases);
            phases.AddRange(splitPhases);
            phases.Sort((x, y) => x.Start.CompareTo(y.Start));
            //
            try
            {
                var splitPhasesMap = new List <string>()
                {
                    "https://i.imgur.com/gJ55jKy.png",
                    "https://i.imgur.com/c2Oz5bj.png",
                    "https://i.imgur.com/P4SGbrc.png",
                };
                var mainPhasesMap = new List <string>()
                {
                    "https://i.imgur.com/IQn2RJV.png",
                    "https://i.imgur.com/3pO7eCB.png",
                    "https://i.imgur.com/ZFw590w.png",
                    "https://i.imgur.com/2P7UE8q.png"
                };
                var crMaps          = new List <string>();
                int mainPhaseIndex  = 0;
                int splitPhaseIndex = 0;
                for (int i = 1; i < phases.Count; i++)
                {
                    PhaseData phaseData = phases[i];
                    if (mainPhases.Contains(phaseData))
                    {
                        if (mainPhasesMap.Contains(crMaps.LastOrDefault()))
                        {
                            splitPhaseIndex++;
                        }
                        crMaps.Add(mainPhasesMap[mainPhaseIndex++]);
                    }
                    else
                    {
                        if (splitPhasesMap.Contains(crMaps.LastOrDefault()))
                        {
                            mainPhaseIndex++;
                        }
                        crMaps.Add(splitPhasesMap[splitPhaseIndex++]);
                    }
                }
                GetCombatReplayMap(log).MatchMapsToPhases(crMaps, phases, log.FightData.FightEnd);
            }
            catch (Exception)
            {
                log.UpdateProgressWithCancellationCheck("Failed to associate Adina Combat Replay maps");
            }

            //
            return(phases);
        }
        public static JsonLog BuildJsonLog(ParsedEvtcLog log, RawFormatSettings settings, Version parserVersion, string[] uploadLinks)
        {
            var jsonLog = new JsonLog();

            //
            log.UpdateProgressWithCancellationCheck("Raw Format: Building Meta Data");
            jsonLog.TriggerID            = log.FightData.TriggerID;
            jsonLog.FightName            = log.FightData.FightName;
            jsonLog.FightIcon            = log.FightData.Logic.Icon;
            jsonLog.EliteInsightsVersion = parserVersion.ToString();
            jsonLog.ArcVersion           = log.LogData.ArcVersion;
            jsonLog.RecordedBy           = log.LogData.PoVName;
            jsonLog.TimeStart            = log.LogData.LogStart;
            jsonLog.TimeEnd      = log.LogData.LogEnd;
            jsonLog.TimeStartStd = log.LogData.LogStartStd;
            jsonLog.TimeEndStd   = log.LogData.LogEndStd;
            jsonLog.Duration     = log.FightData.DurationString;
            jsonLog.Success      = log.FightData.Success;
            jsonLog.GW2Build     = log.LogData.GW2Build;
            jsonLog.UploadLinks  = uploadLinks;
            jsonLog.Language     = log.LogData.Language;
            jsonLog.LanguageID   = (byte)log.LogData.LanguageID;
            jsonLog.IsCM         = log.FightData.IsCM;
            var personalBuffs = new Dictionary <string, HashSet <long> >();
            var skillMap      = new Dictionary <string, SkillDesc>();
            var buffMap       = new Dictionary <string, BuffDesc>();
            var damageModMap  = new Dictionary <string, DamageModDesc>();

            if (log.StatisticsHelper.PresentFractalInstabilities.Any())
            {
                var presentFractalInstabilities = new List <long>();
                foreach (Buff fractalInstab in log.StatisticsHelper.PresentFractalInstabilities)
                {
                    presentFractalInstabilities.Add(fractalInstab.ID);
                    if (!buffMap.ContainsKey("b" + fractalInstab.ID))
                    {
                        buffMap["b" + fractalInstab.ID] = BuildBuffDesc(fractalInstab, log);
                    }
                }
                jsonLog.PresentFractalInstabilities = presentFractalInstabilities;
            }
            //
            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())
            {
                jsonLog.Mechanics = JsonMechanicsBuilder.GetJsonMechanicsList(mechanicLogs);
            }
            //
            log.UpdateProgressWithCancellationCheck("Raw Format: Building Phases");
            jsonLog.Phases = log.FightData.GetNonDummyPhases(log).Select(x => JsonPhaseBuilder.BuildJsonPhase(x, log)).ToList();
            //
            log.UpdateProgressWithCancellationCheck("Raw Format: Building Targets");
            jsonLog.Targets = log.FightData.Logic.Targets.Select(x => JsonNPCBuilder.BuildJsonNPC(x, log, settings, skillMap, buffMap)).ToList();
            //
            log.UpdateProgressWithCancellationCheck("Raw Format: Building Players");
            jsonLog.Players = log.Friendlies.Select(x => JsonPlayerBuilder.BuildJsonPlayer(x, log, settings, skillMap, buffMap, damageModMap, personalBuffs)).ToList();
            //
            if (log.LogData.LogErrors.Any())
            {
                jsonLog.LogErrors = new List <string>(log.LogData.LogErrors);
            }
            if (log.LogData.UsedExtensions.Any())
            {
                var usedExtensions = new List <ExtensionDesc>();
                foreach (AbstractExtensionHandler extension in log.LogData.UsedExtensions)
                {
                    var set = new HashSet <string>();
                    if (log.LogData.PoV != null)
                    {
                        set.Add(log.FindActor(log.LogData.PoV).Character);
                        foreach (AgentItem agent in extension.RunningExtension)
                        {
                            set.Add(log.FindActor(agent).Character);
                        }
                    }
                    usedExtensions.Add(new ExtensionDesc()
                    {
                        Name             = extension.Name,
                        Version          = extension.Version,
                        Signature        = extension.Signature,
                        Revision         = extension.Revision,
                        RunningExtension = set.ToList()
                    });
                }
                jsonLog.UsedExtensions = usedExtensions;
            }
            //
            jsonLog.PersonalBuffs = personalBuffs.ToDictionary(x => x.Key, x => (IReadOnlyCollection <long>)x.Value);
            jsonLog.SkillMap      = skillMap;
            jsonLog.BuffMap       = buffMap;
            jsonLog.DamageModMap  = damageModMap;
            //
            if (log.CanCombatReplay)
            {
                jsonLog.CombatReplayMetaData = JsonCombatReplayMetaDataBuilder.BuildJsonCombatReplayMetaData(log, settings);
            }
            return(jsonLog);
        }
        //Creating CSV---------------------------------------------------------------------------------
        public void CreateCSV(StreamWriter sw)
        {
            _sw = sw;
            //header
            _log.UpdateProgressWithCancellationCheck("CSV: Building Meta Data");
            WriteLine(new[] { "Elite Insights", _parserVersion.ToString() });
            WriteLine(new[] { "ARC Version", _log.LogData.ArcVersion });
            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] });
            }
            else
            {
                NewLine();
            }
            NewLine();
            NewLine();
            NewLine();
            //Boss card
            WriteLine(new[] { "Boss", _log.FightData.GetFightName(_log) });
            WriteLine(new[] { "Success", _log.FightData.Success.ToString() });
            WriteLine(new[] { "Total Boss Health", _legacyTarget.GetHealth(_log.CombatData).ToString() });
            IReadOnlyList <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);
        }
示例#4
0
        public static LogDataDto BuildLogData(ParsedEvtcLog log, bool cr, bool light, Version parserVersion, string[] uploadLinks)
        {
            var usedBuffs      = new Dictionary <long, Buff>();
            var usedDamageMods = new HashSet <DamageModifier>();
            var usedSkills     = new Dictionary <long, SkillItem>();

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

            if (cr)
            {
                log.UpdateProgressWithCancellationCheck("HTML: building Combat Replay");
                logData.CrData = new CombatReplayDto(log);
            }
            log.UpdateProgressWithCancellationCheck("HTML: building Graph Data");
            logData.GraphData = new ChartDataDto(log);
            log.UpdateProgressWithCancellationCheck("HTML: building Players");
            foreach (AbstractSingleActor actor in log.Friendlies)
            {
                logData.HasCommander = logData.HasCommander || actor.HasCommanderTag;
                logData.Players.Add(new PlayerDto(actor, log, ActorDetailsDto.BuildPlayerData(log, actor, usedSkills, usedBuffs)));
            }

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

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

            BuildDictionaries(log, usedBuffs, usedDamageMods, logData, allDamageMods, commonDamageModifiers, itemDamageModifiers);
            //
            log.UpdateProgressWithCancellationCheck("HTML: building Phases");
            IReadOnlyList <PhaseData> phases = log.FightData.GetPhases(log);

            for (int i = 0; i < phases.Count; i++)
            {
                PhaseData phase    = phases[i];
                var       phaseDto = new PhaseDto(phase, phases, log, persBuffDict, commonDamageModifiers, itemDamageModifiers, persDamageModDict);
                logData.Phases.Add(phaseDto);
            }
            //
            if (log.CombatData.HasEXTHealing)
            {
                log.UpdateProgressWithCancellationCheck("HTML: building Healing Extension");
                logData.HealingStatsExtension = new HealingStatsExtension(log, usedSkills, usedBuffs);
            }
            //
            SkillDto.AssembleSkills(usedSkills.Values, logData.SkillMap, log);
            DamageModDto.AssembleDamageModifiers(usedDamageMods, logData.DamageModMap);
            BuffDto.AssembleBoons(usedBuffs.Values, logData.BuffMap, log);
            MechanicDto.BuildMechanics(log.MechanicData.GetPresentMechanics(log, 0, log.FightData.FightEnd), logData.MechanicMap);
            return(logData);
        }
        public static LogDataDto BuildLogData(ParsedEvtcLog log, Dictionary <long, SkillItem> usedSkills, Dictionary <long, Buff> usedBuffs, HashSet <DamageModifier> usedDamageMods, bool cr, bool light, Version parserVersion, string[] uploadLinks)
        {
            StatisticsHelper statistics = log.StatisticsHelper;

            log.UpdateProgressWithCancellationCheck("HTML: building Log Data");
            var logData = new LogDataDto
            {
                EncounterStart = log.LogData.LogStartStd,
                EncounterEnd   = log.LogData.LogEndStd,
                ArcVersion     = log.LogData.ArcVersion,
                Gw2Build       = log.LogData.GW2Build,
                FightID        = log.FightData.TriggerID,
                Parser         = "Elite Insights " + parserVersion.ToString(),
                RecordedBy     = log.LogData.PoVName,
                UploadLinks    = uploadLinks.ToList()
            };

            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, ActorDetailsDto.BuildPlayerData(log, player, usedSkills, usedBuffs)));
            }

            log.UpdateProgressWithCancellationCheck("HTML: building Enemies");
            foreach (AbstractSingleActor enemy in log.MechanicData.GetEnemyList(log, log.FightData.FightStart, log.FightData.FightEnd))
            {
                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, 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(ParserHelper.Source.Common, out IReadOnlyList <DamageModifier> list))
            {
                foreach (DamageModifier dMod in list)
                {
                    if (allDamageMods.Contains(dMod.Name))
                    {
                        commonDamageModifiers.Add(dMod);
                        logData.DmgModifiersCommon.Add(dMod.ID);
                        usedDamageMods.Add(dMod);
                    }
                }
            }
            if (log.DamageModifiers.DamageModifiersPerSource.TryGetValue(ParserHelper.Source.FightSpecific, out list))
            {
                foreach (DamageModifier dMod in list)
                {
                    if (allDamageMods.Contains(dMod.Name))
                    {
                        commonDamageModifiers.Add(dMod);
                        logData.DmgModifiersCommon.Add(dMod.ID);
                        usedDamageMods.Add(dMod);
                    }
                }
            }
            var itemDamageModifiers = new List <DamageModifier>();

            if (log.DamageModifiers.DamageModifiersPerSource.TryGetValue(ParserHelper.Source.Item, out list))
            {
                foreach (DamageModifier dMod in list)
                {
                    if (allDamageMods.Contains(dMod.Name))
                    {
                        itemDamageModifiers.Add(dMod);
                        logData.DmgModifiersItem.Add(dMod.ID);
                        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.PresentSupbuffs)
            {
                logData.SupBuffs.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");
            IReadOnlyList <PhaseData> phases = log.FightData.GetPhases(log);

            for (int i = 0; i < phases.Count; i++)
            {
                PhaseData phase    = phases[i];
                var       phaseDto = new PhaseDto(phase, phases, log)
                {
                    DpsStats        = PhaseDto.BuildDPSData(log, phase),
                    DpsStatsTargets = PhaseDto.BuildDPSTargetsData(log, phase),
                    DmgStatsTargets = PhaseDto.BuildDMGStatsTargetsData(log, phase),
                    DmgStats        = PhaseDto.BuildDMGStatsData(log, phase),
                    DefStats        = PhaseDto.BuildDefenseData(log, phase),
                    SupportStats    = PhaseDto.BuildSupportData(log, phase),
                    //
                    BoonStats             = BuffData.BuildBuffUptimeData(log, statistics.PresentBoons, phase),
                    OffBuffStats          = BuffData.BuildBuffUptimeData(log, statistics.PresentOffbuffs, phase),
                    SupBuffStats          = BuffData.BuildBuffUptimeData(log, statistics.PresentSupbuffs, phase),
                    DefBuffStats          = BuffData.BuildBuffUptimeData(log, statistics.PresentDefbuffs, phase),
                    PersBuffStats         = BuffData.BuildPersonalBuffUptimeData(log, persBuffDict, phase),
                    BoonGenSelfStats      = BuffData.BuildBuffGenerationData(log, statistics.PresentBoons, phase, BuffEnum.Self),
                    BoonGenGroupStats     = BuffData.BuildBuffGenerationData(log, statistics.PresentBoons, phase, BuffEnum.Group),
                    BoonGenOGroupStats    = BuffData.BuildBuffGenerationData(log, statistics.PresentBoons, phase, BuffEnum.OffGroup),
                    BoonGenSquadStats     = BuffData.BuildBuffGenerationData(log, statistics.PresentBoons, phase, BuffEnum.Squad),
                    OffBuffGenSelfStats   = BuffData.BuildBuffGenerationData(log, statistics.PresentOffbuffs, phase, BuffEnum.Self),
                    OffBuffGenGroupStats  = BuffData.BuildBuffGenerationData(log, statistics.PresentOffbuffs, phase, BuffEnum.Group),
                    OffBuffGenOGroupStats = BuffData.BuildBuffGenerationData(log, statistics.PresentOffbuffs, phase, BuffEnum.OffGroup),
                    OffBuffGenSquadStats  = BuffData.BuildBuffGenerationData(log, statistics.PresentOffbuffs, phase, BuffEnum.Squad),
                    SupBuffGenSelfStats   = BuffData.BuildBuffGenerationData(log, statistics.PresentSupbuffs, phase, BuffEnum.Self),
                    SupBuffGenGroupStats  = BuffData.BuildBuffGenerationData(log, statistics.PresentSupbuffs, phase, BuffEnum.Group),
                    SupBuffGenOGroupStats = BuffData.BuildBuffGenerationData(log, statistics.PresentSupbuffs, phase, BuffEnum.OffGroup),
                    SupBuffGenSquadStats  = BuffData.BuildBuffGenerationData(log, statistics.PresentSupbuffs, phase, BuffEnum.Squad),
                    DefBuffGenSelfStats   = BuffData.BuildBuffGenerationData(log, statistics.PresentDefbuffs, phase, BuffEnum.Self),
                    DefBuffGenGroupStats  = BuffData.BuildBuffGenerationData(log, statistics.PresentDefbuffs, phase, BuffEnum.Group),
                    DefBuffGenOGroupStats = BuffData.BuildBuffGenerationData(log, statistics.PresentDefbuffs, phase, BuffEnum.OffGroup),
                    DefBuffGenSquadStats  = BuffData.BuildBuffGenerationData(log, statistics.PresentDefbuffs, phase, BuffEnum.Squad),
                    //
                    BoonActiveStats             = BuffData.BuildActiveBuffUptimeData(log, statistics.PresentBoons, phase),
                    OffBuffActiveStats          = BuffData.BuildActiveBuffUptimeData(log, statistics.PresentOffbuffs, phase),
                    SupBuffActiveStats          = BuffData.BuildActiveBuffUptimeData(log, statistics.PresentSupbuffs, phase),
                    DefBuffActiveStats          = BuffData.BuildActiveBuffUptimeData(log, statistics.PresentDefbuffs, phase),
                    PersBuffActiveStats         = BuffData.BuildActivePersonalBuffUptimeData(log, persBuffDict, phase),
                    BoonGenActiveSelfStats      = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentBoons, phase, BuffEnum.Self),
                    BoonGenActiveGroupStats     = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentBoons, phase, BuffEnum.Group),
                    BoonGenActiveOGroupStats    = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentBoons, phase, BuffEnum.OffGroup),
                    BoonGenActiveSquadStats     = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentBoons, phase, BuffEnum.Squad),
                    OffBuffGenActiveSelfStats   = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentOffbuffs, phase, BuffEnum.Self),
                    OffBuffGenActiveGroupStats  = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentOffbuffs, phase, BuffEnum.Group),
                    OffBuffGenActiveOGroupStats = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentOffbuffs, phase, BuffEnum.OffGroup),
                    OffBuffGenActiveSquadStats  = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentOffbuffs, phase, BuffEnum.Squad),
                    SupBuffGenActiveSelfStats   = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentSupbuffs, phase, BuffEnum.Self),
                    SupBuffGenActiveGroupStats  = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentSupbuffs, phase, BuffEnum.Group),
                    SupBuffGenActiveOGroupStats = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentSupbuffs, phase, BuffEnum.OffGroup),
                    SupBuffGenActiveSquadStats  = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentSupbuffs, phase, BuffEnum.Squad),
                    DefBuffGenActiveSelfStats   = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentDefbuffs, phase, BuffEnum.Self),
                    DefBuffGenActiveGroupStats  = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentDefbuffs, phase, BuffEnum.Group),
                    DefBuffGenActiveOGroupStats = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentDefbuffs, phase, BuffEnum.OffGroup),
                    DefBuffGenActiveSquadStats  = BuffData.BuildActiveBuffGenerationData(log, statistics.PresentDefbuffs, phase, 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, phase),
                    EnemyMechanicStats = MechanicDto.BuildEnemyMechanicData(log, phase)
                };
                foreach (NPC target in phase.Targets)
                {
                    phaseDto.TargetsCondiStats.Add(BuffData.BuildTargetCondiData(log, phase.Start, phase.End, target));
                    phaseDto.TargetsCondiTotals.Add(BuffData.BuildTargetCondiUptimeData(log, phase, target));
                    phaseDto.TargetsBoonTotals.Add(HasBoons(log, phase, target) ? BuffData.BuildTargetBoonData(log, phase, 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.HasBreakbarDamage = log.CombatData.HasBreakbarDamageData;
            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, log.SkillData);
            DamageModDto.AssembleDamageModifiers(usedDamageMods, logData.DamageModMap);
            BuffDto.AssembleBoons(usedBuffs.Values, logData.BuffMap, log);
            MechanicDto.BuildMechanics(log.MechanicData.GetPresentMechanics(log, log.FightData.FightStart, log.FightData.FightEnd), logData.MechanicMap);
            return(logData);
        }
示例#6
0
        private (string, string) BuildAssetPaths(string path)
        {
            string cdn      = null;
            string external = null;

            if (_externalScripts && !string.IsNullOrWhiteSpace(path))
            {
                if (!string.IsNullOrWhiteSpace(_externalScriptsCdn))
                {
                    cdn = (_externalScriptsCdn.EndsWith("/") && _externalScriptsCdn.Length > 1 ? _externalScriptsCdn.Substring(0, _externalScriptsCdn.Length - 1) : _externalScriptsCdn);
                }
                external = path;
                // Setting: External Scripts Path
                // overwrite jsPath (create directory) if files should be placed on different location
                // settings.externalHtmlScriptsPath is set by the user
                if (!string.IsNullOrWhiteSpace(_externalScriptsPath))
                {
                    bool validPath = false;

                    if (!Directory.Exists(_externalScriptsPath))
                    {
                        try
                        {
                            Directory.CreateDirectory(_externalScriptsPath);
                            validPath = true;
                        }
                        catch
                        {
                            // something went wrong on creating the external folder (invalid chars?)
                            // this will skip the saving in this path and continue with jsscript files in the root path for the report
                            _log.UpdateProgressWithCancellationCheck("HTML Warning: can't create external script folder");
                        }
                    }
                    else
                    {
                        try
                        {
                            // Verify write access
                            // https://stackoverflow.com/a/6371533
                            using (FileStream fs = File.Create(
                                       Path.Combine(
                                           _externalScriptsPath,
                                           "EI-" + Path.GetRandomFileName()
                                           ),
                                       1,
                                       FileOptions.DeleteOnClose)
                                   )
                            { }
                            validPath = true;
                        }
                        catch
                        {
                            _log.UpdateProgressWithCancellationCheck("HTML Warning: can't write in external script folder");
                            // couldn't write to directory
                        }
                    }

                    // if the creation of the folder did not fail or the folder already exists use it to include within the report
                    if (validPath)
                    {
                        external = _externalScriptsPath;
                    }
                }
            }
            return(external, cdn);
        }
示例#7
0
        internal JsonLog(ParsedEvtcLog log, RawFormatSettings settings, string[] uploadLinks)
        {
            //
            log.UpdateProgressWithCancellationCheck("Raw Format: Building Meta Data");
            TriggerID            = log.FightData.TriggerID;
            FightName            = log.FightData.GetFightName(log);
            FightIcon            = log.FightData.Logic.Icon;
            EliteInsightsVersion = log.ParserVersion.ToString();
            ArcVersion           = log.LogData.ArcVersion;
            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.GW2Build;
            UploadLinks  = uploadLinks;
            Language     = log.LogData.Language;
            LanguageID   = (byte)log.LogData.LanguageID;
            IsCM         = log.FightData.IsCM;
            if (log.Statistics.PresentFractalInstabilities.Any())
            {
                PresentFractalInstabilities = new List <long>();
                foreach (Buff fractalInstab in log.Statistics.PresentFractalInstabilities)
                {
                    PresentFractalInstabilities.Add(fractalInstab.ID);
                    if (!BuffMap.ContainsKey("b" + fractalInstab.ID))
                    {
                        BuffMap["b" + fractalInstab.ID] = new BuffDesc(fractalInstab, log);
                    }
                }
            }
            //
            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, settings, SkillMap, BuffMap)).ToList();
            //
            log.UpdateProgressWithCancellationCheck("Raw Format: Building Players");
            Players = log.PlayerList.Select(x => new JsonPlayer(x, log, settings, SkillMap, BuffMap, DamageModMap, PersonalBuffs)).ToList();
            //
            if (log.LogData.LogErrors.Count > 0)
            {
                LogErrors = new List <string>(log.LogData.LogErrors);
            }
        }