public static List <List <object> > BuildSupportData(ParsedLog log, int phaseIndex)
        {
            var list = new List <List <object> >();

            foreach (Player player in log.PlayerList)
            {
                FinalPlayerSupport support = player.GetPlayerSupport(log, phaseIndex);
                list.Add(PhaseDto.GetSupportStatData(support));
            }
            return(list);
        }
        public static List <List <object> > BuildDMGStatsData(ParsedLog log, int phaseIndex)
        {
            var list = new List <List <object> >();

            foreach (Player player in log.PlayerList)
            {
                FinalGameplayStatsAll stats = player.GetGameplayStats(log, phaseIndex);
                list.Add(PhaseDto.GetDMGStatData(stats));
            }
            return(list);
        }
        public static List <List <object> > BuildDPSData(ParsedLog log, int phaseIndex)
        {
            var list = new List <List <object> >(log.PlayerList.Count);

            foreach (Player player in log.PlayerList)
            {
                FinalDPS dpsAll = player.GetDPSAll(log, phaseIndex);
                list.Add(PhaseDto.GetDPSStatData(dpsAll));
            }
            return(list);
        }
        public static List <List <object> > BuildDefenseData(ParsedLog log, int phaseIndex)
        {
            var list = new List <List <object> >();

            PhaseData phase = log.FightData.GetPhases(log)[phaseIndex];

            foreach (Player player in log.PlayerList)
            {
                FinalDefensesAll defenses = player.GetDefenses(log, phaseIndex);
                list.Add(PhaseDto.GetDefenseStatData(defenses, phase));
            }

            return(list);
        }
        public static List <List <List <object> > > BuildDPSTargetsData(ParsedLog log, int phaseIndex)
        {
            var       list  = new List <List <List <object> > >(log.PlayerList.Count);
            PhaseData phase = log.FightData.GetPhases(log)[phaseIndex];

            foreach (Player player in log.PlayerList)
            {
                var playerData = new List <List <object> >();

                foreach (NPC target in phase.Targets)
                {
                    playerData.Add(PhaseDto.GetDPSStatData(player.GetDPSTarget(log, phaseIndex, target)));
                }
                list.Add(playerData);
            }
            return(list);
        }
        public static List <List <List <object> > > BuildDMGStatsTargetsData(ParsedLog log, int phaseIndex)
        {
            var list = new List <List <List <object> > >();

            PhaseData phase = log.FightData.GetPhases(log)[phaseIndex];

            foreach (Player player in log.PlayerList)
            {
                var playerData = new List <List <object> >();
                foreach (NPC target in phase.Targets)
                {
                    FinalGameplayStats statsTarget = player.GetGameplayStats(log, phaseIndex, target);
                    playerData.Add(PhaseDto.GetDMGTargetStatData(statsTarget));
                }
                list.Add(playerData);
            }
            return(list);
        }
        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);
        }