Ejemplo n.º 1
0
        /// <summary>
        /// Executes moves without the need for a target.
        /// </summary>
        /// <param name="actions"></param>
        public void UseBuffingActions(IEnumerable <BattleAbility> actions)
        {
            if (actions == null)
            {
                throw new ArgumentNullException("actions");
            }

            var castables = actions.ToList();

            while (castables.Count > 0)
            {
                foreach (var action in castables.ToList())
                {
                    if (!ActionFilters.BuffingFilter(_fface, action))
                    {
                        castables.Remove(action);
                        continue;
                    }

                    // Try to cast the spell. On failure, continue and recast at a later time.
                    if (!_caster.CastSpell(action))
                    {
                        continue;
                    }

                    // Remove spell from castables so that it will not be casted again.
                    castables.Remove(action);

                    // Increase usage count to limit number of usages.
                    action.Usages++;

                    // Set the recast to prevent casting before the recast period.
                    action.LastCast = DateTime.Now.AddSeconds(action.Recast);

                    // Sleep until a spell is recastable.
                    Thread.Sleep(Config.Instance.GlobalCooldown);
                }
            }
        }