Пример #1
0
        internal void BuildTotalStats(GenerateStatsOptions options)
        {
            lock (DamageGroupIds)
            {
                try
                {
                    FireNewStatsEvent(options);
                    Reset();

                    Selected = options.Npcs;
                    Title    = options.Name;
                    var damageBlocks = new List <ActionBlock>();

                    Selected.ForEach(fight =>
                    {
                        damageBlocks.AddRange(fight.DamageBlocks);

                        if (fight.GroupId > -1)
                        {
                            DamageGroupIds[fight.GroupId] = 1;
                        }

                        RaidTotals.Ranges.Add(new TimeSegment(fight.BeginDamageTime, fight.LastDamageTime));
                        StatsUtil.UpdateRaidTimeRanges(fight, PlayerTimeRanges, PlayerSubTimeRanges);
                    });

                    damageBlocks.Sort((a, b) => a.BeginTime.CompareTo(b.BeginTime));

                    if (damageBlocks.Count > 0)
                    {
                        RaidTotals.TotalSeconds = RaidTotals.Ranges.GetTotal();
                        RaidTotals.MaxTime      = RaidTotals.TotalSeconds;

                        int rangeIndex = 0;
                        var newBlock   = new List <ActionBlock>();
                        damageBlocks.ForEach(block =>
                        {
                            if (RaidTotals.Ranges.TimeSegments.Count > rangeIndex && block.BeginTime > RaidTotals.Ranges.TimeSegments[rangeIndex].EndTime)
                            {
                                rangeIndex++;

                                if (newBlock.Count > 0)
                                {
                                    DamageGroups.Add(newBlock);
                                }

                                newBlock = new List <ActionBlock>();
                            }

                            newBlock.Add(block);

                            // update pet mapping
                            block.Actions.ForEach(action => UpdatePetMapping(action as DamageRecord));
                        });

                        DamageGroups.Add(newBlock);
                        RaidTotals.Ranges.TimeSegments.ForEach(segment => DataManager.Instance.GetResistsDuring(segment.BeginTime, segment.EndTime).ForEach(block => Resists.AddRange(block.Actions)));
                        ComputeDamageStats(options);
                    }
                    else if (Selected == null || Selected.Count == 0)
                    {
                        FireNoDataEvent(options, "NONPC");
                    }
                    else
                    {
                        FireNoDataEvent(options, "NODATA");
                    }
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
                {
                    if (ex is ArgumentNullException || ex is NullReferenceException || ex is ArgumentOutOfRangeException || ex is ArgumentException || ex is OutOfMemoryException)
                    {
                        LOG.Error(ex);
                    }
                }
            }
        }
Пример #2
0
        internal void BuildTotalStats(GenerateStatsOptions options)
        {
            lock (TankingGroupIds)
            {
                try
                {
                    FireNewStatsEvent(options);
                    Reset();

                    Selected = options.Npcs.OrderBy(sel => sel.Id).ToList();
                    Title    = options.Name;
                    var damageBlocks = new List <ActionBlock>();

                    Selected.ForEach(fight =>
                    {
                        damageBlocks.AddRange(fight.TankingBlocks);

                        if (fight.GroupId > -1)
                        {
                            TankingGroupIds[fight.GroupId] = 1;
                        }

                        RaidTotals.Ranges.Add(new TimeSegment(fight.BeginTankingTime, fight.LastTankingTime));
                        StatsUtil.UpdateRaidTimeRanges(fight, PlayerTimeRanges, PlayerSubTimeRanges, true);
                    });

                    damageBlocks.Sort((a, b) => a.BeginTime.CompareTo(b.BeginTime));

                    if (damageBlocks.Count > 0)
                    {
                        RaidTotals.TotalSeconds = RaidTotals.MaxTime = RaidTotals.Ranges.GetTotal();

                        int    rangeIndex = 0;
                        double lastTime   = 0;
                        var    newBlock   = new List <ActionBlock>();
                        damageBlocks.ForEach(block =>
                        {
                            if (RaidTotals.Ranges.TimeSegments.Count > rangeIndex && block.BeginTime > RaidTotals.Ranges.TimeSegments[rangeIndex].EndTime)
                            {
                                rangeIndex++;

                                if (newBlock.Count > 0)
                                {
                                    TankingGroups.Add(newBlock);
                                }

                                newBlock = new List <ActionBlock>();
                            }

                            if (lastTime != block.BeginTime)
                            {
                                var copy = new ActionBlock();
                                copy.Actions.AddRange(block.Actions);
                                copy.BeginTime = block.BeginTime;
                                newBlock.Add(copy);
                            }
                            else
                            {
                                newBlock.Last().Actions.AddRange(block.Actions);
                            }
                        });

                        TankingGroups.Add(newBlock);
                        ComputeTankingStats(options);
                    }
                    else if (Selected == null || Selected.Count == 0)
                    {
                        FireNoDataEvent(options, "NONPC");
                    }
                    else
                    {
                        FireNoDataEvent(options, "NODATA");
                    }
                }
                catch (Exception ex)
                {
                    LOG.Error(ex);
                }
            }
        }
Пример #3
0
        internal void BuildTotalStats(GenerateStatsOptions options)
        {
            lock (TankingGroups)
            {
                try
                {
                    FireNewStatsEvent(options);
                    Reset();

                    Selected = options.Npcs;
                    Title    = options.Name;
                    var damageBlocks = new List <ActionBlock>();

                    Selected.ForEach(fight =>
                    {
                        damageBlocks.AddRange(fight.TankingBlocks);
                        RaidTotals.Ranges.Add(new TimeSegment(fight.BeginTankingTime, fight.LastTankingTime));
                        StatsUtil.UpdateRaidTimeRanges(fight, PlayerTimeRanges, PlayerSubTimeRanges, true);
                    });

                    damageBlocks.Sort((a, b) => a.BeginTime.CompareTo(b.BeginTime));

                    if (damageBlocks.Count > 0)
                    {
                        RaidTotals.TotalSeconds = RaidTotals.MaxTime = RaidTotals.Ranges.GetTotal();

                        int    rangeIndex = 0;
                        double lastTime   = 0;
                        var    newBlock   = new List <ActionBlock>();
                        damageBlocks.ForEach(block =>
                        {
                            if (RaidTotals.Ranges.TimeSegments.Count > rangeIndex && block.BeginTime > RaidTotals.Ranges.TimeSegments[rangeIndex].EndTime)
                            {
                                rangeIndex++;

                                if (newBlock.Count > 0)
                                {
                                    TankingGroups.Add(newBlock);
                                }

                                newBlock = new List <ActionBlock>();
                            }

                            if (lastTime != block.BeginTime)
                            {
                                var copy = new ActionBlock();
                                copy.Actions.AddRange(block.Actions);
                                copy.BeginTime = block.BeginTime;
                                newBlock.Add(copy);
                            }
                            else
                            {
                                newBlock.Last().Actions.AddRange(block.Actions);
                            }
                        });

                        TankingGroups.Add(newBlock);
                        ComputeTankingStats(options);
                    }
                    else if (Selected == null || Selected.Count == 0)
                    {
                        FireNoDataEvent(options, "NONPC");
                    }
                    else
                    {
                        FireNoDataEvent(options, "NODATA");
                    }
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception ex)
#pragma warning restore CA1031 // Do not catch general exception types
                {
                    if (ex is ArgumentNullException || ex is NullReferenceException || ex is ArgumentOutOfRangeException || ex is ArgumentException || ex is OutOfMemoryException)
                    {
                        LOG.Error(ex);
                    }
                }
            }
        }