Exemple #1
0
        public static decimal GetMagnitude(IAlchemyEffect effect, decimal powerFactor)
        {
            var magnitudeFactor = effect.PowerAffectsMagnitude()
                ? powerFactor
                : 1;

            return(Math.Round(effect.Magnitude * magnitudeFactor, MidpointRounding.AwayFromZero));
        }
Exemple #2
0
        public static decimal GetDuration(IAlchemyEffect effect, decimal powerFactor)
        {
            var durationFactor = effect.PowerAffectsDuration()
                ? powerFactor
                : 1;

            return(Math.Round(Math.Max(effect.Duration, 0) * durationFactor, MidpointRounding.AwayFromZero));
        }
Exemple #3
0
        private static decimal GetPoisonerPerkFactor(IAlchemyEffect effect, IEnumerable <IPerk <AlchemySkill> > perks)
        {
            var hasPoisonerPerk = perks.OfType <PoisonerPerk>().Any();

            return(hasPoisonerPerk && !effect.IsPositiveEffect
                ? 25
                : 0);
        }
        public void SameEffect(IAlchemyEffect effect)
        {
            var result = Subject.Create(effect, 1, 1, 1);

            result.Should().BeOfType(AllAlchemyEffects.CureDisease.GetType());
            result.Cost.Should().Be(1);
            result.Duration.Should().Be(1);
            result.Magnitude.Should().Be(1);
        }
Exemple #5
0
        public static decimal GetPerks(IAlchemyEffect effect, IEnumerable <IPerk <AlchemySkill> > perks)
        {
            var alchemistPerkFactor  = GetAlchemistPerkFactor(perks);
            var physicianPerkFactor  = GetPhysicianPerkFactor(effect, perks);
            var benefactorPerkFactor = GetBenefactorPerkFactor(effect, perks);
            var poisonerPerkFactor   = GetPoisonerPerkFactor(effect, perks);

            return((1 + alchemistPerkFactor / 100)
                   * (1 + physicianPerkFactor / 100)
                   * (1 + benefactorPerkFactor / 100 + poisonerPerkFactor / 100));
        }
Exemple #6
0
        public static decimal GetCost(IAlchemyEffect effect, decimal magnitude, decimal duration)
        {
            var magnitudeFactor = magnitude > 0
                ? magnitude
                : 1;

            var durationFactor = duration > 0
                ? duration / 10
                : 1;

            return(Math.Floor(effect.Cost * (decimal)Math.Pow((double)(magnitudeFactor * durationFactor), 1.1)));
        }
 private static IAlchemyEffect Create(
     this IAlchemyEffect effect,
     decimal costFactor      = 1,
     decimal durationFactor  = 1,
     decimal magnitudeFactor = 1)
 {
     return(new AlchemyEffectFactory()
            .Create(
                effect,
                effect.Cost * costFactor,
                effect.Duration * durationFactor,
                effect.Magnitude * magnitudeFactor));
 }
Exemple #8
0
        private static decimal GetPhysicianPerkFactor(IAlchemyEffect effect, IEnumerable <IPerk <AlchemySkill> > perks)
        {
            var hasPhysicianPerk         = perks.OfType <PhysicianPerk>().Any();
            var isRestoreAttributeEffect = new []
            {
                AllAlchemyEffects.RestoreHealth,
                AllAlchemyEffects.RestoreMagicka,
                AllAlchemyEffects.RestoreStamina
            }.Contains(effect, new IHasIdEqualityComparer());

            return(hasPhysicianPerk && isRestoreAttributeEffect
                ? 25
                : 0);
        }
Exemple #9
0
        protected void TestAndAssert(
            IAlchemyEffect effect,
            decimal baseCost,
            decimal cost,
            decimal duration,
            decimal magnitude)
        {
            var results = Subject.GetResults(effect, Options.Object);

            results.BaseCost.Should().Be(baseCost);
            results.Cost.Should().Be(cost);
            results.Duration.Should().Be(duration);
            results.Magnitude.Should().Be(magnitude);
        }
        public AlchemyFormulaeResults GetResults(IAlchemyEffect effect, IAlchemyOptions options)
        {
            var baseFactor = BaseFormulae.GetBase(effect, options);
            var perkFactor = PerksFormulae.GetPerks(effect, options.Perks);

            var baseMagnitude = MagnitudeFormulae.GetMagnitude(effect, baseFactor);
            var magnitude     = MagnitudeFormulae.GetMagnitude(effect, baseFactor * perkFactor);

            var baseDuration = DurationFormulae.GetDuration(effect, baseFactor);
            var duration     = DurationFormulae.GetDuration(effect, baseFactor * perkFactor);

            var baseCost = CostFormulae.GetCost(effect, baseMagnitude, baseDuration);
            var cost     = CostFormulae.GetCost(effect, magnitude, duration);

            return(new AlchemyFormulaeResults(
                       baseCost,
                       cost,
                       duration,
                       magnitude));
        }
        public void Test(
            IAlchemyEffect effect,
            decimal baseCost,
            decimal cost,
            decimal duration,
            decimal magnitude)
        {
            Options
            .Setup(x => x.Perks)
            .Returns(new [] { Perk });

            Options
            .Setup(x => x.AlchemyLevel)
            .Returns(SkillConstants.MaxLevel);

            Options
            .Setup(x => x.FortifyAlchemyPercent)
            .Returns(0);

            TestAndAssert(effect, baseCost, cost, duration, magnitude);
        }
        public void Test(
            IAlchemyEffect effect,
            decimal baseCost,
            decimal cost,
            decimal duration,
            decimal magnitude)
        {
            Options
            .Setup(x => x.Perks)
            .Returns(Enumerable.Empty <IPerk <AlchemySkill> >());

            Options
            .Setup(x => x.AlchemyLevel)
            .Returns(SkillConstants.MaxLevel);

            Options
            .Setup(x => x.FortifyAlchemyPercent)
            .Returns(50);

            TestAndAssert(effect, baseCost, cost, duration, magnitude);
        }
 public static bool PowerAffectsDuration(this IAlchemyEffect e) => durationAffects.Contains(e);
Exemple #14
0
 public IAlchemyEffect Create(IAlchemyEffect e, decimal cost, decimal duration, decimal magnitude) => map[e](cost, duration, magnitude);
Exemple #15
0
        public void Magnitude(IAlchemyEffect effect, decimal expected)
        {
            var actual = effect.ScaleMagnitude(2);

            actual.Magnitude.Should().Be(expected);
        }
Exemple #16
0
        public void Duration(IAlchemyEffect effect, decimal expected)
        {
            var actual = effect.ScaleDuration(2);

            actual.Duration.Should().Be(expected);
        }
Exemple #17
0
        public void Cost(IAlchemyEffect effect, decimal expected)
        {
            var actual = effect.ScaleCost(2);

            actual.Cost.Should().Be(expected);
        }
 public IEffectIngredientPriority Create(IAlchemyEffect effect) => effectMap[effect];
Exemple #19
0
 public static decimal GetBase(IAlchemyEffect effect, IAlchemyOptions options)
 {
     return(AlchemyConstants.IngredientMultiplier
            * (1 + (AlchemyConstants.AlchemySkillFactor - 1) * (decimal)options.AlchemyLevel / 100)
            * (1 + options.FortifyAlchemyPercent / 100));
 }
 internal static IAlchemyEffect ScaleCost(this IAlchemyEffect effect, decimal factor)
 {
     return(Create(effect, costFactor: factor));
 }
 internal static IAlchemyEffect ScaleDuration(this IAlchemyEffect effect, decimal factor)
 {
     return(Create(effect, durationFactor: factor));
 }
 public static bool PowerAffectsMagnitude(this IAlchemyEffect e) => !durationAffects.Contains(e);
 internal static IAlchemyEffect ScaleMagnitude(this IAlchemyEffect effect, decimal factor)
 {
     return(Create(effect, magnitudeFactor: factor));
 }
Exemple #24
0
        public void SameEffect(IAlchemyEffect effect)
        {
            var result = Subject.Create(effect);

            result.Should().BeOfType(typeof(DamageHealthIngredientPriority));
        }