internal static SpellData ParseCustomSpellData(string line)
        {
            SpellData spellData = null;

            if (!string.IsNullOrEmpty(line))
            {
                string[] data = line.Split('^');
                if (data.Length >= 11)
                {
                    int    duration   = int.Parse(data[3], CultureInfo.CurrentCulture) * 6; // as seconds
                    int    beneficial = int.Parse(data[4], CultureInfo.CurrentCulture);
                    byte   target     = byte.Parse(data[6], CultureInfo.CurrentCulture);
                    ushort classMask  = ushort.Parse(data[7], CultureInfo.CurrentCulture);

                    // deal with too big or too small values
                    // all adps we care about is in the range of a few minutes
                    if (duration > ushort.MaxValue)
                    {
                        duration = ushort.MaxValue;
                    }
                    else if (duration < 0)
                    {
                        duration = 0;
                    }

                    spellData = new SpellData()
                    {
                        ID           = string.Intern(data[0]),
                        Name         = string.Intern(data[1]),
                        NameAbbrv    = Helpers.AbbreviateSpellName(data[1]),
                        Level        = ushort.Parse(data[2], CultureInfo.CurrentCulture),
                        Duration     = (ushort)duration,
                        IsBeneficial = beneficial != 0,
                        Target       = target,
                        MaxHits      = ushort.Parse(data[5], CultureInfo.CurrentCulture),
                        ClassMask    = classMask,
                        LandsOnYou   = string.Intern(data[8]),
                        LandsOnOther = string.Intern(data[9]),
                        Damaging     = byte.Parse(data[10], CultureInfo.CurrentCulture) == 1,
                        IsProc       = byte.Parse(data[11], CultureInfo.CurrentCulture) == 1,
                        Adps         = ushort.Parse(data[13], CultureInfo.CurrentCulture)
                    };
                }
            }

            return(spellData);
        }
        private const int SPELL_TIME_OFFSET = 10; // seconds back

        internal static SpellCountData GetSpellCounts(List <string> playerList, PlayerStats raidStats)
        {
            var result  = new SpellCountData();
            var offsets = GetOffsetTimes(raidStats);
            var begins  = offsets.Item1;
            var lasts   = offsets.Item2;

            List <IAction> castsDuring    = new List <IAction>();
            List <IAction> receivedDuring = new List <IAction>();

            for (int i = 0; i < begins.Count; i++)
            {
                var blocks = DataManager.Instance.GetCastsDuring(begins[i], lasts[i]);
                blocks.ForEach(block => castsDuring.AddRange(block.Actions));
                blocks = DataManager.Instance.GetReceivedSpellsDuring(begins[i], lasts[i]);
                blocks.ForEach(block => receivedDuring.AddRange(block.Actions));
            }

            foreach (var action in castsDuring.AsParallel().Where(cast => playerList.Contains((cast as SpellCast).Caster)))
            {
                SpellCast cast      = action as SpellCast;
                var       spellData = DataManager.Instance.GetSpellByAbbrv(Helpers.AbbreviateSpellName(cast.Spell));
                if (spellData != null)
                {
                    UpdateMaps(spellData, cast.Caster, result.PlayerCastCounts, result.MaxCastCounts, result.UniqueSpells);
                }
            }

            foreach (var action in receivedDuring.AsParallel().Where(received => playerList.Contains((received as ReceivedSpell).Receiver)))
            {
                ReceivedSpell received = action as ReceivedSpell;

                var spellData  = received.SpellData;
                var spellClass = PlayerManager.Instance.GetPlayerClassEnum(received.Receiver);

                if (DataManager.Instance.CheckForSpellAmbiguity(spellData, spellClass, out SpellData replaced))
                {
                    spellData = replaced;
                }

                UpdateMaps(spellData, received.Receiver, result.PlayerReceivedCounts, result.MaxReceivedCounts, result.UniqueSpells);
            }

            return(result);
        }
Exemple #3
0
        private static string GetTypeFromSpell(string name, string type)
        {
            string key = Helpers.CreateRecordKey(type, name);

            if (string.IsNullOrEmpty(key) || !SpellTypeCache.TryGetValue(key, out string result))
            {
                if (!string.IsNullOrEmpty(key))
                {
                    string    spellName = Helpers.AbbreviateSpellName(name);
                    SpellData data      = DataManager.Instance.GetSpellByAbbrv(spellName);
                    result = (data != null && data.IsProc) ? Labels.PROC : type;
                    SpellTypeCache[key] = result;
                }
                else
                {
                    result = type;
                }
            }

            return(result);
        }