Пример #1
0
 public MechanicLog(long time, Mechanic mechanic,
                    AbstractMasterPlayer player)
 {
     Time      = time;
     _mechanic = mechanic;
     Player    = player;
 }
Пример #2
0
 private List <int>[] Build1SDPS(AbstractMasterPlayer player)
 {
     List <int>[] res = new List <int> [_log.FightData.Logic.Targets.Count];
     for (int i = 0; i < _log.FightData.Logic.Targets.Count; i++)
     {
         res[i] = Build1SDPS(player, _log.FightData.Logic.Targets[i]);
     }
     return(res);
 }
Пример #3
0
        private List <int> Build1SDPS(AbstractMasterPlayer player, Target target)
        {
            List <int> res = new List <int>();

            foreach (var pt in GraphHelper.GetTargetDPSGraph(_log, player, 0, _statistics.Phases[0], GraphHelper.GraphMode.S1, target))
            {
                res.Add(pt.Y);
            }
            return(res);
        }
Пример #4
0
 private Dictionary <string, JsonDamageDist>[] BuildDamageTaken(AbstractMasterPlayer p)
 {
     Dictionary <string, JsonDamageDist>[] res = new Dictionary <string, JsonDamageDist> [_statistics.Phases.Count];
     for (int i = 0; i < _statistics.Phases.Count; i++)
     {
         PhaseData phase = _statistics.Phases[i];
         res[i] = BuildDamageDist(p.GetDamageTakenLogs(null, _log, phase.Start, phase.End));
     }
     return(res);
 }
Пример #5
0
 private Dictionary <string, JsonDamageDist>[][] BuildDamageDist(AbstractMasterPlayer p)
 {
     Dictionary <string, JsonDamageDist>[][] res = new Dictionary <string, JsonDamageDist> [_log.FightData.Logic.Targets.Count][];
     for (int i = 0; i < _log.FightData.Logic.Targets.Count; i++)
     {
         Target target = _log.FightData.Logic.Targets[i];
         res[i] = BuildDamageDist(p, target);
     }
     return(res);
 }
 private Dictionary <long, JsonDamageDist>[] BuildDamageDist(AbstractMasterPlayer p, Boss target)
 {
     Dictionary <long, JsonDamageDist>[] res = new Dictionary <long, JsonDamageDist> [_statistics.Phases.Count];
     for (int i = 0; i < _statistics.Phases.Count; i++)
     {
         PhaseData phase = _statistics.Phases[i];
         res[i] = BuildDamageDist(p.GetJustPlayerDamageLogs(target, _log, phase.Start, phase.End));
     }
     return(res);
 }
Пример #7
0
        private List <JsonMinions> BuildMinions(AbstractMasterPlayer master)
        {
            List <JsonMinions> mins = new List <JsonMinions>();

            foreach (Minions minions in master.GetMinions(_log).Values)
            {
                JsonMinions min = new JsonMinions()
                {
                    Name             = minions.Character,
                    Rotation         = BuildRotation(minions.GetCastLogs(_log, 0, _log.FightData.FightDuration)),
                    TotalDamageDist  = BuildDamageDist(minions, null),
                    TargetDamageDist = BuildDamageDist(minions),
                };
                mins.Add(min);
            }
            return(mins);
        }
        /// <summary>
        /// Gets the points for the cleave dps graph for a given player
        /// </summary>
        /// <param name="log"></param>
        /// <param name="p"></param>
        /// <param name="phaseIndex"></param>
        /// <param name="phase"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        public static List <Point> GetCleaveDPSGraph(ParsedLog log, AbstractMasterPlayer p, int phaseIndex, PhaseData phase, GraphMode mode, Boss boss)
        {
            int askedId = (phaseIndex + "_" + (-1) + "_" + mode).GetHashCode();

            if (p.GetDPSGraph(askedId).Count > 0)
            {
                return(p.GetDPSGraph(askedId));
            }
            List <Point> totalPoints  = GetTotalDPSGraph(log, p, phaseIndex, phase, mode);
            List <Point> bossPoints   = GetBossDPSGraph(log, p, phaseIndex, phase, mode, boss);
            List <Point> cleavePoints = new List <Point>();

            for (int i = 0; i < bossPoints.Count; i++)
            {
                cleavePoints.Add(new Point(bossPoints[i].X, totalPoints[i].Y - bossPoints[i].Y));
            }
            p.DpsGraph[askedId] = cleavePoints;
            return(cleavePoints);
        }
        private static List <Point> GetDPSGraph(ParsedLog log, AbstractMasterPlayer p, int phaseIndex, PhaseData phase, AbstractPlayer target, GraphMode mode)
        {
            ulong targetId = target != null ? target.Agent : 0;
            int   askedId  = (phaseIndex + "_" + targetId + "_" + mode).GetHashCode();

            if (p.GetDPSGraph(askedId).Count > 0)
            {
                return(p.GetDPSGraph(askedId));
            }

            List <Point>     dmgList    = new List <Point>();
            List <Point>     dmgList1s  = new List <Point>();
            List <Point>     dmgList10s = new List <Point>();
            List <Point>     dmgList30s = new List <Point>();
            List <DamageLog> damageLogs = p.GetDamageLogs(target, log, phase.Start, phase.End);
            // fill the graph, full precision
            List <double> dmgListFull = new List <double>();

            for (int i = 0; i <= phase.GetDuration(); i++)
            {
                dmgListFull.Add(0.0);
            }
            int totalTime   = 1;
            int totalDamage = 0;

            foreach (DamageLog dl in damageLogs)
            {
                int time = (int)(dl.Time - phase.Start);
                // fill
                for (; totalTime < time; totalTime++)
                {
                    dmgListFull[totalTime] = totalDamage;
                }
                totalDamage           += dl.Damage;
                dmgListFull[totalTime] = totalDamage;
            }
            // fill
            for (; totalTime <= phase.GetDuration(); totalTime++)
            {
                dmgListFull[totalTime] = totalDamage;
            }

            /*CombatReplay replay = p.Replay;
             * if (replay != null && dstid == 0 && phaseIndex == 0)
             * {
             *  foreach (int i in replay.GetTimes())
             *  {
             *      int limitId = 0;
             *      replay.AddDPS((int)Math.Round(1000 * (dmgListFull[i] - dmgListFull[limitId]) / (i - limitId)));
             *      if (Settings.Show10s)
             *      {
             *          limitId = Math.Max(i - 10000, 0);
             *          replay.AddDPS10s((int)Math.Round(1000 * (dmgListFull[i] - dmgListFull[limitId]) / (i - limitId)));
             *      }
             *      if (Settings.Show30s)
             *      {
             *          limitId = Math.Max(i - 30000, 0);
             *          replay.AddDPS30s((int)Math.Round(1000 * (dmgListFull[i] - dmgListFull[limitId]) / (i - limitId)));
             *      }
             *  }
             * }*/
            dmgList.Add(new Point(0, 0));
            dmgList1s.Add(new Point(0, 0));
            dmgList10s.Add(new Point(0, 0));
            dmgList30s.Add(new Point(0, 0));
            for (int i = 1; i <= phase.GetDuration("s"); i++)
            {
                int limitId = 0;
                dmgList.Add(new Point(i, (int)Math.Round((dmgListFull[1000 * i] - dmgListFull[1000 * limitId]) / (i - limitId))));
                limitId = i - 1;
                dmgList1s.Add(new Point(i, (int)Math.Round((dmgListFull[1000 * i] - dmgListFull[1000 * limitId]) / (i - limitId))));
                if (Settings.Show10s)
                {
                    limitId = Math.Max(i - 10, 0);
                    dmgList10s.Add(new Point(i, (int)Math.Round((dmgListFull[1000 * i] - dmgListFull[1000 * limitId]) / (i - limitId))));
                }
                if (Settings.Show30s)
                {
                    limitId = Math.Max(i - 30, 0);
                    dmgList30s.Add(new Point(i, (int)Math.Round((dmgListFull[1000 * i] - dmgListFull[1000 * limitId]) / (i - limitId))));
                }
            }
            int id = (phaseIndex + "_" + targetId + "_" + GraphMode.Full).GetHashCode();

            p.DpsGraph[id] = dmgList;
            id             = (phaseIndex + "_" + targetId + "_" + GraphMode.S1).GetHashCode();
            p.DpsGraph[id] = dmgList1s;
            if (Settings.Show10s)
            {
                id             = (phaseIndex + "_" + targetId + "_" + GraphMode.S10).GetHashCode();
                p.DpsGraph[id] = dmgList10s;
            }
            if (Settings.Show30s)
            {
                id             = (phaseIndex + "_" + targetId + "_" + GraphMode.S30).GetHashCode();
                p.DpsGraph[id] = dmgList30s;
            }
            return(p.GetDPSGraph(askedId));
        }
 /// <summary>
 /// Gets the points for the total dps graph for a given player
 /// </summary>
 /// <param name="log"></param>
 /// <param name="p"></param>
 /// <param name="phaseIndex"></param>
 /// <param name="phase"></param>
 /// <param name="mode"></param>
 /// <returns></returns>
 public static List <Point> GetTotalDPSGraph(ParsedLog log, AbstractMasterPlayer p, int phaseIndex, PhaseData phase, GraphMode mode)
 {
     return(GetDPSGraph(log, p, phaseIndex, phase, null, mode));
 }
 /// <summary>
 /// Gets the points for the boss dps graph for a given player
 /// </summary>
 /// <param name="log"></param>
 /// <param name="p"></param>
 /// <param name="phaseIndex"></param>
 /// <param name="phase"></param>
 /// <param name="mode"></param>
 /// <returns></returns>
 public static List <Point> GetBossDPSGraph(ParsedLog log, AbstractMasterPlayer p, int phaseIndex, PhaseData phase, GraphMode mode, Boss boss)
 {
     return(GetDPSGraph(log, p, phaseIndex, phase, boss, mode));
 }
        //
        protected static List <CombatItem> GetFilteredList(ParsedLog log, long skillID, AbstractMasterPlayer target)
        {
            bool needStart             = true;
            List <CombatItem> main     = log.GetBoonData(skillID).Where(x => ((x.DstInstid == target.InstID && x.IsBuffRemove == ParseEnum.BuffRemove.None) || (x.SrcInstid == target.InstID && x.IsBuffRemove != ParseEnum.BuffRemove.None)) && x.Time >= target.FirstAware && x.Time <= target.LastAware).ToList();
            List <CombatItem> filtered = new List <CombatItem>();

            for (int i = 0; i < main.Count; i++)
            {
                CombatItem c = main[i];
                if (needStart && c.IsBuffRemove == ParseEnum.BuffRemove.None)
                {
                    needStart = false;
                    filtered.Add(c);
                }
                else if (!needStart && c.IsBuffRemove != ParseEnum.BuffRemove.None)
                {
                    // consider only last remove event before another application
                    if ((i == main.Count - 1) || (i < main.Count - 1 && main[i + 1].IsBuffRemove == ParseEnum.BuffRemove.None))
                    {
                        needStart = true;
                        filtered.Add(c);
                    }
                }
            }
            return(filtered);
        }
        public void ComputeMechanics(ParsedLog log)
        {
            MechanicData mechData   = log.MechanicData;
            FightData    fightData  = log.FightData;
            CombatData   combatData = log.CombatData;
            long         start      = fightData.FightStart;
            long         end        = fightData.FightEnd;

            Mechanic.CheckSpecialCondition condition;
            HashSet <ushort> playersIds = new HashSet <ushort>(log.PlayerList.Select(x => x.InstID));
            Dictionary <ushort, AbstractMasterPlayer> regroupedMobs = new Dictionary <ushort, AbstractMasterPlayer>();

            foreach (Mechanic mech in MechanicList)
            {
                switch (mech.MechanicType)
                {
                case Mechanic.MechType.PlayerStatus:
                    foreach (Player p in log.PlayerList)
                    {
                        List <CombatItem> cList = new List <CombatItem>();
                        switch (mech.SkillId)
                        {
                        case SkillItem.DeathId:
                            cList = combatData.GetStates(p.InstID, ParseEnum.StateChange.ChangeDead, start, end);
                            break;

                        case SkillItem.DownId:
                            cList = combatData.GetStates(p.InstID, ParseEnum.StateChange.ChangeDown, start, end);
                            break;

                        case SkillItem.ResurrectId:
                            cList = log.GetCastData(p.InstID).Where(x => x.SkillID == SkillItem.ResurrectId && x.IsActivation.IsCasting()).ToList();
                            break;
                        }
                        foreach (CombatItem mechItem in cList)
                        {
                            mechData[mech].Add(new MechanicLog(mechItem.Time - start, mech, p));
                        }
                    }
                    break;

                case Mechanic.MechType.SkillOnPlayer:
                    foreach (Player p in log.PlayerList)
                    {
                        List <DamageLog> dls = p.GetDamageTakenLogs(log, 0, fightData.FightDuration);
                        condition = mech.SpecialCondition;
                        foreach (DamageLog dLog in dls)
                        {
                            if (condition != null && !condition(new SpecialConditionItem(dLog)))
                            {
                                continue;
                            }
                            if (dLog.SkillId == mech.SkillId && dLog.Result.IsHit())
                            {
                                mechData[mech].Add(new MechanicLog(dLog.Time, mech, p));
                            }
                        }
                    }
                    break;

                case Mechanic.MechType.PlayerBoon:
                case Mechanic.MechType.PlayerOnPlayer:
                case Mechanic.MechType.PlayerBoonRemove:
                    foreach (Player p in log.PlayerList)
                    {
                        condition = mech.SpecialCondition;
                        foreach (CombatItem c in log.GetBoonData(mech.SkillId))
                        {
                            if (condition != null && !condition(new SpecialConditionItem(c)))
                            {
                                continue;
                            }
                            if (mech.MechanicType == Mechanic.MechType.PlayerBoonRemove)
                            {
                                if (c.IsBuffRemove == ParseEnum.BuffRemove.Manual && p.InstID == c.SrcInstid)
                                {
                                    mechData[mech].Add(new MechanicLog(c.Time - start, mech, p));
                                }
                            }
                            else
                            {
                                if (c.IsBuffRemove == ParseEnum.BuffRemove.None && p.InstID == c.DstInstid)
                                {
                                    mechData[mech].Add(new MechanicLog(c.Time - start, mech, p));
                                    if (mech.MechanicType == Mechanic.MechType.PlayerOnPlayer)
                                    {
                                        mechData[mech].Add(new MechanicLog(c.Time - start, mech, log.PlayerList.FirstOrDefault(x => x.InstID == c.SrcInstid)));
                                    }
                                }
                            }
                        }
                    }
                    break;

                case Mechanic.MechType.HitOnEnemy:
                    foreach (Player p in log.PlayerList)
                    {
                        condition = mech.SpecialCondition;
                        IEnumerable <AgentItem> agents = log.AgentData.GetAgentsByID((ushort)mech.SkillId);
                        foreach (AgentItem a in agents)
                        {
                            foreach (DamageLog dl in p.GetDamageLogs(null, log, 0, log.FightData.FightDuration))
                            {
                                if (dl.DstInstId != a.InstID || dl.IsCondi > 0 || dl.Time < a.FirstAware - start || dl.Time > a.LastAware - start || (condition != null && !condition(new SpecialConditionItem(dl))))
                                {
                                    continue;
                                }
                                mechData[mech].Add(new MechanicLog(dl.Time, mech, p));
                            }
                        }
                    }
                    break;

                case Mechanic.MechType.PlayerSkill:
                    foreach (Player p in log.PlayerList)
                    {
                        condition = mech.SpecialCondition;
                        foreach (CombatItem c in log.GetCastDataById(mech.SkillId))
                        {
                            if (condition != null && !condition(new SpecialConditionItem(c)))
                            {
                                continue;
                            }
                            if (c.IsActivation.IsCasting() && c.SrcInstid == p.InstID)
                            {
                                mechData[mech].Add(new MechanicLog(c.Time - fightData.FightStart, mech, p));
                            }
                        }
                    }
                    break;

                case Mechanic.MechType.EnemyBoon:
                case Mechanic.MechType.EnemyBoonStrip:
                    condition = mech.SpecialCondition;
                    foreach (CombatItem c in log.GetBoonData(mech.SkillId))
                    {
                        if (condition != null && !condition(new SpecialConditionItem(c)))
                        {
                            continue;
                        }
                        AbstractMasterPlayer amp = null;
                        if (mech.MechanicType == Mechanic.MechType.EnemyBoon && c.IsBuffRemove == ParseEnum.BuffRemove.None)
                        {
                            Boss target = Targets.Find(x => x.InstID == c.DstInstid && x.FirstAware <= c.Time && x.LastAware >= c.Time);
                            if (target != null)
                            {
                                amp = target;
                            }
                            else
                            {
                                AgentItem a = log.AgentData.GetAgent(c.DstAgent);
                                if (playersIds.Contains(a.InstID))
                                {
                                    continue;
                                }
                                else if (a.MasterAgent != 0)
                                {
                                    AgentItem m = log.AgentData.GetAgent(a.MasterAgent);
                                    if (playersIds.Contains(m.InstID))
                                    {
                                        continue;
                                    }
                                }
                                if (!regroupedMobs.TryGetValue(a.ID, out amp))
                                {
                                    amp = new DummyPlayer(a);
                                    regroupedMobs.Add(a.ID, amp);
                                }
                            }
                        }
                        else if (mech.MechanicType == Mechanic.MechType.EnemyBoonStrip && c.IsBuffRemove == ParseEnum.BuffRemove.Manual)
                        {
                            Boss target = Targets.Find(x => x.InstID == c.SrcInstid && x.FirstAware <= c.Time && x.LastAware >= c.Time);
                            if (target != null)
                            {
                                amp = target;
                            }
                            else
                            {
                                AgentItem a = log.AgentData.GetAgent(c.SrcAgent);
                                if (playersIds.Contains(a.InstID))
                                {
                                    continue;
                                }
                                else if (a.MasterAgent != 0)
                                {
                                    AgentItem m = log.AgentData.GetAgent(a.MasterAgent);
                                    if (playersIds.Contains(m.InstID))
                                    {
                                        continue;
                                    }
                                }
                                if (!regroupedMobs.TryGetValue(a.ID, out amp))
                                {
                                    amp = new DummyPlayer(a);
                                    regroupedMobs.Add(a.ID, amp);
                                }
                            }
                        }
                        if (amp != null)
                        {
                            mechData[mech].Add(new MechanicLog(c.Time - fightData.FightStart, mech, amp));
                        }
                    }
                    break;

                case Mechanic.MechType.EnemyCastEnd:
                case Mechanic.MechType.EnemyCastStart:
                    condition = mech.SpecialCondition;
                    foreach (CombatItem c in log.GetCastDataById(mech.SkillId))
                    {
                        if (condition != null && !condition(new SpecialConditionItem(c)))
                        {
                            continue;
                        }
                        AbstractMasterPlayer amp = null;
                        if ((mech.MechanicType == Mechanic.MechType.EnemyCastStart && c.IsActivation.IsCasting()) || (mech.MechanicType == Mechanic.MechType.EnemyCastEnd && !c.IsActivation.IsCasting()))
                        {
                            Boss target = Targets.Find(x => x.InstID == c.SrcInstid && x.FirstAware <= c.Time && x.LastAware >= c.Time);
                            if (target != null)
                            {
                                amp = target;
                            }
                            else
                            {
                                AgentItem a = log.AgentData.GetAgent(c.SrcAgent);
                                if (playersIds.Contains(a.InstID))
                                {
                                    continue;
                                }
                                else if (a.MasterAgent != 0)
                                {
                                    AgentItem m = log.AgentData.GetAgent(a.MasterAgent);
                                    if (playersIds.Contains(m.InstID))
                                    {
                                        continue;
                                    }
                                }
                                if (!regroupedMobs.TryGetValue(a.ID, out amp))
                                {
                                    amp = new DummyPlayer(a);
                                    regroupedMobs.Add(a.ID, amp);
                                }
                            }
                        }
                        if (amp != null)
                        {
                            mechData[mech].Add(new MechanicLog(c.Time - fightData.FightStart, mech, amp));
                        }
                    }
                    break;

                case Mechanic.MechType.Spawn:
                    foreach (AgentItem a in log.AgentData.GetAgentByType(AgentItem.AgentType.NPC).Where(x => x.ID == mech.SkillId))
                    {
                        if (!regroupedMobs.TryGetValue(a.ID, out AbstractMasterPlayer amp))
                        {
                            amp = new DummyPlayer(a);
                            regroupedMobs.Add(a.ID, amp);
                        }
                        mechData[mech].Add(new MechanicLog(a.FirstAware - fightData.FightStart, mech, amp));
                    }
                    break;
                }
            }
            mechData.ComputePresentMechanics(log);
        }