Example #1
0
        private void ProcessCuring(KPDatabaseDataSet dataSet, MobFilter mobFilter,
                                   bool displayCures, bool displayAvgCures,
                                   ref StringBuilder sb, List <StringMods> strModList)
        {
            // linq query to get the basic rows with healing
            var uberHealing = from c in dataSet.Combatants
                              where (((EntityType)c.CombatantType == EntityType.Player) ||
                                     ((EntityType)c.CombatantType == EntityType.Pet) ||
                                     ((EntityType)c.CombatantType == EntityType.Fellow))
                              orderby c.CombatantType, c.CombatantName
                select new
            {
                Player  = c.CombatantNameOrJobName,
                Healing = from h in c.GetInteractionsRowsByActorCombatantRelation()
                          where mobFilter.CheckFilterMobBattle(h) &&
                          h.IsActionIDNull() == false &&
                          ((AidType)h.AidType == AidType.Recovery ||
                           (AidType)h.AidType == AidType.Enhance)
                          select h
            };

            int cureSpell = 0;
            int cureAbil  = 0;
            int numCure1  = 0;
            int numCure2  = 0;
            int numCure3  = 0;
            int numCure4  = 0;
            int numCure5  = 0;
            int numCure6  = 0;
            int numCuraga = 0;
            int numRegen1 = 0;
            int numRegen2 = 0;
            int numRegen3 = 0;
            int numRegen4 = 0;

            double avgC1 = 0;
            double avgC2 = 0;
            double avgC3 = 0;
            double avgC4 = 0;
            double avgC5 = 0;
            double avgC6 = 0;
            double avgCg = 0;
            double avgAb = 0;

            bool placeHeader = false;

            if (uberHealing.Any())
            {
                if (displayCures == true)
                {
                    StringBuilder costsSB2 = new StringBuilder();

                    foreach (var healer in uberHealing)
                    {
                        var healLU = healer.Healing.ToLookup(a => a.ActionsRow.ActionName);

                        numCure1 = healLU[lsCure1].Count() +
                                   healLU[lsPollen].Count() +
                                   healLU[lsHealingBreath1].Count();
                        numCure2 = healLU[lsCure2].Count() +
                                   healLU[lsCWaltz1].Count() +
                                   healLU[lsHealingBreath2].Count();
                        numCure3 = healLU[lsCure3].Count() +
                                   healLU[lsCWaltz2].Count() +
                                   healLU[lsHealingBreath3].Count()
                                   + healLU[lsWildCarrot].Count();
                        numCure4 = healLU[lsCure4].Count() +
                                   healLU[lsCWaltz3].Count() +
                                   healLU[lsMagicFruit].Count();
                        numCure5 = healLU[lsCure5].Count() +
                                   healLU[lsCWaltz4].Count();
                        numCure6 = healLU[lsCure6].Count() +
                                   healLU[lsCWaltz5].Count();
                        numCuraga = healLU[lsHealingBreeze].GroupBy(a => a.Timestamp).Count() +
                                    healLU[lsDivineWaltz1].GroupBy(a => a.Timestamp).Count() +
                                    healLU[lsDivineWaltz2].GroupBy(a => a.Timestamp).Count() +
                                    healLU[lsCura1].GroupBy(a => a.Timestamp).Count() +
                                    healLU[lsCura2].GroupBy(a => a.Timestamp).Count() +
                                    healLU[lsCuraga1].GroupBy(a => a.Timestamp).Count() +
                                    healLU[lsCuraga2].GroupBy(a => a.Timestamp).Count() +
                                    healLU[lsCuraga3].GroupBy(a => a.Timestamp).Count() +
                                    healLU[lsCuraga4].GroupBy(a => a.Timestamp).Count();
                        numRegen1 = healLU[lsRegen1].Count();
                        numRegen2 = healLU[lsRegen2].Count();
                        numRegen3 = healLU[lsRegen3].Count();
                        numRegen4 = healLU[lsRegen4].Count();

                        var cures = healer.Healing.Where(a => (AidType)a.AidType == AidType.Recovery &&
                                                         (RecoveryType)a.RecoveryType == RecoveryType.RecoverHP);

                        var spellCures = cures.Where(a => (ActionType)a.ActionType == ActionType.Spell);
                        var abilCures  = cures.Where(a => (ActionType)a.ActionType == ActionType.Ability);

                        cureSpell = spellCures.Sum(a => a.Amount);
                        cureAbil  = abilCures.Sum(a => a.Amount);

                        if ((cureSpell + cureAbil +
                             numCure1 + numCure2 + numCure3 + numCure4 + numCure5 + numCure6 +
                             numRegen1 + numRegen2 + numRegen3 + numRegen4 + numCuraga) > 0)
                        {
                            if (placeHeader == false)
                            {
                                strModList.Add(new StringMods
                                {
                                    Start  = sb.Length,
                                    Length = lsTitleCuring.Length,
                                    Bold   = true,
                                    Color  = Color.Red
                                });
                                sb.Append(lsTitleCuring + "\n\n");

                                strModList.Add(new StringMods
                                {
                                    Start     = sb.Length,
                                    Length    = lsHeaderCuring.Length,
                                    Bold      = true,
                                    Underline = true,
                                    Color     = Color.Black
                                });
                                sb.Append(lsHeaderCuring + "\n");

                                placeHeader = true;
                            }

                            sb.AppendFormat(lsFormatCuring,
                                            healer.Player,
                                            cureSpell,
                                            cureAbil,
                                            numCure1,
                                            numCure2,
                                            numCure3,
                                            numCure4,
                                            numCure5,
                                            numCure6,
                                            numCuraga,
                                            numRegen1,
                                            numRegen2,
                                            numRegen3,
                                            numRegen4);

                            sb.Append("\n");


                            // Costs of curing (generate text for this during this loop)
                            int totalMP = 0;

                            totalMP += healLU[lsCure1].Count() * 8;
                            totalMP += healLU[lsCure2].Count() * 24;
                            totalMP += healLU[lsCure3].Count() * 46;
                            totalMP += healLU[lsCure4].Count() * 88;
                            totalMP += healLU[lsCure5].Count() * 135;
                            totalMP += healLU[lsCure6].Count() * 227;
                            totalMP += healLU[lsPollen].Count() * 8;
                            totalMP += healLU[lsWildCarrot].Count() * 37;
                            totalMP += healLU[lsMagicFruit].Count() * 72;
                            totalMP += healLU[lsHealingBreeze].Count() * 55;
                            totalMP += healLU[lsCura1].Count() * 30;
                            totalMP += healLU[lsCura2].Count() * 60;
                            totalMP += healLU[lsCuraga1].GroupBy(a => a.Timestamp).Count() * 60;
                            totalMP += healLU[lsCuraga2].GroupBy(a => a.Timestamp).Count() * 120;
                            totalMP += healLU[lsCuraga3].GroupBy(a => a.Timestamp).Count() * 180;
                            totalMP += healLU[lsCuraga4].GroupBy(a => a.Timestamp).Count() * 260;

                            int regenCost = 0;
                            regenCost += numRegen1 * 15;
                            regenCost += numRegen2 * 36;
                            regenCost += numRegen3 * 64;
                            regenCost += numRegen4 * 82;

                            totalMP += regenCost;

                            int totalTP = 0;
                            totalTP += healLU[lsCWaltz1].Count() * 20;
                            totalTP += healLU[lsCWaltz2].Count() * 35;
                            totalTP += healLU[lsCWaltz3].Count() * 50;
                            totalTP += healLU[lsCWaltz4].Count() * 65;
                            totalTP += healLU[lsCWaltz5].Count() * 80;
                            totalTP += healLU[lsDivineWaltz1].Count() * 40;
                            totalTP += healLU[lsDivineWaltz2].Count() * 80;


                            float mpCureEff    = 0;
                            float mpCureRegEff = 0;
                            float tpCureEff    = 0;

                            if (totalMP > 0)
                            {
                                if (totalMP > regenCost)
                                {
                                    mpCureEff = (float)cureSpell / (totalMP - regenCost);
                                }
                                else
                                {
                                    mpCureEff = 0;
                                }

                                int curesWithRegen = cureSpell +
                                                     numRegen1 * 125 +
                                                     numRegen2 * 240 +
                                                     numRegen3 * 400 +
                                                     numRegen4 * 600;

                                mpCureRegEff = (float)curesWithRegen / totalMP;
                            }

                            if (totalTP > 0)
                            {
                                int tpCures = cureAbil - healLU[lsChakra].Sum(a => a.Amount);
                                tpCureEff = (float)tpCures / totalTP;
                            }

                            if ((totalMP > 0) || (totalTP > 0))
                            {
                                costsSB2.AppendFormat(lsFormatCuringCost,
                                                      healer.Player,
                                                      totalMP,
                                                      mpCureEff,
                                                      mpCureRegEff,
                                                      totalTP,
                                                      tpCureEff);

                                costsSB2.Append("\n");
                            }
                        }
                    }


                    // Insert costs calculations into the text stream here
                    if (placeHeader)
                    {
                        sb.Append("\n\n");

                        strModList.Add(new StringMods
                        {
                            Start  = sb.Length,
                            Length = lsTitleCuringCost.Length,
                            Bold   = true,
                            Color  = Color.Blue
                        });
                        sb.Append(lsTitleCuringCost + "\n\n");

                        strModList.Add(new StringMods
                        {
                            Start     = sb.Length,
                            Length    = lsHeaderCuringCost.Length,
                            Bold      = true,
                            Underline = true,
                            Color     = Color.Black
                        });
                        sb.Append(lsHeaderCuringCost + "\n");

                        sb.Append(costsSB2.ToString());

                        sb.Append("\n\n");
                    }
                }

                if (displayAvgCures == true)
                {
                    placeHeader = false;

                    foreach (var healer in uberHealing)
                    {
                        var healLU = healer.Healing.ToLookup(a => a.ActionsRow.ActionName);

                        avgCg = 0;
                        avgAb = 0;

                        avgC1 = healLU[lsCure1].Concat(healLU[lsPollen]).Concat(healLU[lsHealingBreath1])
                                .Average(a => (int?)a.Amount) ?? 0.0;

                        avgC2 = healLU[lsCure2].Concat(healLU[lsHealingBreath2]).Concat(healLU[lsCWaltz1])
                                .Average(a => (int?)a.Amount) ?? 0.0;

                        avgC3 = healLU[lsCure3].Concat(healLU[lsHealingBreath3]).Concat(healLU[lsCWaltz2]).Concat(healLU[lsWildCarrot])
                                .Average(a => (int?)a.Amount) ?? 0.0;

                        avgC4 = healLU[lsCure4].Concat(healLU[lsMagicFruit]).Concat(healLU[lsCWaltz3])
                                .Average(a => (int?)a.Amount) ?? 0.0;

                        avgC5 = healLU[lsCure5].Concat(healLU[lsCWaltz4])
                                .Average(a => (int?)a.Amount) ?? 0.0;

                        avgC6 = healLU[lsCure6].Average(a => (int?)a.Amount) ?? 0.0;


                        avgCg = healLU[lsCura1].GroupBy(a => a.Timestamp)
                                .Concat(healLU[lsCura2].GroupBy(a => a.Timestamp))
                                .Concat(healLU[lsCuraga1].GroupBy(a => a.Timestamp))
                                .Concat(healLU[lsCuraga2].GroupBy(a => a.Timestamp))
                                .Concat(healLU[lsCuraga3].GroupBy(a => a.Timestamp))
                                .Concat(healLU[lsCuraga4].GroupBy(a => a.Timestamp))
                                .Concat(healLU[lsDivineWaltz1].GroupBy(a => a.Timestamp))
                                .Concat(healLU[lsDivineWaltz2].GroupBy(a => a.Timestamp))
                                .Concat(healLU[lsHealingBreeze].GroupBy(a => a.Timestamp))
                                .Average(a => a.Sum(b => (int?)b.Amount)) ?? 0.0;

                        avgAb = healLU[lsChakra]
                                .Average(a => (int?)a.Amount) ?? 0.0;


                        if ((avgAb + avgC1 + avgC2 + avgC3 + avgC4 + avgC5 + avgC6 + avgCg) > 0)
                        {
                            if (placeHeader == false)
                            {
                                strModList.Add(new StringMods
                                {
                                    Start  = sb.Length,
                                    Length = lsTitleAvgCuring.Length,
                                    Bold   = true,
                                    Color  = Color.Red
                                });
                                sb.Append(lsTitleAvgCuring + "\n\n");

                                strModList.Add(new StringMods
                                {
                                    Start     = sb.Length,
                                    Length    = lsHeaderAvgCuring.Length,
                                    Bold      = true,
                                    Underline = true,
                                    Color     = Color.Black
                                });
                                sb.Append(lsHeaderAvgCuring + "\n");

                                placeHeader = true;
                            }


                            sb.AppendFormat(lsFormatAvgCuring,
                                            healer.Player,
                                            avgC1,
                                            avgC2,
                                            avgC3,
                                            avgC4,
                                            avgC5,
                                            avgC6,
                                            avgCg,
                                            avgAb);

                            sb.Append("\n");
                        }
                    }

                    if (placeHeader)
                    {
                        sb.Append("\n\n");
                    }
                }
            }
        }
Example #2
0
        private void ProcessStatusCured(KPDatabaseDataSet dataSet, MobFilter mobFilter,
                                        ref StringBuilder sb, List <StringMods> strModList)
        {
            var statusHealing = from c in dataSet.Combatants
                                where (((EntityType)c.CombatantType == EntityType.Player) ||
                                       ((EntityType)c.CombatantType == EntityType.Pet) ||
                                       ((EntityType)c.CombatantType == EntityType.Fellow))
                                orderby c.CombatantType, c.CombatantName
            let targetInteractions = c.GetInteractionsRowsByTargetCombatantRelation().Where(a => mobFilter.CheckFilterMobBattle(a))
                                     select new
            {
                Player         = c.CombatantNameOrJobName,
                StatusRemovals = from cr in targetInteractions
                                 where ((AidType)cr.AidType == AidType.RemoveStatus) &&
                                 (cr.IsActionIDNull() == false)
                                 group cr by cr.ActionsRow.ActionName
            };

            bool placeHeader = false;

            foreach (var player in statusHealing)
            {
                if (player.StatusRemovals.Any())
                {
                    if (placeHeader == false)
                    {
                        strModList.Add(new StringMods
                        {
                            Start  = sb.Length,
                            Length = lsTitleStatusCured.Length,
                            Bold   = true,
                            Color  = Color.Red
                        });
                        sb.Append(lsTitleStatusCured + "\n\n");

                        placeHeader = true;
                    }

                    strModList.Add(new StringMods
                    {
                        Start  = sb.Length,
                        Length = player.Player.Length,
                        Bold   = true,
                        Color  = Color.Blue
                    });
                    sb.Append(player.Player + "\n");

                    strModList.Add(new StringMods
                    {
                        Start     = sb.Length,
                        Length    = lsHeaderStatusCuring.Length,
                        Bold      = true,
                        Underline = true,
                        Color     = Color.Black
                    });
                    sb.Append(lsHeaderStatusCuring + "\n");


                    foreach (var statusSpell in player.StatusRemovals)
                    {
                        int spellUsed     = statusSpell.Count();
                        int spellNoEffect = statusSpell.Count(a => (FailedActionType)a.FailedActionType
                                                              == FailedActionType.NoEffect);

                        sb.AppendFormat(lsFormatStatusCuring,
                                        statusSpell.Key,
                                        spellUsed,
                                        spellNoEffect);
                        sb.Append("\n");

                        var effects = statusSpell.GroupBy(a =>
                                                          a.IsSecondActionIDNull() ? "-unknown-" :
                                                          a.ActionsRowBySecondaryActionNameRelation.ActionName);

                        foreach (var effect in effects)
                        {
                            if (effect.Key != "-unknown-")
                            {
                                sb.AppendFormat(lsFormatStatusCuringSub,
                                                effect.Key,
                                                effect.Count());
                                sb.Append("\n");
                            }
                        }
                    }

                    sb.Append("\n");
                }
            }
        }
Example #3
0
        private void ProcessDamage(KPDatabaseDataSet dataSet, MobFilter mobFilter,
                                   ref StringBuilder sb, List <StringMods> strModList)
        {
            var playerData = from c in dataSet.Combatants
                             where (((EntityType)c.CombatantType == EntityType.Player) ||
                                    ((EntityType)c.CombatantType == EntityType.Pet) ||
                                    ((EntityType)c.CombatantType == EntityType.CharmedMob) ||
                                    ((EntityType)c.CombatantType == EntityType.Fellow))
                             orderby c.CombatantType, c.CombatantName
            let targetInteractions = c.GetInteractionsRowsByTargetCombatantRelation().Where(a => mobFilter.CheckFilterMobBattle(a))
                                     let actorInteractions = c.GetInteractionsRowsByActorCombatantRelation().Where(a => mobFilter.CheckFilterMobBattle(a))
                                                             select new
            {
                Player        = c.CombatantNameOrJobName,
                PrimeDmgTaken = from dm in targetInteractions
                                where (((HarmType)dm.HarmType == HarmType.Damage) ||
                                       ((HarmType)dm.HarmType == HarmType.Drain))
                                select dm.Amount,
                SecondDmgTaken = from dm in targetInteractions
                                 where (((HarmType)dm.SecondHarmType == HarmType.Damage) ||
                                        ((HarmType)dm.SecondHarmType == HarmType.Drain))
                                 select dm.SecondAmount,
                PrimeDrain = from dr in actorInteractions
                             where ((HarmType)dr.HarmType == HarmType.Drain) &&
                             mobFilter.CheckFilterMobBattle(dr)
                             select dr.Amount,
                SecondDrain = from dr in actorInteractions
                              where (((HarmType)dr.SecondHarmType == HarmType.Drain) ||
                                     ((AidType)dr.SecondAidType == AidType.Recovery))
                              select dr.SecondAmount,
                Cured = from cr in targetInteractions
                        where (((AidType)cr.AidType == AidType.Recovery) &&
                               ((RecoveryType)cr.RecoveryType == RecoveryType.RecoverHP))
                        select cr.Amount,
                Regen1 = from cr in targetInteractions
                         where (((AidType)cr.AidType == AidType.Enhance) &&
                                (cr.IsActionIDNull() == false) &&
                                (cr.ActionsRow.ActionName == lsRegen1))
                         select cr,
                Regen2 = from cr in targetInteractions
                         where (((AidType)cr.AidType == AidType.Enhance) &&
                                (cr.IsActionIDNull() == false) &&
                                (cr.ActionsRow.ActionName == lsRegen2))
                         select cr,
                Regen3 = from cr in targetInteractions
                         where (((AidType)cr.AidType == AidType.Enhance) &&
                                (cr.IsActionIDNull() == false) &&
                                (cr.ActionsRow.ActionName == lsRegen3))
                         select cr,
                Regen4 = from cr in targetInteractions
                         where (((AidType)cr.AidType == AidType.Enhance) &&
                                (cr.IsActionIDNull() == false) &&
                                (cr.ActionsRow.ActionName == lsRegen4))
                         select cr,
            };


            int dmgTaken = 0;
            int drainAmt = 0;
            int healAmt  = 0;
            int numR1    = 0;
            int numR2    = 0;
            int numR3    = 0;
            int numR4    = 0;

            int ttlDmgTaken = 0;
            int ttlDrainAmt = 0;
            int ttlHealAmt  = 0;
            int ttlNumR1    = 0;
            int ttlNumR2    = 0;
            int ttlNumR3    = 0;
            int ttlNumR4    = 0;

            bool placeHeader = false;

            if (playerData.Any())
            {
                foreach (var player in playerData)
                {
                    dmgTaken = player.PrimeDmgTaken.Sum() + player.SecondDmgTaken.Sum();
                    drainAmt = player.PrimeDrain.Sum() + player.SecondDrain.Sum();
                    healAmt  = player.Cured.Sum();
                    numR1    = player.Regen1.Count();
                    numR2    = player.Regen2.Count();
                    numR3    = player.Regen3.Count();
                    numR4    = player.Regen4.Count();

                    if ((dmgTaken + drainAmt + healAmt + numR1 + numR2 + numR3 + numR4) > 0)
                    {
                        if (placeHeader == false)
                        {
                            strModList.Add(new StringMods
                            {
                                Start  = sb.Length,
                                Length = lsTitleRecovery.Length,
                                Bold   = true,
                                Color  = Color.Red
                            });
                            sb.Append(lsTitleRecovery + "\n\n");

                            strModList.Add(new StringMods
                            {
                                Start     = sb.Length,
                                Length    = lsHeaderRecovery.Length,
                                Bold      = true,
                                Underline = true,
                                Color     = Color.Black
                            });
                            sb.Append(lsHeaderRecovery + "\n");

                            placeHeader = true;
                        }

                        ttlDmgTaken += dmgTaken;
                        ttlDrainAmt += drainAmt;
                        ttlHealAmt  += healAmt;
                        ttlNumR1    += numR1;
                        ttlNumR2    += numR2;
                        ttlNumR3    += numR3;
                        ttlNumR4    += numR4;

                        sb.AppendFormat(lsFormatRecovery,
                                        player.Player,
                                        dmgTaken,
                                        drainAmt,
                                        healAmt,
                                        numR1,
                                        numR2,
                                        numR3,
                                        numR4);

                        sb.Append("\n");
                    }
                }

                if (placeHeader == true)
                {
                    string totalString = string.Format(lsFormatRecovery,
                                                       lsTotal,
                                                       ttlDmgTaken,
                                                       ttlDrainAmt,
                                                       ttlHealAmt,
                                                       ttlNumR1,
                                                       ttlNumR2,
                                                       ttlNumR3,
                                                       ttlNumR4);

                    strModList.Add(new StringMods
                    {
                        Start  = sb.Length,
                        Length = totalString.Length,
                        Bold   = true,
                        Color  = Color.Black
                    });
                    sb.Append(totalString + "\n\n\n");
                }
            }
        }