public ConditionBuilderResult(StatConverter statConverter = null, IValue value = null)
 {
     HasStatConverter = !(statConverter is null);
     StatConverter    = statConverter ?? Funcs.Identity;
     HasValue         = !(value is null);
     Value            = value ?? new Constant(true);
 }
 private static IIntermediateModifier CreateResult(IReadOnlyList <IntermediateModifierEntry> entries = null,
                                                   StatConverter statConverter   = null,
                                                   ValueConverter valueConverter = null)
 {
     return(new SimpleIntermediateModifier(entries ?? new IntermediateModifierEntry[0],
                                           statConverter ?? (s => s),
                                           valueConverter ?? (v => v)));
 }
Exemplo n.º 3
0
 private ModifierBuilder(IEnumerable <IntermediateModifierEntry> entries,
                         StatConverter statConverter,
                         ValueConverter valueConverter)
 {
     Entries        = entries.ToList();
     StatConverter  = statConverter;
     ValueConverter = valueConverter;
 }
Exemplo n.º 4
0
 private ModifierBuilder(IReadOnlyList <IntermediateModifierEntry> entries,
                         StatConverter statConverter,
                         ValueConverter valueConverter)
 {
     Entries        = entries;
     StatConverter  = statConverter;
     ValueConverter = valueConverter;
 }
Exemplo n.º 5
0
 public StatConvertingConditionBuilder(
     StatConverter statConverter, StatConverter negatedStatConverter,
     Func <ResolveContext, IConditionBuilder> resolver = null)
 {
     _statConverter        = statConverter;
     _negatedStatConverter = negatedStatConverter;
     _resolver             = resolver;
 }
Exemplo n.º 6
0
        public void WithStatConverterSetsStatConverter()
        {
            var           sut           = ModifierBuilder.Empty;
            StatConverter statConverter = s => null;

            sut = (ModifierBuilder)sut.WithStatConverter(statConverter);

            Assert.AreSame(statConverter, sut.StatConverter);
        }
        public void AddWithSubstitution()
        {
            StatConverter manipulator = s => null !;

            _sut.Add(Regex, manipulator, "substitution");

            var builder = _sut.AssertSingle(Regex, "substitution");

            Assert.AreSame(manipulator, builder.StatConverter);
        }
        /// <summary>
        /// Adds a matcher applying a stat converter.
        /// </summary>
        public void Add(
            [RegexPattern] string regex,
            StatConverter manipulateStat,
            string substitution = "")
        {
            var builder = ModifierBuilder
                          .WithStatConverter(manipulateStat);

            Add(regex, builder, substitution);
        }
Exemplo n.º 9
0
        public IModifierBuilder WithStatConverter(StatConverter converter)
        {
            if (converter == null)
            {
                throw new ArgumentNullException(nameof(converter));
            }
            if (StatConverter != null)
            {
                throw new InvalidOperationException();
            }
            var ret = (ModifierBuilderStub)MemberwiseClone();

            ret.StatConverter = converter;
            return(ret);
        }
 private static IIntermediateModifier CreateResult(StatConverter statConverter)
 {
     return(CreateResult(null, statConverter));
 }
Exemplo n.º 11
0
 public IModifierBuilder WithStatConverter(StatConverter converter)
 {
     return(new ModifierBuilder(Entries, converter, ValueConverter));
 }
 public ConditionBuilderResult(StatConverter statConverter)
     : this(statConverter, null)
 {
 }
Exemplo n.º 13
0
 public IModifierBuilder WithStatConverter(StatConverter converter)
 => new ModifierBuilder(Entries, converter, ValueConverter);
Exemplo n.º 14
0
 public StatConvertingConditionBuilder(
     StatConverter statConverter,
     Func <ResolveContext, IConditionBuilder> resolver = null)
     : this(statConverter, statConverter, resolver)
 {
 }
Exemplo n.º 15
0
 public void Deconstruct(out StatConverter statConverter, out IValue value) =>
 (statConverter, value) = (StatConverter, Value);