NotSet() public method

public NotSet ( ) : bool
return bool
コード例 #1
0
 public bool IsValid(ActionContext context)
 {
     var action = context.BattleAbility;
     var memory = context.MemoryAPI;
     var mpReserve = new Range(action.MPReserveLow, action.MPReserveHigh);
     return mpReserve.InRange(memory.Player.MPPCurrent) || mpReserve.NotSet();
 }
コード例 #2
0
ファイル: RangeTests.cs プロジェクト: EasyFarm/EasyFarm
 public void SetWhenEitherHighOrLowIsNotZero(int low, int high)
 {
     var range = new Range(low, high);
     Assert.False(range.NotSet());
 }
コード例 #3
0
ファイル: RangeTests.cs プロジェクト: EasyFarm/EasyFarm
 public void NotSetWhenBothHighAndLowAreZero()
 {
     var range = new Range(0, 0);
     Assert.True(range.NotSet());
 }
コード例 #4
0
ファイル: ActionFilters.cs プロジェクト: sruon/EasyFarm
        /// <summary>
        ///     Filters out unusable buffing abilities.
        /// </summary>
        /// <param name="fface"></param>
        /// <param name="action"></param>
        /// <param name="units"></param>
        /// <returns></returns>
        public static IEnumerable <Result> ValidateBuffingAction(
            IMemoryAPI fface,
            BattleAbility action,
            ICollection <IUnit> units)
        {
            // Return if not enabled.
            if (!action.IsEnabled)
            {
                yield return(Result.Fail("Must be enabled"));
            }

            // Name Check
            if (string.IsNullOrWhiteSpace(action.Name))
            {
                yield return(Result.Fail("Must have name"));
            }

            // MP Check
            if (action.MpCost > fface.Player.MPCurrent)
            {
                yield return(Result.Fail("Not enough mp"));
            }

            // TP Check
            if (action.TpCost > fface.Player.TPCurrent)
            {
                yield return(Result.Fail("Not enough tp"));
            }

            // MP Range
            var mpReserve = new Range(action.MPReserveLow, action.MPReserveHigh);

            if (!mpReserve.InRange(fface.Player.MPPCurrent) && !mpReserve.NotSet())
            {
                yield return(Result.Fail("Outside mp reserve range"));
            }

            // TP Range
            var tpReserve = new Range(action.TPReserveLow, action.TPReserveHigh);

            if (!tpReserve.InRange(fface.Player.TPCurrent) && !tpReserve.NotSet())
            {
                yield return(Result.Fail("Outside tp reserve range"));
            }

            // Usage Limit Check.
            if (action.UsageLimit != 0)
            {
                if (action.Usages > action.UsageLimit)
                {
                    yield return(Result.Fail("Max uses reached"));
                }
            }

            // Recast Check
            if (!AbilityUtils.IsRecastable(fface, action))
            {
                yield return(Result.Fail("Not recastable"));
            }

            // Limiting Status Effect Check for Spells.
            if (ResourceHelper.IsSpell(action.AbilityType))
            {
                if (ProhibitEffects.ProhibitEffectsSpell.Intersect(fface.Player.StatusEffects).Any())
                {
                    yield return(Result.Fail("Status effect blocking spell"));
                }
            }

            // Limiting Status Effect Check for Abilities.
            if (ResourceHelper.IsAbility(action.AbilityType))
            {
                if (ProhibitEffects.ProhibitEffectsAbility.Intersect(fface.Player.StatusEffects).Any())
                {
                    yield return(Result.Fail("Status effect blocking ability"));
                }
            }

            // Player HP Checks Enabled.
            if (action.PlayerLowerHealth != 0 || action.PlayerUpperHealth != 0)
            {
                // Player Upper HP Check
                if (fface.Player.HPPCurrent > action.PlayerUpperHealth)
                {
                    yield return(Result.Fail("Player health too high"));
                }

                // Player Lower HP Check
                if (fface.Player.HPPCurrent < action.PlayerLowerHealth)
                {
                    yield return(Result.Fail("Player health too low"));
                }
            }

            // Status Effect Checks Enabled
            if (!string.IsNullOrWhiteSpace(action.StatusEffect))
            {
                var hasEffect = fface.Player.StatusEffects.Any(effect =>
                                                               Regex.IsMatch(effect.ToString(),
                                                                             action.StatusEffect.Replace(" ", "_"),
                                                                             RegexOptions.IgnoreCase));

                // Contains Effect Check
                if (hasEffect && !action.TriggerOnEffectPresent)
                {
                    yield return(Result.Fail("Player missing status effect"));
                }

                // Missing EFfect Check
                if (!hasEffect && action.TriggerOnEffectPresent)
                {
                    yield return(Result.Fail("Player contains status effect"));
                }
            }

            // Check if action's recast period has passed.
            if (action.Recast != 0)
            {
                if (action.LastCast > DateTime.Now)
                {
                    yield return(Result.Fail("Recast period not reached"));
                }
            }

            // Do not cast trust magic with aggro.
            var isTrustMagic = action.AbilityType == AbilityType.Trust;
            var hasAggro     = units.Any(x => x.HasAggroed);

            if (isTrustMagic && hasAggro)
            {
                yield return(Result.Fail("Cannot use trust magic with aggro"));
            }

            // Do not cast action not matching chat text.
            if (!string.IsNullOrEmpty(action.ChatEvent))
            {
                var chatEntries = fface.Chat.ChatEntries.ToList();

                List <EliteAPI.ChatEntry> matches = chatEntries
                                                    .Where(x => x.Text.ToLower().Contains(action.ChatEvent.ToLower())).ToList();

                if (!matches.Any())
                {
                    yield return(Result.Fail("Chat message has not been received"));
                }

                if (action.ChatEventPeriod.HasValue && !matches.Any(x => DateTime.Now <= x.Timestamp.Add(action.ChatEventPeriod.Value)))
                {
                    yield return(Result.Fail("No chat messages valid for the given time range"));
                }
            }
        }