internal static Dictionary <long, FinalPlayerBuffs>[] GetBuffsForPlayers(List <Player> playerList, ParsedEvtcLog log, AgentItem agentItem, long start, long end)
        {
            long phaseDuration = end - start;

            var buffDistribution = new Dictionary <Player, BuffDistribution>();

            foreach (Player p in playerList)
            {
                buffDistribution[p] = p.GetBuffDistribution(log, start, end);
            }

            var buffsToTrack = new HashSet <Buff>(buffDistribution.SelectMany(x => x.Value.BuffIDs).Select(x => log.Buffs.BuffsByIds[x]));

            var buffs =
                new Dictionary <long, FinalPlayerBuffs>();
            var activeBuffs =
                new Dictionary <long, FinalPlayerBuffs>();

            foreach (Buff boon in buffsToTrack)
            {
                double totalGeneration       = 0;
                double totalOverstack        = 0;
                double totalWasted           = 0;
                double totalUnknownExtension = 0;
                double totalExtension        = 0;
                double totalExtended         = 0;
                //
                double totalActiveGeneration       = 0;
                double totalActiveOverstack        = 0;
                double totalActiveWasted           = 0;
                double totalActiveUnknownExtension = 0;
                double totalActiveExtension        = 0;
                double totalActiveExtended         = 0;
                bool   hasGeneration     = false;
                int    activePlayerCount = 0;
                foreach (KeyValuePair <Player, BuffDistribution> pair in buffDistribution)
                {
                    BuffDistribution boons = pair.Value;
                    long             playerActiveDuration = pair.Key.GetActiveDuration(log, start, end);
                    if (boons.HasBuffID(boon.ID))
                    {
                        hasGeneration = hasGeneration || boons.HasSrc(boon.ID, agentItem);
                        double generation       = boons.GetGeneration(boon.ID, agentItem);
                        double overstack        = boons.GetOverstack(boon.ID, agentItem);
                        double wasted           = boons.GetWaste(boon.ID, agentItem);
                        double unknownExtension = boons.GetUnknownExtension(boon.ID, agentItem);
                        double extension        = boons.GetExtension(boon.ID, agentItem);
                        double extended         = boons.GetExtended(boon.ID, agentItem);

                        totalGeneration       += generation;
                        totalOverstack        += overstack;
                        totalWasted           += wasted;
                        totalUnknownExtension += unknownExtension;
                        totalExtension        += extension;
                        totalExtended         += extended;
                        if (playerActiveDuration > 0)
                        {
                            activePlayerCount++;
                            totalActiveGeneration       += generation / playerActiveDuration;
                            totalActiveOverstack        += overstack / playerActiveDuration;
                            totalActiveWasted           += wasted / playerActiveDuration;
                            totalActiveUnknownExtension += unknownExtension / playerActiveDuration;
                            totalActiveExtension        += extension / playerActiveDuration;
                            totalActiveExtended         += extended / playerActiveDuration;
                        }
                    }
                }
                totalGeneration       /= phaseDuration;
                totalOverstack        /= phaseDuration;
                totalWasted           /= phaseDuration;
                totalUnknownExtension /= phaseDuration;
                totalExtension        /= phaseDuration;
                totalExtended         /= phaseDuration;

                if (hasGeneration)
                {
                    var uptime       = new FinalPlayerBuffs();
                    var uptimeActive = new FinalPlayerBuffs();
                    buffs[boon.ID]       = uptime;
                    activeBuffs[boon.ID] = uptimeActive;
                    if (boon.Type == BuffType.Duration)
                    {
                        uptime.Generation      = Math.Round(100.0 * totalGeneration / playerList.Count, ParserHelper.BuffDigit);
                        uptime.Overstack       = Math.Round(100.0 * (totalOverstack + totalGeneration) / playerList.Count, ParserHelper.BuffDigit);
                        uptime.Wasted          = Math.Round(100.0 * (totalWasted) / playerList.Count, ParserHelper.BuffDigit);
                        uptime.UnknownExtended = Math.Round(100.0 * (totalUnknownExtension) / playerList.Count, ParserHelper.BuffDigit);
                        uptime.ByExtension     = Math.Round(100.0 * (totalExtension) / playerList.Count, ParserHelper.BuffDigit);
                        uptime.Extended        = Math.Round(100.0 * (totalExtended) / playerList.Count, ParserHelper.BuffDigit);
                        //
                        if (activePlayerCount > 0)
                        {
                            uptimeActive.Generation      = Math.Round(100.0 * totalActiveGeneration / activePlayerCount, ParserHelper.BuffDigit);
                            uptimeActive.Overstack       = Math.Round(100.0 * (totalActiveOverstack + totalActiveGeneration) / activePlayerCount, ParserHelper.BuffDigit);
                            uptimeActive.Wasted          = Math.Round(100.0 * (totalActiveWasted) / activePlayerCount, ParserHelper.BuffDigit);
                            uptimeActive.UnknownExtended = Math.Round(100.0 * (totalActiveUnknownExtension) / activePlayerCount, ParserHelper.BuffDigit);
                            uptimeActive.ByExtension     = Math.Round(100.0 * (totalActiveExtension) / activePlayerCount, ParserHelper.BuffDigit);
                            uptimeActive.Extended        = Math.Round(100.0 * (totalActiveExtended) / activePlayerCount, ParserHelper.BuffDigit);
                        }
                    }
                    else if (boon.Type == BuffType.Intensity)
                    {
                        uptime.Generation      = Math.Round(totalGeneration / playerList.Count, ParserHelper.BuffDigit);
                        uptime.Overstack       = Math.Round((totalOverstack + totalGeneration) / playerList.Count, ParserHelper.BuffDigit);
                        uptime.Wasted          = Math.Round((totalWasted) / playerList.Count, ParserHelper.BuffDigit);
                        uptime.UnknownExtended = Math.Round((totalUnknownExtension) / playerList.Count, ParserHelper.BuffDigit);
                        uptime.ByExtension     = Math.Round((totalExtension) / playerList.Count, ParserHelper.BuffDigit);
                        uptime.Extended        = Math.Round((totalExtended) / playerList.Count, ParserHelper.BuffDigit);
                        //
                        if (activePlayerCount > 0)
                        {
                            uptimeActive.Generation      = Math.Round(totalActiveGeneration / activePlayerCount, ParserHelper.BuffDigit);
                            uptimeActive.Overstack       = Math.Round((totalActiveOverstack + totalActiveGeneration) / activePlayerCount, ParserHelper.BuffDigit);
                            uptimeActive.Wasted          = Math.Round((totalActiveWasted) / activePlayerCount, ParserHelper.BuffDigit);
                            uptimeActive.UnknownExtended = Math.Round((totalActiveUnknownExtension) / activePlayerCount, ParserHelper.BuffDigit);
                            uptimeActive.ByExtension     = Math.Round((totalActiveExtension) / activePlayerCount, ParserHelper.BuffDigit);
                            uptimeActive.Extended        = Math.Round((totalActiveExtended) / activePlayerCount, ParserHelper.BuffDigit);
                        }
                    }
                }
            }

            return(new Dictionary <long, FinalPlayerBuffs>[] { buffs, activeBuffs });
        }
Example #2
0
        internal static (List <Dictionary <long, FinalPlayerBuffs> >, List <Dictionary <long, FinalPlayerBuffs> >) GetBuffsForPlayers(List <Player> playerList, ParsedEvtcLog log, AgentItem agentItem)
        {
            var uptimesByPhase       = new List <Dictionary <long, FinalPlayerBuffs> >();
            var uptimesActiveByPhase = new List <Dictionary <long, FinalPlayerBuffs> >();

            List <PhaseData> phases = log.FightData.GetPhases(log);

            for (int phaseIndex = 0; phaseIndex < phases.Count; phaseIndex++)
            {
                PhaseData phase         = phases[phaseIndex];
                long      phaseDuration = phase.DurationInMS;

                var boonDistributions = new Dictionary <Player, BuffDistribution>();
                foreach (Player p in playerList)
                {
                    boonDistributions[p] = p.GetBuffDistribution(log, phaseIndex);
                }

                var boonsToTrack = new HashSet <Buff>(boonDistributions.SelectMany(x => x.Value).Select(x => log.Buffs.BuffsByIds[x.Key]));

                var final =
                    new Dictionary <long, FinalPlayerBuffs>();
                var finalActive =
                    new Dictionary <long, FinalPlayerBuffs>();

                foreach (Buff boon in boonsToTrack)
                {
                    double totalGeneration       = 0;
                    double totalOverstack        = 0;
                    double totalWasted           = 0;
                    double totalUnknownExtension = 0;
                    double totalExtension        = 0;
                    double totalExtended         = 0;
                    //
                    double totalActiveGeneration       = 0;
                    double totalActiveOverstack        = 0;
                    double totalActiveWasted           = 0;
                    double totalActiveUnknownExtension = 0;
                    double totalActiveExtension        = 0;
                    double totalActiveExtended         = 0;
                    bool   hasGeneration     = false;
                    int    activePlayerCount = 0;
                    foreach (KeyValuePair <Player, BuffDistribution> pair in boonDistributions)
                    {
                        BuffDistribution boons = pair.Value;
                        long             playerActiveDuration = phase.GetActorActiveDuration(pair.Key, log);
                        if (boons.ContainsKey(boon.ID))
                        {
                            hasGeneration = hasGeneration || boons.HasSrc(boon.ID, agentItem);
                            double generation       = boons.GetGeneration(boon.ID, agentItem);
                            double overstack        = boons.GetOverstack(boon.ID, agentItem);
                            double wasted           = boons.GetWaste(boon.ID, agentItem);
                            double unknownExtension = boons.GetUnknownExtension(boon.ID, agentItem);
                            double extension        = boons.GetExtension(boon.ID, agentItem);
                            double extended         = boons.GetExtended(boon.ID, agentItem);

                            totalGeneration       += generation;
                            totalOverstack        += overstack;
                            totalWasted           += wasted;
                            totalUnknownExtension += unknownExtension;
                            totalExtension        += extension;
                            totalExtended         += extended;
                            if (playerActiveDuration > 0)
                            {
                                activePlayerCount++;
                                totalActiveGeneration       += generation / playerActiveDuration;
                                totalActiveOverstack        += overstack / playerActiveDuration;
                                totalActiveWasted           += wasted / playerActiveDuration;
                                totalActiveUnknownExtension += unknownExtension / playerActiveDuration;
                                totalActiveExtension        += extension / playerActiveDuration;
                                totalActiveExtended         += extended / playerActiveDuration;
                            }
                        }
                    }
                    totalGeneration       /= phaseDuration;
                    totalOverstack        /= phaseDuration;
                    totalWasted           /= phaseDuration;
                    totalUnknownExtension /= phaseDuration;
                    totalExtension        /= phaseDuration;
                    totalExtended         /= phaseDuration;

                    if (hasGeneration)
                    {
                        var uptime       = new FinalPlayerBuffs();
                        var uptimeActive = new FinalPlayerBuffs();
                        final[boon.ID]       = uptime;
                        finalActive[boon.ID] = uptimeActive;
                        if (boon.Type == BuffType.Duration)
                        {
                            uptime.Generation      = Math.Round(100.0 * totalGeneration / playerList.Count, ParserHelper.BuffDigit);
                            uptime.Overstack       = Math.Round(100.0 * (totalOverstack + totalGeneration) / playerList.Count, ParserHelper.BuffDigit);
                            uptime.Wasted          = Math.Round(100.0 * (totalWasted) / playerList.Count, ParserHelper.BuffDigit);
                            uptime.UnknownExtended = Math.Round(100.0 * (totalUnknownExtension) / playerList.Count, ParserHelper.BuffDigit);
                            uptime.ByExtension     = Math.Round(100.0 * (totalExtension) / playerList.Count, ParserHelper.BuffDigit);
                            uptime.Extended        = Math.Round(100.0 * (totalExtended) / playerList.Count, ParserHelper.BuffDigit);
                            //
                            if (activePlayerCount > 0)
                            {
                                uptimeActive.Generation      = Math.Round(100.0 * totalActiveGeneration / activePlayerCount, ParserHelper.BuffDigit);
                                uptimeActive.Overstack       = Math.Round(100.0 * (totalActiveOverstack + totalActiveGeneration) / activePlayerCount, ParserHelper.BuffDigit);
                                uptimeActive.Wasted          = Math.Round(100.0 * (totalActiveWasted) / activePlayerCount, ParserHelper.BuffDigit);
                                uptimeActive.UnknownExtended = Math.Round(100.0 * (totalActiveUnknownExtension) / activePlayerCount, ParserHelper.BuffDigit);
                                uptimeActive.ByExtension     = Math.Round(100.0 * (totalActiveExtension) / activePlayerCount, ParserHelper.BuffDigit);
                                uptimeActive.Extended        = Math.Round(100.0 * (totalActiveExtended) / activePlayerCount, ParserHelper.BuffDigit);
                            }
                        }
                        else if (boon.Type == BuffType.Intensity)
                        {
                            uptime.Generation      = Math.Round(totalGeneration / playerList.Count, ParserHelper.BuffDigit);
                            uptime.Overstack       = Math.Round((totalOverstack + totalGeneration) / playerList.Count, ParserHelper.BuffDigit);
                            uptime.Wasted          = Math.Round((totalWasted) / playerList.Count, ParserHelper.BuffDigit);
                            uptime.UnknownExtended = Math.Round((totalUnknownExtension) / playerList.Count, ParserHelper.BuffDigit);
                            uptime.ByExtension     = Math.Round((totalExtension) / playerList.Count, ParserHelper.BuffDigit);
                            uptime.Extended        = Math.Round((totalExtended) / playerList.Count, ParserHelper.BuffDigit);
                            //
                            if (activePlayerCount > 0)
                            {
                                uptimeActive.Generation      = Math.Round(totalActiveGeneration / activePlayerCount, ParserHelper.BuffDigit);
                                uptimeActive.Overstack       = Math.Round((totalActiveOverstack + totalActiveGeneration) / activePlayerCount, ParserHelper.BuffDigit);
                                uptimeActive.Wasted          = Math.Round((totalActiveWasted) / activePlayerCount, ParserHelper.BuffDigit);
                                uptimeActive.UnknownExtended = Math.Round((totalActiveUnknownExtension) / activePlayerCount, ParserHelper.BuffDigit);
                                uptimeActive.ByExtension     = Math.Round((totalActiveExtension) / activePlayerCount, ParserHelper.BuffDigit);
                                uptimeActive.Extended        = Math.Round((totalActiveExtended) / activePlayerCount, ParserHelper.BuffDigit);
                            }
                        }
                    }
                }

                uptimesByPhase.Add(final);
                uptimesActiveByPhase.Add(finalActive);
            }

            return(uptimesByPhase, uptimesActiveByPhase);
        }