Esempio n. 1
0
 public void GetXForYTotal_WhenNoEffect_ShouldReturnPaidFor(Formula formula, ITechnologyManager technologyManager)
 {
     technologyManager.GetEffects(EffectCode.XFor1, EffectInheritance.Invisible).Returns(new List <Effect>());
     formula.GetXForYTotal(technologyManager, 0).Should().Be(0);
     formula.GetXForYTotal(technologyManager, 1).Should().Be(1);
     formula.GetXForYTotal(technologyManager, 99).Should().Be(99);
 }
Esempio n. 2
0
        public void GetXForYTotal_WhenMultipleEffects_ShouldUseTheHighestValue(Formula formula, ITechnologyManager technologyManager)
        {
            var effects = new List <Effect>
            {
                new Effect
                {
                    Id        = EffectCode.XFor1,
                    IsPrivate = true,
                    Location  = EffectLocation.Object,
                    Value     = new object[] { 5, 3 }
                },
                new Effect
                {
                    Id        = EffectCode.XFor1,
                    IsPrivate = true,
                    Location  = EffectLocation.Object,
                    Value     = new object[] { 2, 1 }
                },
                new Effect
                {
                    Id        = EffectCode.XFor1,
                    IsPrivate = true,
                    Location  = EffectLocation.Object,
                    Value     = new object[] { 3, 2 }
                }
            };

            technologyManager.GetEffects(EffectCode.XFor1, EffectInheritance.Invisible).Returns(effects);
            formula.GetXForYTotal(technologyManager, 100).Should().Be(200);
        }
Esempio n. 3
0
        public void TrainTime_WhenHasDiscount_ShouldLowerTime(int baseTime,
                                                              int structureLevel,
                                                              int expected,
                                                              ITechnologyManager techManager,
                                                              ICity city,
                                                              IBaseUnitStats baseUnitStats,
                                                              Formula formula)
        {
            techManager.GetEffects(0).ReturnsForAnyArgs(new List <Effect>());
            baseUnitStats.BuildTime.Returns(baseTime);

            formula.TrainTime(structureLevel, 2, baseUnitStats).Should().Be(expected * 2);
        }
Esempio n. 4
0
        /// <summary>
        ///     Returns the total unit for the price of paidFor
        /// </summary>
        /// <param name="tech"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public virtual int GetXForYPaidFor(ITechnologyManager tech, int total)
        {
            var effects = tech.GetEffects(EffectCode.XFor1, EffectInheritance.Invisible);

            if (effects.Count == 0)
            {
                return(total);
            }

            var effect = effects.OrderByDescending(x => (decimal)(int)x.Value[0] / (int)x.Value[1]).First();

            return((int)Math.Ceiling((decimal)total / (int)effect.Value[0] * (int)effect.Value[1]));
        }
Esempio n. 5
0
        public void GetXForYTotal_WhenXForY(int x, int y, int paidForCount, int expectTotalCount, Formula formula, ITechnologyManager technologyManager)
        {
            var effect = new Effect
            {
                Id        = EffectCode.XFor1,
                IsPrivate = true,
                Location  = EffectLocation.Object,
                Value     = new object[] { x, y }
            };

            technologyManager.GetEffects(EffectCode.XFor1, EffectInheritance.Invisible).Returns(new List <Effect> {
                effect
            });
            formula.GetXForYTotal(technologyManager, paidForCount).Should().Be(expectTotalCount);
        }