示例#1
0
        public NodeValue?Calculate(IValueCalculationContext context)
        {
            if (context.GetValue(_stat, NodeType.BaseSet, _path) is NodeValue baseSet)
            {
                var baseAdd = context.GetValue(_stat, NodeType.BaseAdd, _path) ?? new NodeValue(0);
                return(baseSet + baseAdd);
            }

            return(context.GetValue(_stat, NodeType.BaseAdd, _path));
        }
        public NodeValue? Calculate(IValueCalculationContext context)
        {
            var value = _transformedValue.Calculate(context);
            if (value is null)
                return null;

            var conversion = context.GetValue(ConvertTo) ?? new NodeValue(0);
            var gain = context.GetValue(GainAs) ?? new NodeValue(0);
            return value * (conversion + gain) / 100;
        }
            public NodeValue?GetValue(IStat stat, NodeType nodeType, PathDefinition path)
            {
                if (nodeType != NodeType.PathTotal || !_value._regens(_value._pool).Equals(stat))
                {
                    return(_originalContext.GetValue(stat, nodeType, path));
                }

                return(_applyingPools
                       .Select(p => _originalContext.GetValue(_value._regens(p), nodeType, path))
                       .Sum());
            }
        public NodeValue?Calculate(IValueCalculationContext context)
        {
            var baseSet = context.GetValue(_stat, NodeType.BaseSet, _path);
            var baseAdd = context.GetValue(_stat, NodeType.BaseAdd, _path);

            if (baseSet is null && baseAdd is null)
            {
                return(null);
            }
            return(_stat.Round((baseSet ?? new NodeValue(0)) + (baseAdd ?? new NodeValue(0))));
        }
示例#5
0
        public NodeValue?Calculate(IValueCalculationContext context)
        {
            var value = _transformedValue.Calculate(context);

            if (value is null)
            {
                return(null);
            }

            var conversion = context.GetValue(_barFooConversion) ?? new NodeValue(0);
            var gain       = context.GetValue(_barFooGain) ?? new NodeValue(0);

            return(value * (conversion + gain));
        }
示例#6
0
        public NodeValue?Calculate(IValueCalculationContext context)
        {
            var @base = context.GetValue(_stat, NodeType.Base, _path);

            if (@base == null)
            {
                return(null);
            }

            var increase = context.GetValue(_stat, NodeType.Increase, _path) ?? new NodeValue(0);
            var more     = context.GetValue(_stat, NodeType.More, _path) ?? new NodeValue(1);

            return(@base * (1 + increase) * more);
        }
示例#7
0
            public NodeValue?GetValue(IStat stat, NodeType nodeType, PathDefinition path)
            {
                if (nodeType != NodeType.PathTotal || !_value._regens(_value._pool).Equals(stat))
                {
                    return(_originalContext.GetValue(stat, nodeType, path));
                }

                NodeValue?result = null;

                foreach (var pool in _applyingPools)
                {
                    var value = _originalContext.GetValue(_value._regens(pool), nodeType, path);
                    result = result.SumWhereNotNull(value);
                }
                return(result);
            }
        private NodeValue?Calculate(IValueCalculationContext context, NodeValue value)
        {
            if (Stat.Minimum != null)
            {
                var minimum = context.GetValue(Stat.Minimum) ?? new NodeValue(double.MinValue);
                value = NodeValue.Combine(value, minimum, Math.Max);
            }

            if (Stat.Maximum != null)
            {
                var maximum = context.GetValue(Stat.Maximum) ?? new NodeValue(double.MaxValue);
                value = NodeValue.Combine(value, maximum, Math.Min);
            }

            return(value);
        }
        public NodeValue?Calculate(IValueCalculationContext context)
        {
            var original        = _transformedValue.Calculate(context);
            var skillBaseDamage = context.GetValue(_skillDamage, NodeType.Base);

            return(new[] { original, skillBaseDamage }.Sum());
        }
示例#10
0
        public NodeValue?Calculate(IValueCalculationContext context)
        {
            var original        = _transformedValue.Calculate(context);
            var skillBaseDamage = context.GetValue(_skillDamage, NodeType.Base, context.CurrentPath);

            return(original.SumWhereNotNull(skillBaseDamage));
        }
        public NodeValue?Calculate(IValueCalculationContext context)
        {
            // Make sure paths for conversion chains are created
            context.GetValue(_source, NodeType.UncappedSubtotal, PathDefinition.MainPath);

            var modifiedContext = new ModifiedValueCalculationContext(context, GetPaths);

            return(_transformedValue.Calculate(modifiedContext));
        }
        private NodeValue?GetValues(
            IValueCalculationContext context, IStat stat, NodeType nodeType, PathDefinition path)
        {
            var originalValue = context.GetValue(stat, nodeType, path);

            if (nodeType != NodeType.BaseAdd && nodeType != NodeType.BaseSet)
            {
                return(originalValue);
            }
            if (!stat.Equals(_transformedStat))
            {
                return(originalValue);
            }

            var effectivenessStat =
                nodeType == NodeType.BaseSet ? _baseSetEffectivenessStat : _baseAddEffectivenessStat;
            var effectiveness = context.GetValue(effectivenessStat) ?? new NodeValue(1);

            return(originalValue * effectiveness);
        }
        GetValue(IValueCalculationContext context, IStat stat, NodeType nodeType, PathDefinition path)
        {
            var value = context.GetValue(stat, nodeType, path);

            if (value is null || !_convertTo.Equals(stat) || nodeType != NodeType.PathTotal)
            {
                return(value);
            }

            var sourceConversion = context.GetValue(_conversion) ?? new NodeValue(0);

            if (sourceConversion <= 100)
            {
                // Conversions don't exceed 100%, No scaling required
                return(value);
            }

            var isSkillPath           = path.ModifierSource is ModifierSource.Local.Skill;
            var sourceSkillConversion = context.GetValue(_skillConversion) ?? new NodeValue(0);

            if (sourceSkillConversion >= 100)
            {
                // Conversions from skills are or exceed 100%
                // Non-skill conversions don't apply
                if (!isSkillPath)
                {
                    return(new NodeValue(0));
                }
                // Skill conversions are scaled to sum to 100%
                return(value / sourceSkillConversion * 100);
            }

            // Conversions exceed 100%
            // Skill conversions don't scale (they themselves don't exceed 100%)
            if (isSkillPath)
            {
                return(value);
            }
            // Non-skill conversions are scaled to sum to 100% - skill conversions
            return(value * (100 - sourceSkillConversion) / (sourceConversion - sourceSkillConversion));
        }
示例#14
0
            public NodeValue?GetValue(IStat stat, NodeType nodeType, PathDefinition path)
            {
                var value = _originalContext.GetValue(stat, nodeType, path);

                if (value is null || !_barFooConversion.Equals(stat) || nodeType != NodeType.PathTotal)
                {
                    return(value);
                }

                var barConversion = _originalContext.GetValue(_barConversion) ?? new NodeValue(0);

                if (barConversion <= 1)
                {
                    // Conversions don't exceed 100%, No scaling required
                    return(value);
                }

                var isSkillPath        = path.ModifierSource is ModifierSource.Local.Skill;
                var barSkillConversion = _originalContext.GetValue(_barSkillConversion) ?? new NodeValue(0);

                if (barSkillConversion >= 1)
                {
                    // Conversions from skills are or exceed 100%
                    // Non-skill conversions don't apply
                    if (!isSkillPath)
                    {
                        return(new NodeValue(0));
                    }
                    // Skill conversions are scaled to sum to 100%
                    return(value / barSkillConversion);
                }

                // Conversions exceed 100%
                // Skill conversions don't scale (they themselves don't exceed 100%)
                if (isSkillPath)
                {
                    return(value);
                }
                // Non-skill conversions are scaled to sum to 100% - skill conversions
                return(value * (1 - barSkillConversion) / (barConversion - barSkillConversion));
            }
        public NodeValue?Calculate(IValueCalculationContext context)
        {
            var applyingPools =
                from pool in Enum.GetValues(typeof(Pool)).Cast <Pool>()
                let targetPoolStat = _targetPools(pool)
                                     let targetPoolValue = context.GetValue(targetPoolStat)
                                                           where targetPoolValue.HasValue && (Pool)targetPoolValue.Single() == _pool
                                                           select pool;
            var modifiedContext = new ModifiedContext(this, applyingPools.ToList(), context);

            return(_transformedValue.Calculate(modifiedContext));
        }
示例#16
0
        public NodeValue?Calculate(IValueCalculationContext context)
        {
            var uncapped = context.GetValue(_stat, NodeType.UncappedSubtotal);

            if (uncapped is null)
            {
                return(null);
            }

            var uncappedV = uncapped.Value;

            if (uncappedV == 0)
            {
                return(new NodeValue(0));
            }

            var min = _stat.Minimum is null ? null : context.GetValue(_stat.Minimum);
            var max = _stat.Maximum is null ? null : context.GetValue(_stat.Maximum);

            return(Min(Max(uncappedV, min), max));
        }
        /// <summary>
        /// Returns the values of the nodes of all paths of the given type in the given stat's subgraph.
        /// </summary>
        public static List <NodeValue?> GetValues(
            this IValueCalculationContext context, IStat stat, NodeType nodeType)
        {
            var paths  = context.GetPaths(stat);
            var values = new List <NodeValue?>(paths.Count);

            foreach (var path in paths)
            {
                values.Add(context.GetValue(stat, nodeType, path));
            }
            return(values);
        }
示例#18
0
        public NodeValue?Calculate(IValueCalculationContext context)
        {
            var value = _transformedValue.Calculate(context);

            if (value is null)
            {
                return(null);
            }

            var conversion = context.GetValue(_barConversion) ?? new NodeValue(0);

            return(value * (1 - conversion).Clip(0, 1));
        }
示例#19
0
 /// <summary>
 /// Returns the values of the nodes of all paths of the given type in the given stat's subgraph.
 /// </summary>
 public static IEnumerable <NodeValue?> GetValues(
     this IValueCalculationContext context, IStat stat, NodeType nodeType) =>
 context.GetPaths(stat).Select(p => context.GetValue(stat, nodeType, p));
 public static NodeValue?GetValue(
     this IValueCalculationContext context, IStat stat, NodeType nodeType = NodeType.Total)
 => context.GetValue(stat, nodeType, PathDefinition.MainPath);
示例#21
0
 public NodeValue?Calculate(IValueCalculationContext valueCalculationContext) =>
 _multiplier * (valueCalculationContext.GetValue(_stat) / _divisor).Select(Math.Ceiling);
示例#22
0
        public NodeValue?Calculate(IValueCalculationContext valueCalculationContext)
        {
            var path = new PathDefinition(_path.ModifierSource, _path.ConversionStats.Skip(1).ToArray());

            return(valueCalculationContext.GetValue(_path.ConversionStats[0], NodeType.Base, path));
        }
 public NodeValue?Calculate(IValueCalculationContext context) =>
 context.GetValue(_stat, NodeType.TotalOverride) ?? context.GetValue(_stat, NodeType.Subtotal);
示例#24
0
 public NodeValue?GetValue(IStat stat, NodeType nodeType, PathDefinition path) =>
 _originalContext.GetValue(stat, nodeType, path);