Example #1
0
        private static JsonRotation BuildJsonRotation(ParsedEvtcLog log, long skillID, List <AbstractCastEvent> skillCasts, Dictionary <string, JsonLog.SkillDesc> skillDesc)
        {
            var jsonRotation = new JsonRotation();

            if (!skillDesc.ContainsKey("s" + skillID))
            {
                SkillItem skill = skillCasts.First().Skill;
                skillDesc["s" + skillID] = JsonLogBuilder.BuildSkillDesc(skill, log);
            }
            jsonRotation.Id     = skillID;
            jsonRotation.Skills = skillCasts.Select(x => BuildJsonSkill(x)).ToList();
            return(jsonRotation);
        }
Example #2
0
        public static JsonBuffsUptime BuildJsonBuffsUptime(AbstractSingleActor actor, long buffID, ParsedEvtcLog log, RawFormatSettings settings, List <JsonBuffsUptimeData> buffData, Dictionary <string, JsonLog.BuffDesc> buffDesc)
        {
            var jsonBuffsUptime = new JsonBuffsUptime();

            jsonBuffsUptime.Id       = buffID;
            jsonBuffsUptime.BuffData = buffData;
            if (!buffDesc.ContainsKey("b" + buffID))
            {
                buffDesc["b" + buffID] = JsonLogBuilder.BuildBuffDesc(log.Buffs.BuffsByIds[buffID], log);
            }
            if (settings.RawFormatTimelineArrays)
            {
                jsonBuffsUptime.States = GetBuffStates(actor.GetBuffGraphs(log)[buffID]);
            }
            return(jsonBuffsUptime);
        }
        private static EXTJsonHealingDist BuildHealingDist(long id, List <EXTAbstractHealingEvent> list, ParsedEvtcLog log, Dictionary <string, JsonLog.SkillDesc> skillDesc, Dictionary <string, JsonLog.BuffDesc> buffDesc)
        {
            var jsonHealingDist = new EXTJsonHealingDist();

            jsonHealingDist.IndirectHealing = list.Exists(x => x is EXTNonDirectHealingEvent);
            if (jsonHealingDist.IndirectHealing)
            {
                if (!buffDesc.ContainsKey("b" + id))
                {
                    if (log.Buffs.BuffsByIds.TryGetValue(id, out Buff buff))
                    {
                        buffDesc["b" + id] = JsonLogBuilder.BuildBuffDesc(buff, log);
                    }
                    else
                    {
                        SkillItem skill   = list.First().Skill;
                        var       auxBoon = new Buff(skill.Name, id, skill.Icon);
                        buffDesc["b" + id] = JsonLogBuilder.BuildBuffDesc(auxBoon, log);
                    }
                }
            }
            else
            {
                if (!skillDesc.ContainsKey("s" + id))
                {
                    SkillItem skill = list.First().Skill;
                    skillDesc["s" + id] = JsonLogBuilder.BuildSkillDesc(skill, log);
                }
            }
            jsonHealingDist.Id  = id;
            jsonHealingDist.Min = int.MaxValue;
            jsonHealingDist.Max = int.MinValue;
            foreach (EXTAbstractHealingEvent healingEvt in list)
            {
                jsonHealingDist.Hits++;;
                jsonHealingDist.TotalHealing += healingEvt.HealingDone;
                if (healingEvt.AgainstDowned)
                {
                    jsonHealingDist.TotalDownedHealing += healingEvt.HealingDone;
                }
                jsonHealingDist.Min = Math.Min(jsonHealingDist.Min, healingEvt.HealingDone);
                jsonHealingDist.Max = Math.Max(jsonHealingDist.Max, healingEvt.HealingDone);
            }
            jsonHealingDist.Min = jsonHealingDist.Min == int.MaxValue ? 0 : jsonHealingDist.Min;
            jsonHealingDist.Max = jsonHealingDist.Max == int.MinValue ? 0 : jsonHealingDist.Max;
            return(jsonHealingDist);
        }
        private static List <JsonPlayerBuffsGeneration> GetPlayerBuffGenerations(List <IReadOnlyDictionary <long, FinalPlayerBuffs> > buffs, ParsedEvtcLog log, Dictionary <string, JsonLog.BuffDesc> buffDesc)
        {
            IReadOnlyList <PhaseData> phases = log.FightData.GetNonDummyPhases(log);
            var uptimes = new List <JsonPlayerBuffsGeneration>();

            foreach (KeyValuePair <long, FinalPlayerBuffs> pair in buffs[0])
            {
                Buff buff = log.Buffs.BuffsByIds[pair.Key];
                if (!buffDesc.ContainsKey("b" + pair.Key))
                {
                    buffDesc["b" + pair.Key] = JsonLogBuilder.BuildBuffDesc(buff, log);
                }
                var data = new List <JsonBuffsGenerationData>();
                for (int i = 0; i < phases.Count; i++)
                {
                    if (buffs[i].TryGetValue(pair.Key, out FinalPlayerBuffs val))
                    {
                        JsonBuffsGenerationData value = JsonPlayerBuffsGenerationBuilder.BuildJsonBuffsGenerationData(val);
                        data.Add(value);
                    }
                    else
                    {
                        var value = new JsonBuffsGenerationData();
                        data.Add(value);
                    }
                }
                var jsonBuffs = new JsonPlayerBuffsGeneration()
                {
                    BuffData = data,
                    Id       = pair.Key
                };
                uptimes.Add(jsonBuffs);
            }

            if (!uptimes.Any())
            {
                return(null);
            }

            return(uptimes);
        }
        public static List <JsonDamageModifierData> GetDamageModifiers(List <IReadOnlyDictionary <string, DamageModifierStat> > damageModDicts, ParsedEvtcLog log, Dictionary <string, JsonLog.DamageModDesc> damageModDesc)
        {
            var dict = new Dictionary <int, List <JsonDamageModifierItem> >();

            foreach (IReadOnlyDictionary <string, DamageModifierStat> damageModDict in damageModDicts)
            {
                foreach (string key in damageModDict.Keys)
                {
                    DamageModifier dMod = log.DamageModifiers.DamageModifiersByName[key];
                    int            iKey = dMod.ID;
                    string         nKey = "d" + iKey;
                    if (!damageModDesc.ContainsKey(nKey))
                    {
                        damageModDesc[nKey] = JsonLogBuilder.BuildDamageModDesc(dMod);
                    }
                    if (dict.TryGetValue(iKey, out List <JsonDamageModifierItem> list))
                    {
                        list.Add(BuildJsonDamageModifierItem(damageModDict[key]));
                    }
                    else
                    {
                        dict[iKey] = new List <JsonDamageModifierItem>
                        {
                            BuildJsonDamageModifierItem(damageModDict[key])
                        };
                    }
                }
            }

            var res = new List <JsonDamageModifierData>();

            foreach (KeyValuePair <int, List <JsonDamageModifierItem> > pair in dict)
            {
                res.Add(BuildJsonDamageModifierData(pair.Key, pair.Value));
            }
            return(res);
        }
        public static JsonPlayer BuildJsonPlayer(Player player, ParsedEvtcLog log, RawFormatSettings settings, Dictionary <string, JsonLog.SkillDesc> skillDesc, Dictionary <string, JsonLog.BuffDesc> buffDesc, Dictionary <string, JsonLog.DamageModDesc> damageModDesc, Dictionary <string, HashSet <long> > personalBuffs)
        {
            var jsonPlayer = new JsonPlayer();

            JsonActorBuilder.FillJsonActor(jsonPlayer, player, log, settings, skillDesc, buffDesc);
            IReadOnlyList <PhaseData> phases = log.FightData.GetNonDummyPhases(log);

            //
            jsonPlayer.Account         = player.Account;
            jsonPlayer.Weapons         = player.GetWeaponsArray(log).Select(w => w ?? "Unknown").ToArray();
            jsonPlayer.Group           = player.Group;
            jsonPlayer.Profession      = player.Prof;
            jsonPlayer.FriendlyNPC     = player.AgentItem.IsNPC;
            jsonPlayer.NotInSquad      = player.AgentItem.IsNotInSquadPlayer;
            jsonPlayer.ActiveTimes     = phases.Select(x => player.GetActiveDuration(log, x.Start, x.End)).ToList();
            jsonPlayer.HasCommanderTag = player.HasCommanderTag;
            //
            jsonPlayer.Support = phases.Select(phase => JsonStatisticsBuilder.BuildJsonPlayerSupport(player.GetPlayerSupportStats(log, phase.Start, phase.End))).ToArray();
            var targetDamage1S          = new IReadOnlyList <int> [log.FightData.Logic.Targets.Count][];
            var targetPowerDamage1S     = new IReadOnlyList <int> [log.FightData.Logic.Targets.Count][];
            var targetConditionDamage1S = new IReadOnlyList <int> [log.FightData.Logic.Targets.Count][];
            var targetBreakbarDamage1S  = new IReadOnlyList <double> [log.FightData.Logic.Targets.Count][];
            var dpsTargets       = new JsonStatistics.JsonDPS[log.FightData.Logic.Targets.Count][];
            var statsTargets     = new JsonStatistics.JsonGameplayStats[log.FightData.Logic.Targets.Count][];
            var targetDamageDist = new IReadOnlyList <JsonDamageDist> [log.FightData.Logic.Targets.Count][];

            for (int j = 0; j < log.FightData.Logic.Targets.Count; j++)
            {
                NPC target                     = log.FightData.Logic.Targets[j];
                var graph1SDamageList          = new IReadOnlyList <int> [phases.Count];
                var graph1SPowerDamageList     = new IReadOnlyList <int> [phases.Count];
                var graph1SConditionDamageList = new IReadOnlyList <int> [phases.Count];
                var graph1SBreakbarDamageList  = new IReadOnlyList <double> [phases.Count];
                var targetDamageDistList       = new IReadOnlyList <JsonDamageDist> [phases.Count];
                for (int i = 0; i < phases.Count; i++)
                {
                    PhaseData phase = phases[i];
                    if (settings.RawFormatTimelineArrays)
                    {
                        graph1SDamageList[i]          = player.Get1SDamageList(log, phase.Start, phase.End, target, DamageType.All);
                        graph1SPowerDamageList[i]     = player.Get1SDamageList(log, phase.Start, phase.End, target, DamageType.Power);
                        graph1SConditionDamageList[i] = player.Get1SDamageList(log, phase.Start, phase.End, target, DamageType.Condition);
                        graph1SBreakbarDamageList[i]  = player.Get1SBreakbarDamageList(log, phase.Start, phase.End, target);
                    }
                    targetDamageDistList[i] = JsonDamageDistBuilder.BuildJsonDamageDistList(player.GetDamageEvents(target, log, phase.Start, phase.End).GroupBy(x => x.SkillId).ToDictionary(x => x.Key, x => x.ToList()), log, skillDesc, buffDesc);
                }
                if (settings.RawFormatTimelineArrays)
                {
                    targetDamage1S[j]          = graph1SDamageList;
                    targetPowerDamage1S[j]     = graph1SPowerDamageList;
                    targetConditionDamage1S[j] = graph1SConditionDamageList;
                    targetBreakbarDamage1S[j]  = graph1SBreakbarDamageList;
                }
                targetDamageDist[j] = targetDamageDistList;
                dpsTargets[j]       = phases.Select(phase => JsonStatisticsBuilder.BuildJsonDPS(player.GetDPSStats(target, log, phase.Start, phase.End))).ToArray();
                statsTargets[j]     = phases.Select(phase => JsonStatisticsBuilder.BuildJsonGameplayStats(player.GetGameplayStats(target, log, phase.Start, phase.End))).ToArray();
            }
            if (settings.RawFormatTimelineArrays)
            {
                jsonPlayer.TargetDamage1S          = targetDamage1S;
                jsonPlayer.TargetPowerDamage1S     = targetPowerDamage1S;
                jsonPlayer.TargetConditionDamage1S = targetConditionDamage1S;
                jsonPlayer.TargetBreakbarDamage1S  = targetBreakbarDamage1S;
            }
            jsonPlayer.TargetDamageDist = targetDamageDist;
            jsonPlayer.DpsTargets       = dpsTargets;
            jsonPlayer.StatsTargets     = statsTargets;
            if (!log.CombatData.HasBreakbarDamageData)
            {
                jsonPlayer.TargetBreakbarDamage1S = null;
            }
            //
            jsonPlayer.BuffUptimes   = GetPlayerJsonBuffsUptime(player, phases.Select(phase => player.GetBuffs(BuffEnum.Self, log, phase.Start, phase.End)).ToList(), log, settings, buffDesc, personalBuffs);
            jsonPlayer.SelfBuffs     = GetPlayerBuffGenerations(phases.Select(phase => player.GetBuffs(BuffEnum.Self, log, phase.Start, phase.End)).ToList(), log, buffDesc);
            jsonPlayer.GroupBuffs    = GetPlayerBuffGenerations(phases.Select(phase => player.GetBuffs(BuffEnum.Group, log, phase.Start, phase.End)).ToList(), log, buffDesc);
            jsonPlayer.OffGroupBuffs = GetPlayerBuffGenerations(phases.Select(phase => player.GetBuffs(BuffEnum.OffGroup, log, phase.Start, phase.End)).ToList(), log, buffDesc);
            jsonPlayer.SquadBuffs    = GetPlayerBuffGenerations(phases.Select(phase => player.GetBuffs(BuffEnum.Squad, log, phase.Start, phase.End)).ToList(), log, buffDesc);
            //
            jsonPlayer.BuffUptimesActive   = GetPlayerJsonBuffsUptime(player, phases.Select(phase => player.GetActiveBuffs(BuffEnum.Self, log, phase.Start, phase.End)).ToList(), log, settings, buffDesc, personalBuffs);
            jsonPlayer.SelfBuffsActive     = GetPlayerBuffGenerations(phases.Select(phase => player.GetActiveBuffs(BuffEnum.Self, log, phase.Start, phase.End)).ToList(), log, buffDesc);
            jsonPlayer.GroupBuffsActive    = GetPlayerBuffGenerations(phases.Select(phase => player.GetActiveBuffs(BuffEnum.Group, log, phase.Start, phase.End)).ToList(), log, buffDesc);
            jsonPlayer.OffGroupBuffsActive = GetPlayerBuffGenerations(phases.Select(phase => player.GetActiveBuffs(BuffEnum.OffGroup, log, phase.Start, phase.End)).ToList(), log, buffDesc);
            jsonPlayer.SquadBuffsActive    = GetPlayerBuffGenerations(phases.Select(phase => player.GetActiveBuffs(BuffEnum.Squad, log, phase.Start, phase.End)).ToList(), log, buffDesc);
            //
            IReadOnlyList <Consumable> consumables = player.GetConsumablesList(log, 0, log.FightData.FightEnd);

            if (consumables.Any())
            {
                var consumablesJSON = new List <JsonConsumable>();
                foreach (Consumable food in consumables)
                {
                    if (!buffDesc.ContainsKey("b" + food.Buff.ID))
                    {
                        buffDesc["b" + food.Buff.ID] = JsonLogBuilder.BuildBuffDesc(food.Buff, log);
                    }
                    consumablesJSON.Add(JsonConsumableBuilder.BuildJsonConsumable(food));
                }
                jsonPlayer.Consumables = consumablesJSON;
            }
            //
            IReadOnlyList <DeathRecap> deathRecaps = player.GetDeathRecaps(log);

            if (deathRecaps.Any())
            {
                jsonPlayer.DeathRecap = deathRecaps.Select(x => JsonDeathRecapBuilder.BuildJsonDeathRecap(x)).ToList();
            }
            //
            jsonPlayer.DamageModifiers       = JsonDamageModifierDataBuilder.GetDamageModifiers(phases.Select(x => player.GetDamageModifierStats(null, log, x.Start, x.End)).ToList(), log, damageModDesc);
            jsonPlayer.DamageModifiersTarget = JsonDamageModifierDataBuilder.GetDamageModifiersTarget(player, log, damageModDesc, phases);
            return(jsonPlayer);
        }
        private static JsonDamageDist BuildJsonDamageDist(long id, List <AbstractHealthDamageEvent> list, ParsedEvtcLog log, Dictionary <string, JsonLog.SkillDesc> skillDesc, Dictionary <string, JsonLog.BuffDesc> buffDesc)
        {
            var jsonDamageDist = new JsonDamageDist();

            jsonDamageDist.IndirectDamage = list.Exists(x => x is NonDirectHealthDamageEvent);
            if (jsonDamageDist.IndirectDamage)
            {
                if (!buffDesc.ContainsKey("b" + id))
                {
                    if (log.Buffs.BuffsByIds.TryGetValue(id, out Buff buff))
                    {
                        buffDesc["b" + id] = JsonLogBuilder.BuildBuffDesc(buff, log);
                    }
                    else
                    {
                        SkillItem skill   = list.First().Skill;
                        var       auxBoon = new Buff(skill.Name, id, skill.Icon);
                        buffDesc["b" + id] = JsonLogBuilder.BuildBuffDesc(auxBoon, log);
                    }
                }
            }
            else
            {
                if (!skillDesc.ContainsKey("s" + id))
                {
                    SkillItem skill = list.First().Skill;
                    skillDesc["s" + id] = JsonLogBuilder.BuildSkillDesc(skill, log.LogData.GW2Build, log.SkillData);
                }
            }
            jsonDamageDist.Id  = id;
            jsonDamageDist.Min = int.MaxValue;
            jsonDamageDist.Max = int.MinValue;
            foreach (AbstractHealthDamageEvent dmgEvt in list)
            {
                jsonDamageDist.Hits        += dmgEvt.DoubleProcHit ? 0 : 1;
                jsonDamageDist.TotalDamage += dmgEvt.HealthDamage;
                if (dmgEvt.HasHit)
                {
                    jsonDamageDist.Min = Math.Min(jsonDamageDist.Min, dmgEvt.HealthDamage);
                    jsonDamageDist.Max = Math.Max(jsonDamageDist.Max, dmgEvt.HealthDamage);
                }
                if (!jsonDamageDist.IndirectDamage)
                {
                    if (dmgEvt.HasHit)
                    {
                        jsonDamageDist.Flank      += dmgEvt.IsFlanking ? 1 : 0;
                        jsonDamageDist.Glance     += dmgEvt.HasGlanced ? 1 : 0;
                        jsonDamageDist.Crit       += dmgEvt.HasCrit ? 1 : 0;
                        jsonDamageDist.CritDamage += dmgEvt.HasCrit ? dmgEvt.HealthDamage : 0;
                    }
                    jsonDamageDist.Missed      += dmgEvt.IsBlind ? 1 : 0;
                    jsonDamageDist.Evaded      += dmgEvt.IsEvaded ? 1 : 0;
                    jsonDamageDist.Blocked     += dmgEvt.IsBlocked ? 1 : 0;
                    jsonDamageDist.Interrupted += dmgEvt.HasInterrupted ? 1 : 0;
                }
                jsonDamageDist.ConnectedHits += dmgEvt.HasHit ? 1 : 0;
                jsonDamageDist.Invulned      += dmgEvt.IsAbsorbed ? 1 : 0;
                jsonDamageDist.ShieldDamage  += dmgEvt.ShieldDamage;
            }
            jsonDamageDist.Min = jsonDamageDist.Min == int.MaxValue ? 0 : jsonDamageDist.Min;
            jsonDamageDist.Max = jsonDamageDist.Max == int.MinValue ? 0 : jsonDamageDist.Max;
            return(jsonDamageDist);
        }