public IEnumerable <StatBuilderResult> Build(BuildParameters parameters)
        {
            var restrictions  = _restrictionsBuilder.Build(parameters);
            var selectedBuffs = _buffs.Where(restrictions.AllowsBuff).ToList();

            if (selectedBuffs.IsEmpty())
            {
                return(Enumerable.Empty <StatBuilderResult>());
            }
            return(selectedBuffs
                   .Select(b => _statFactory(b.Buff))
                   .Aggregate((l, r) => l.Concat(r))
                   .Build(parameters));
        }
Example #2
0
        private IEnumerable <IValue> CreateValues(BuildParameters parameters)
        {
            var restrictions   = _restrictionsBuilder.Build(parameters);
            var sourceEntities = _source.Build(parameters.ModifierSourceEntity);
            var targetEntities = _target.Build(parameters.ModifierSourceEntity);

            return(from b in _buffs
                   where restrictions.AllowsBuff(b)
                   let buffIdentity = b.Buff.Build(parameters)
                                      from t in targetEntities
                                      let activeStat = _statFactory.BuffIsActive(t, buffIdentity)
                                                       let activeCondition = new StatValue(activeStat)
                                                                             let buffSourceCondition = BuffSourceIsAny(t, buffIdentity, sourceEntities)
                                                                                                       select new ConditionalValue(
                       c => activeCondition.Calculate(c).IsTrue() && buffSourceCondition.Calculate(c).IsTrue(),
                       $"{activeCondition} && {buffSourceCondition}"));
        }