private void AddToList(PlayerStats playerStats, List <PlayerSubStats> list, List <PlayerSubStats> additionalStats)
 {
     additionalStats.ForEach(stats =>
     {
         if (list.Find(item => item.Name == stats.Name) is PlayerSubStats found)
         {
             var combined = new PlayerSubStats()
             {
                 Name = found.Name
             };
             StatsUtil.MergeStats(combined, found);
             StatsUtil.MergeStats(combined, stats);
             StatsUtil.CalculateRates(combined, RaidStats, playerStats);
             list.Remove(found);
             list.Add(combined);
         }
         else
         {
             list.Add(stats);
         }
     });
 }
        private void BuildGroups(PlayerStats playerStats, List <PlayerSubStats> all)
        {
            List <PlayerSubStats> list = new List <PlayerSubStats>();
            PlayerSubStats        dots = new PlayerSubStats()
            {
                Name = Labels.DOT, Type = Labels.DOT
            };
            PlayerSubStats dds = new PlayerSubStats()
            {
                Name = Labels.DD, Type = Labels.DD
            };
            PlayerSubStats procs = new PlayerSubStats()
            {
                Name = Labels.PROC, Type = Labels.PROC
            };
            PlayerSubStats resisted = new PlayerSubStats()
            {
                Name = Labels.RESIST, Type = Labels.RESIST, ResistRate = 100
            };
            List <PlayerSubStats> allDots     = new List <PlayerSubStats>();
            List <PlayerSubStats> allDds      = new List <PlayerSubStats>();
            List <PlayerSubStats> allProcs    = new List <PlayerSubStats>();
            List <PlayerSubStats> allResisted = new List <PlayerSubStats>();

            all.ForEach(sub =>
            {
                PlayerSubStats stats = null;

                switch (sub.Type)
                {
                case Labels.DOT:
                    stats = dots;
                    allDots.Add(sub);
                    break;

                case Labels.DD:
                case Labels.BANE:
                    stats = dds;
                    allDds.Add(sub);
                    break;

                case Labels.PROC:
                    stats = procs;
                    allProcs.Add(sub);
                    break;

                case Labels.RESIST:
                    stats = resisted;
                    allResisted.Add(sub);
                    break;

                default:
                    list.Add(sub);
                    break;
                }

                StatsUtil.MergeStats(stats, sub);
            });

            foreach (var stats in new PlayerSubStats[] { dots, dds, procs, resisted })
            {
                StatsUtil.CalculateRates(stats, RaidStats, playerStats);
            }

            UnGroupedDD[playerStats.Name]       = allDds;
            UnGroupedDoT[playerStats.Name]      = allDots;
            UnGroupedProcs[playerStats.Name]    = allProcs;
            UnGroupedResisted[playerStats.Name] = allResisted;
            GroupedDD[playerStats.Name]         = dds;
            GroupedDoT[playerStats.Name]        = dots;
            GroupedProcs[playerStats.Name]      = procs;
            GroupedResisted[playerStats.Name]   = resisted;
            OtherDamage[playerStats.Name]       = list;

            Dispatcher.InvokeAsync(() =>
            {
                if (allDds.Count > 0 && !groupDirectDamage.IsEnabled)
                {
                    groupDirectDamage.IsEnabled = true;
                }

                if (allProcs.Count > 0 && !groupProcs.IsEnabled)
                {
                    groupProcs.IsEnabled = true;
                }

                if (allDots.Count > 0 && !groupDoT.IsEnabled)
                {
                    groupDoT.IsEnabled = true;
                }

                if (allResisted.Count > 0 && !groupResisted.IsEnabled)
                {
                    groupResisted.IsEnabled = true;
                }
            });
        }