public static List<AuraEffectHandler> CreateEffectHandlers(SpellEffect[] effects, CasterInfo caster, Unit target, bool beneficial) { if (effects == null) return null; try { List<AuraEffectHandler> effectHandlers = null; var failReason = SpellFailedReason.Ok; for (var i = 0; i < effects.Length; i++) { var effect = effects[i]; if (effect.HarmType == HarmType.Beneficial || !beneficial) { var effectValue = effect.CalcEffectValue(caster); var effectHandler = CreateEffectHandler(effect, caster, target, effectValue, ref failReason); if (failReason != SpellFailedReason.Ok) { return null; } if (effectHandlers == null) { effectHandlers = new List<AuraEffectHandler>(3); } effectHandlers.Add(effectHandler); } } return effectHandlers; } catch (Exception e) { LogUtil.ErrorException(e, "Failed to create AuraEffectHandlers for: " + effects.GetWhere(effect => effect != null).Spell); return null; } }