Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        private IEnumerable <IValue> CreateValues(BuildParameters parameters)
        {
            var restrictions   = _restrictionsBuilder.Build();
            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()
                                      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}"));
        }