public static JsonDeathRecap BuildJsonDeathRecap(DeathRecap recap)
        {
            var jsonDeathRecap = new JsonDeathRecap();

            jsonDeathRecap.DeathTime = recap.DeathTime;
            jsonDeathRecap.ToDown    = recap.ToDown?.Select(x => BuildJsonDeathRecapDamageItem(x)).ToList();
            jsonDeathRecap.ToKill    = recap.ToKill?.Select(x => BuildJsonDeathRecapDamageItem(x)).ToList();
            return(jsonDeathRecap);
        }
Beispiel #2
0
        private List <JsonDeathRecap> BuildDeathRecaps(Player p)
        {
            List <JsonDeathRecap>    res    = new List <JsonDeathRecap>();
            List <Player.DeathRecap> recaps = p.GetDeathRecaps(_log);

            if (recaps == null)
            {
                return(null);
            }
            foreach (Player.DeathRecap deathRecap in recaps)
            {
                JsonDeathRecap recap = new JsonDeathRecap()
                {
                    time = deathRecap.Time
                };
                res.Add(recap);
                if (deathRecap.ToKill != null)
                {
                    recap.toKill = new List <JsonDeathRecap.JsonDeathRecapDamageItem>();
                    foreach (Player.DeathRecap.DeathRecapDamageItem item in deathRecap.ToKill)
                    {
                        recap.toKill.Add(new JsonDeathRecap.JsonDeathRecapDamageItem()
                        {
                            time    = item.Time,
                            skillID = item.Skill,
                            damage  = item.Damage,
                            source  = item.Src,
                            condi   = item.Condi
                        });
                    }
                }
                if (deathRecap.ToDown != null)
                {
                    recap.toDown = new List <JsonDeathRecap.JsonDeathRecapDamageItem>();
                    foreach (Player.DeathRecap.DeathRecapDamageItem item in deathRecap.ToDown)
                    {
                        recap.toDown.Add(new JsonDeathRecap.JsonDeathRecapDamageItem()
                        {
                            time    = item.Time,
                            skillID = item.Skill,
                            damage  = item.Damage,
                            source  = item.Src,
                            condi   = item.Condi
                        });
                    }
                }
            }
            return(res);
        }
        private List <JsonDeathRecap> BuilDeathRecap(Player player)
        {
            List <JsonDeathRecap> res = new List <JsonDeathRecap>();
            long start                  = _log.FightData.FightStart;
            long end                    = _log.FightData.FightEnd;
            List <CombatItem> dead      = _log.CombatData.GetStates(player.InstID, ParseEnum.StateChange.ChangeDead, start, end);
            List <CombatItem> down      = _log.CombatData.GetStates(player.InstID, ParseEnum.StateChange.ChangeDown, start, end);
            long             lastTime   = start;
            List <DamageLog> damageLogs = player.GetDamageTakenLogs(_log, 0, _log.FightData.FightDuration);

            foreach (CombatItem c in dead)
            {
                JsonDeathRecap recap = new JsonDeathRecap()
                {
                    Time = (int)(c.Time - start)
                };
                CombatItem downed = down.LastOrDefault(x => x.Time <= c.Time && x.Time >= lastTime);
                if (downed != null)
                {
                    List <DamageLog> damageToDown = damageLogs.Where(x => x.Time < downed.Time - start && x.Damage > 0 && x.Time > lastTime - start).ToList();
                    recap.ToDown = damageToDown.Count > 0 ? new List <JsonDeathRecap.DamageItem>() : null;
                    int damage = 0;
                    for (int i = damageToDown.Count - 1; i > 0; i--)
                    {
                        DamageLog dl = damageToDown[i];
                        AgentItem ag = _log.AgentData.GetAgentByInstID(dl.SrcInstId, dl.Time + start);
                        JsonDeathRecap.DamageItem item = new JsonDeathRecap.DamageItem()
                        {
                            Time   = (int)dl.Time,
                            Condi  = dl.IsCondi,
                            Skill  = dl.SkillId,
                            Damage = dl.Damage,
                            Src    = ag != null?ag.Name.Replace("\u0000", "").Split(':')[0] : ""
                        };
                        damage += dl.Damage;
                        recap.ToDown.Add(item);
                        if (damage > 20000)
                        {
                            break;
                        }
                    }
                    List <DamageLog> damageToKill = damageLogs.Where(x => x.Time > downed.Time - start && x.Time < c.Time - start && x.Damage > 0 && x.Time > lastTime - start).ToList();
                    recap.ToKill = damageToKill.Count > 0 ? new List <JsonDeathRecap.DamageItem>() : null;
                    for (int i = damageToKill.Count - 1; i > 0; i--)
                    {
                        DamageLog dl = damageToKill[i];
                        AgentItem ag = _log.AgentData.GetAgentByInstID(dl.SrcInstId, dl.Time + start);
                        JsonDeathRecap.DamageItem item = new JsonDeathRecap.DamageItem()
                        {
                            Time   = (int)dl.Time,
                            Condi  = dl.IsCondi,
                            Skill  = dl.SkillId,
                            Damage = dl.Damage,
                            Src    = ag != null?ag.Name.Replace("\u0000", "").Split(':')[0] : ""
                        };
                        recap.ToKill.Add(item);
                    }
                }
                else
                {
                    recap.ToDown = null;
                    List <DamageLog> damageToKill = damageLogs.Where(x => x.Time < c.Time - start && x.Damage > 0 && x.Time > lastTime - start).ToList();
                    recap.ToKill = damageToKill.Count > 0 ? new List <JsonDeathRecap.DamageItem>() : null;
                    int damage = 0;
                    for (int i = damageToKill.Count - 1; i > 0; i--)
                    {
                        DamageLog dl = damageToKill[i];
                        AgentItem ag = _log.AgentData.GetAgentByInstID(dl.SrcInstId, dl.Time + start);
                        JsonDeathRecap.DamageItem item = new JsonDeathRecap.DamageItem()
                        {
                            Time   = (int)dl.Time,
                            Condi  = dl.IsCondi,
                            Skill  = dl.SkillId,
                            Damage = dl.Damage,
                            Src    = ag != null?ag.Name.Replace("\u0000", "").Split(':')[0] : ""
                        };
                        damage += dl.Damage;
                        recap.ToKill.Add(item);
                        if (damage > 20000)
                        {
                            break;
                        }
                    }
                }
                lastTime = c.Time;
                res.Add(recap);
            }
            return(res.Count > 0 ? res : null);
        }