private static int GetRollModifierByPerkRule(Equipment?equipment, int efficientModifierValue,
                                              PerkRuleSubScheme rule)
 {
     if (rule.Params is null || string.IsNullOrWhiteSpace(rule.Params))
     {
         efficientModifierValue = RuleCalculations.CalcEfficientByRuleLevel(efficientModifierValue, rule.Level);
     }
Exemple #2
0
        private static int GetRollModifierByPerkRule(Equipment equipment, int efficientModifierValue,
                                                     PerkRuleSubScheme rule)
        {
            if (string.IsNullOrWhiteSpace(rule.Params))
            {
                efficientModifierValue = RuleCalculations.CalcEfficientByRuleLevel(efficientModifierValue, rule.Level);
            }
            else
            {
                var damagePerkParams = JsonConvert.DeserializeObject <DamagePerkParams>(rule.Params);
                if (damagePerkParams.WeaponTags != null && equipment != null)
                {
                    var hasAllTags = true;
                    foreach (var requiredTag in damagePerkParams.WeaponTags)
                    {
                        if (equipment.Scheme.Tags?.Contains(requiredTag) != true)
                        {
                            hasAllTags = false;
                            break;
                        }
                    }

                    if (hasAllTags)
                    {
                        efficientModifierValue =
                            RuleCalculations.CalcEfficientByRuleLevel(efficientModifierValue, rule.Level);
                    }
                }
            }

            return(efficientModifierValue);
        }
Exemple #3
0
        public void CalcEfficientByRuleLevel_AllKnownLevels_NotThrowException(int currentModifier,
                                                                              PersonRuleLevel level)
        {
            // ACT
            Action act = () =>
            {
                var _ = RuleCalculations.CalcEfficientByRuleLevel(currentModifier, level);
            };

            // ASSERT
            act.Should().NotThrow <NotSupportedException>();
        }