Exemple #1
0
        public double GetMitigatedAmount(double amount, Entity source, Entity target)
        {
            bool crited;

            if (CriticalChance != null)
            {
                MeNode resolvedCritChance = Sanitizer.ReplaceTargetAndSource(CriticalChance, source, target)
                                            .Resolve();

                crited = Utils.Utility.Chance(resolvedCritChance.Value.ToDouble());
            }
            else
            {
                crited = false;
            }

            double mutliplier = 1.0;

            if (crited)
            {
                if (CriticalModifier != null)
                {
                    mutliplier = Sanitizer.ReplaceTargetAndSource(CriticalModifier, source, target)
                                 .Resolve().Value.ToDouble();
                }
            }

            double finalAmount = mutliplier * amount;

            if (Mitigation != null)
            {
                MeNode mitigation = Sanitizer.SanitizeMitigation(Mitigation, target, source, finalAmount)
                                    .Resolve();
                return(mitigation.Value.ToDouble());
            }
            else
            {
                return(finalAmount);
            }
        }