예제 #1
0
 protected MatchNumber(MatchNumber copy)
     : base(copy)
 {
     Op = copy.Op;
     Value = copy.Value;
     Value2 = copy.Value2;
     Min = copy.Min;
     Max = copy.Max;
 }
예제 #2
0
        public bool Subsets(Match match)
        {
            if (Priority != match.Priority) return false;

            MatchNumber number = match as MatchNumber;

            // Non-equality operator cannot be subsetted.
            if (Op == Operator.NotEqual || number.Op == Operator.NotEqual) return false;

            return Value >= number.Value && Value2 <= number.Value2;
        }
예제 #3
0
        // Overriden due to more restrictive conditions.
        public override bool CanMerge(Match match)
        {
            if (!base.CanMerge(match)) return false;

            MatchNumber number = match as MatchNumber;

            // Non-equality operators are not mergeable.
            if (Op == Operator.NotEqual || number.Op == Operator.NotEqual) return false;

            // This match subsets, is subsetted by match, or complements match.
            return Subsets(match) || number.Subsets(this) || Complements(match);
        }
예제 #4
0
        public bool Complements(Match match)
        {
            // The different priorities cannot complement each other (e.g. "Quality" cannot complement "ItemLevel" and vice versa).
            if (Priority != match.Priority) return false;

            MatchNumber number = match as MatchNumber;

            // Non-equality operator cannot complement anything.
            if (Op == Operator.NotEqual || number.Op == Operator.NotEqual) return false;

            // Complements from left or right.
            // XXX: Don't have to take operator into account at all, due to conversion of all operators into Between ranges in constructor.
            return Value2 + 1 == number.Value || Value == number.Value2 + 1;
        }
예제 #5
0
        public void Merge(Match match)
        {
            MatchNumber number = match as MatchNumber;

            if (Complements(number))
            {
                // Complements from left.
                if (Value2 + 1 == number.Value)
                    Value2 = number.Value2;
                else // Value 1 == number.Value2 + 1
                    Value = number.Value;
            }
            else // If we subset the match.
                if (Subsets(number))
                {
                    Op = number.Op;
                    Value = number.Value;
                    Value2 = number.Value2;
                } // Otherwise match subsets us, nothing to do.
        }