public void PrimaryAttribute_Refreshes_Mods_Value_With_Integer_Increase(float pctIncrease)
        {
            IAttributeMod pctMod = _mockAttr.AddPercentModifier(pctIncrease);

            _mockAttr.Increase((int)_dfValue);

            Assert.AreEqual(2 * _dfValue * pctIncrease, pctMod.ValueAsFloat());
        }
Ejemplo n.º 2
0
        public void Integer_Attribute_Correctly_Adds_Percent_Mod(int dfValue, float pctMod, int expected)
        {
            RPGAttribute  attr = Substitute.ForPartsOf <RPGAttribute>(AttributeType.Integer, dfValue);
            IAttributeMod mod  = attr.AddPercentModifier(pctMod);

            Assert.AreEqual(expected, mod.ValueAsInt());
            Assert.AreEqual(expected, mod.ValueAsFloat());
        }
Ejemplo n.º 3
0
        public void RPGAttribute_Correctly_Changes_Calculated_Mods_After_Removing_Flat_Mod()
        {
            IAttributeMod mod       = _mockAttr.AddFlatModifier(5);
            float         totalMods = _mockAttr.ModsValue;
            bool          removed   = _mockAttr.RemoveFlatModifier(mod);

            Assert.AreEqual(mod.ValueAsFloat(), totalMods);
            Assert.AreEqual(0f, _mockAttr.ModsValue);
        }
Ejemplo n.º 4
0
        public void Float_Attribute_Correctly_Adds_Flat_Mod(float flatMod)
        {
            RPGAttribute  attr = Setup(AttributeType.Float);
            IAttributeMod mod  = attr.AddFlatModifier(flatMod);

            float modVal = flatMod;

            Assert.AreEqual((int)modVal, mod.ValueAsInt());
            Assert.AreEqual(modVal, mod.ValueAsFloat());
        }
Ejemplo n.º 5
0
        public void RPGAttribute_Correctly_Changes_Calculated_Mods_After_Adding_Percent_Mod(int iterations)
        {
            float pctIncrease = 1f / (float)iterations;

            if (iterations == 0)
            {
                pctIncrease = 0;
            }

            float expected = 0;

            for (int i = 0; i < iterations; i++)
            {
                IAttributeMod mod = _mockAttr.AddPercentModifier(pctIncrease);
                expected += mod.ValueAsFloat();
            }

            Assert.AreEqual(expected, _mockAttr.ModsValue);
        }