예제 #1
0
파일: Caster.cs 프로젝트: jonii99/EasyFarm
 public bool CastAbility(Ability ability)
 {
     // Send the command to the game.
     _fface.Windower.SendString(ability.ToString());
     Thread.Sleep(100);
     return true;
 }
예제 #2
0
        /// <summary>
        ///     Checks whether a spell or ability can be recasted.
        /// </summary>
        /// <param name="fface"></param>
        /// <param name="ability"></param>
        /// <returns></returns>
        public static bool IsRecastable(FFACE fface, Ability ability)
        {
            var recast = -1;

            /*
             * Fix: If the action is a ranged attack,
             * it will return something even when it's recastable.
             *
             * This if statement must be above process abilities since
             * AbilityType.Range is in AbilityType.IsAbility
             */
            if (AbilityType.Range.HasFlag(ability.AbilityType))
            {
                return true;
            }

            // If a spell get spell recast
            if (CompositeAbilityTypes.IsSpell.HasFlag(ability.AbilityType))
            {
                recast = fface.Timer.GetSpellRecast(ToSpellList(ability));
            }

            // if ability get ability recast.
            if (CompositeAbilityTypes.IsAbility.HasFlag(ability.AbilityType))
            {
                recast = fface.Timer.GetAbilityRecast(ToAbilityList(ability));
            }

            /*
             * Fixed bug: recast for weaponskills returns -1 not zero.
             * Check for <= to zero instead of strictly == zero.
             */
            return recast <= 0;
        }
예제 #3
0
 public void TestToString()
 {
     var test = new Ability
     {
         Prefix = "/magic",
         English = "Cure",
         Targets = "Self"
     };
     var cure = new AbilityService("resources").CreateAbility("Cure");
     Assert.Equals(test.ToString(), cure.ToString());
 }
예제 #4
0
        /// <summary>
        ///     Execute a single buffing type action.
        /// </summary>
        /// <param name="action"></param>
        public void UseBuffingAction(Ability action)
        {
            if (action == null) throw new ArgumentNullException("action");

            // Create new new ability and set its basic required information.
            var baction = new BattleAbility
            {
                Name = action.English,
                IsEnabled = true,
                Ability = action
            };

            // Convert ability to new battleability object.
            UseBuffingActions(new List<BattleAbility> {baction});
        }
예제 #5
0
 /// <summary>
 ///     Create a storing a reference to the given ability.
 /// </summary>
 /// <param name="ability"></param>
 public BattleAbility(Ability ability)
 {
     Ability = ability;
     Name = ability.English;
 }
예제 #6
0
파일: Caster.cs 프로젝트: jonii99/EasyFarm
        /// <summary>
        ///     Cast the spell and returns whether the cast was
        ///     successful or not.
        /// </summary>
        /// <param name="ability"></param>
        /// <returns></returns>
        public bool CastSpell(Ability ability)
        {
            // Call for player to stop.
            while (_player.IsMoving)
            {
                _fface.Navigator.Reset();
                Thread.Sleep(100);
            }

            // Try to cast the spell and return false if
            // we've failed to start casting or the
            // casting was interrupted.
            if (EnsureCast(ability.ToString()))
            {
                return MonitorCast();
            }

            return false;
        }
예제 #7
0
        private static AbilityList ToAbilityList(Ability ability)
        {
            var name = AdjustName(ability.English);

            AbilityList value;

            // Fixes for summoner's blood pact recast times.
            if (ability.CategoryType.HasFlag(CategoryType.BloodPactWard))
                return AbilityList.Blood_Pact_Ward;
            if (ability.CategoryType.HasFlag(CategoryType.BloodPactRage))
                return AbilityList.Blood_Pact_Rage;

            Enum.TryParse(name, out value);

            return value;
        }
예제 #8
0
 private static SpellList ToSpellList(Ability ability)
 {
     var name = AdjustName(ability.English);
     SpellList value;
     Enum.TryParse(name, out value);
     return value;
 }
예제 #9
0
        /// <summary>
        ///     A general method for loading abilites from the .xml files.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        protected IEnumerable<Ability> ParseResources(string name)
        {
            // Stores the created abilities with the given name.
            var abilities = new List<Ability>();

            // Stores the XElement attributes that match the name.
            var elements = new List<XElement>();

            // Select all matching XElement objects.
            foreach (var resource in Resources)
            {
                elements.AddRange(resource.Elements()
                    .Attributes()
                    .Where(x => x.Name == "english" || x.Name == "japanese")
                    .Where(x => x.Value.Equals(name, StringComparison.CurrentCultureIgnoreCase))
                    .Select(x => x.Parent));
            }

            // Start extracting values from XElement;s and augment our ability objects.
            foreach (var element in elements.Where(x => x.HasAttributes))
            {
                var ability = new Ability();

                // Get the list of handlers that can process this element.
                var augmenters = _augmenters
                    .Where(augmenter => augmenter.CanAugment(element))
                    .ToList();

                // Assign the ability's fields for each handler
                augmenters.ForEach(augmenter => augmenter.Augment(element, ability));

                abilities.Add(ability);
            }

            return abilities;
        }
예제 #10
0
 private void CompleteSelectionButton_Click(object sender, RoutedEventArgs e)
 {
     SelectedAbility = AbilityListBox.SelectedValue as Ability;
     Close();
 }