public static void QueueVerification(string spellName, WoWUnit target, RotationSpell.VerificationType type)
 {
     lock (_verificationLock)
     {
         RotationLogger.Debug($"Queueing verification for {spellName} on {Thread.CurrentThread.Name}");
         _verification = new Tuple <string, ulong, RotationSpell.VerificationType, DateTime>(spellName, target.Guid, type, DateTime.Now);
         RegisterCombatLogClearer();
     }
 }
        public static void NotifyCombatLog(List <string> args)
        {
            lock (_verificationLock)
            {
                string timestamp   = args[0];
                string eventName   = args[1];
                string sourceGuid  = args[2];
                string sourceName  = args[3];
                string sourceFlags = args[4];
                string destGuid    = args[5];
                string destName    = args[6];
                string destFlags   = args[7];

                // we have to check that the event fired is an expected event for the type of spell being casted
                // so that spells expecting an aura will only be verified on aura appliance
                RotationSpell.VerificationType type = GetVerificationType();
                if (_successEvents[type].Contains(eventName))
                {
                    string spellId     = args[8];
                    string spellName   = args[9];
                    string spellSchool = args[10];

                    RotationLogger.Trace($"{eventName} {sourceGuid} {sourceName} {destGuid} {destName} {spellId} {spellName} {spellSchool}");

                    ulong castedBy = GetGUIDForLuaGUID(sourceGuid);
                    if (castedBy == _playerGuid && IsSpellWaitingForVerification(spellName))
                    {
                        var delegated = _eventDelegates.FirstOrDefault(e => e.Item1 == eventName);
                        if (delegated != null)
                        {
                            string delegatedEvent = delegated.Item2;
                            RotationLogger.Debug($"Delegating {eventName} to {delegatedEvent}");
                            CreatePassiveEventDelegate(delegatedEvent);
                        }
                        else
                        {
                            RotationLogger.Debug($"Clearing verification for {spellName}");
                            _verification = _emptyVerify;
                        }
                    }

                    ulong spellTarget = GetGUIDForLuaGUID(destGuid);
                    if (castedBy == 0 && IsWaitingForSpellOnTarget(spellName, spellTarget))
                    {
                        var delegated = _eventDelegates.FirstOrDefault(e => e.Item1 == eventName);
                        if (delegated != null)
                        {
                            string delegatedEvent = delegated.Item2;
                            RotationLogger.Debug($"Delegating {eventName} to {delegatedEvent}");
                            CreatePassiveEventDelegate(delegatedEvent);
                        }
                        else
                        {
                            RotationLogger.Debug($"Clearing verification for spell with no source {spellName}");
                            _verification = _emptyVerify;
                        }
                    }
                }

                if (eventName == "SPELL_CAST_FAILED")
                {
                    string spellId     = args[8];
                    string spellName   = args[9];
                    string spellSchool = args[10];
                    string failedType  = args[11];

                    ulong castedBy = GetGUIDForLuaGUID(sourceGuid);
                    if (castedBy == _playerGuid && IsSpellWaitingForVerification(spellName) && failedType != "Another action is in progress")
                    {
                        RotationLogger.Debug($"Clearing verification for {spellName} because {failedType}");
                        _verification = _emptyVerify;
                    }
                }

                if (eventName == "UNIT_DIED")
                {
                    ulong deadUnit = GetGUIDForLuaGUID(destGuid);
                    if (IsWaitingOnTarget(deadUnit))
                    {
                        RotationLogger.Debug($"Clearing verification because target died");
                        _verification = _emptyVerify;
                    }

                    if (deadUnit == _playerGuid)
                    {
                        RotationLogger.Debug($"Clearing verification because we died");
                        _verification = _emptyVerify;
                    }
                }

                ClearVerificationOlderThan(10);
            }
        }