コード例 #1
0
        public static bool MatchLine(string line)
        {
            StaticEffect effect;

            line = FoodEffect.NormalizeLine(line, StaticFoodEffect.InvalidWords, StaticFoodEffect.RegexReplacementMatches);
            return(_regexEffect.IsMatch(line) && Enum.TryParse(_regexEffect.Match(line).Value, true, out effect));
        }
コード例 #2
0
        public override bool ParseEffect(string line)
        {
            int          value;
            StaticEffect effect;
            bool         wasSuccessful = false;

            line = FoodEffect.NormalizeLine(line, StaticFoodEffect.InvalidWords, StaticFoodEffect.RegexReplacementMatches);

            if (_regexEffect.Match(line).Success&&
                Enum.TryParse(_regexEffect.Match(line).Value, true, out effect))
            {
                Effect        = effect;
                wasSuccessful = true;
            }

            return(wasSuccessful);
        }
コード例 #3
0
        public override bool ParseEffect(string line)
        {
            int      value;
            StatType statType;
            bool     wasSuccessful = false;

            line = FoodEffect.NormalizeLine(line, FlatStatFoodEffect.InvalidWords, FlatStatFoodEffect.RegexReplacementMatches);

            if (_regexValue.Match(line).Success&&
                _regexAffectedStat.Match(line).Success)
            {
                string matchValue = _regexValue.Match(line).Value.Trim();
                if (int.TryParse(matchValue, out value) &&
                    Enum.TryParse(_regexAffectedStat.Match(line).Value, true, out statType))
                {
                    Value         = value;
                    AffectedStat  = statType;
                    wasSuccessful = true;
                }
            }

            return(wasSuccessful);
        }
コード例 #4
0
        public override bool ParseEffect(string line)
        {
            int    value;
            Action action;
            bool   wasSuccessful = false;

            line = FoodEffect.NormalizeLine(line, ChanceFoodEffect.InvalidWords, ChanceFoodEffect.RegexReplacementMatches);

            if (_regexValue.Match(line).Success&&
                _regexActions.Match(line).Success)
            {
                string valueMatch  = _regexValue.Match(line).Value;
                string actionMatch = _regexActions.Match(line).Value;

                if (int.TryParse(valueMatch, out value) &&
                    Enum.TryParse(actionMatch, out action))
                {
                    Chance        = value;
                    Effect        = action;
                    wasSuccessful = true;
                }
            }
            else if (!_regexValue.Match(line).Success&&
                     _regexActions.Match(line).Success)
            {
                if (Enum.TryParse(_regexActions.Match(line).Value, out action))
                {
                    //Action found, but no Value -> probably 100%
                    Chance        = 100;
                    Effect        = action;
                    wasSuccessful = true;
                }
            }

            return(wasSuccessful);
        }
コード例 #5
0
 public static bool MatchLine(string line)
 {
     line = FoodEffect.NormalizeLine(line, ChanceFoodEffect.InvalidWords, ChanceFoodEffect.RegexReplacementMatches);
     return(_regexActions.IsMatch(line));
 }
コード例 #6
0
 public static bool MatchLine(string line)
 {
     line = FoodEffect.NormalizeLine(line, FoodEffect.InvalidWords, FoodEffect.RegexReplacementMatches);
     return(_regexDescription.IsMatch(line));
 }
コード例 #7
0
 public static bool MatchLine(string line)
 {
     line = FoodEffect.NormalizeLine(line, FlatStatFoodEffect.InvalidWords, FlatStatFoodEffect.RegexReplacementMatches);
     return(_regexValue.IsMatch(line) &&
            _regexAffectedStat.IsMatch(line));
 }