예제 #1
0
        public void RPGAttribute_Does_Nothing_When_Removing_Inexistent_Percent_Mod()
        {
            IAttributeMod mod     = Substitute.For <IAttributeMod>();
            bool          removed = _mockAttr.RemovePercentModifier(mod);

            Assert.IsFalse(removed);
            Assert.IsFalse(_changed);
        }
        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());
        }
예제 #3
0
        public void RPGAttribute_Correctly_Removes_Percent_Modifier()
        {
            IAttributeMod mod     = _mockAttr.AddPercentModifier(1);
            bool          removed = _mockAttr.RemovePercentModifier(mod);

            Assert.IsTrue(removed);
            Assert.IsTrue(_changed);
        }
예제 #4
0
        public void RPGAttribute_Correctly_Removes_Flat_Modifier()
        {
            IAttributeMod mod     = _mockAttr.AddFlatModifier(5);
            bool          removed = _mockAttr.RemoveFlatModifier(mod);

            Assert.IsTrue(removed);
            Assert.IsTrue(_changed);
        }
예제 #5
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());
        }
예제 #6
0
        public void RPGAttribute_Correctly_Changes_Calculated_Mods_After_Removing_Percent_Mod()
        {
            IAttributeMod mod       = _mockAttr.AddPercentModifier(1);
            float         totalMods = _mockAttr.ModsValue;
            bool          removed   = _mockAttr.RemovePercentModifier(mod);

            Assert.AreEqual(_dfValue, totalMods);
            Assert.AreEqual(0f, _mockAttr.ModsValue);
        }
예제 #7
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);
        }
예제 #8
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());
        }
예제 #9
0
        /// <summary>
        /// Removes a percent modifier from the Attribute.
        /// Updates the Mods value and fires onAttributeChanged if the modifier
        /// were succesfully removed
        /// </summary>
        /// <param name="pctMod">The Modifier to be removed from the PctMods</param>
        /// <returns>True if the modifier was removed. False otherwise</returns>
        public bool RemovePercentModifier(IAttributeMod pctMod)
        {
            bool removed = _percentMods.Remove(pctMod);

            if (removed)
            {
                _modsValue = CalculateMods();
                RaiseAttributeChanged();
            }

            return(removed);
        }
예제 #10
0
        /// <summary>
        /// Removes a flat modifier from the Attribute.
        /// Updates the Mods value and fires onAttributeChanged if the modifier
        /// were succesfully removed
        /// </summary>
        /// <param name="flatMod">The Modifier to be removed from the FlatMods</param>
        /// <returns>True if the modifier was removed. False otherwise</returns>
        public bool RemoveFlatModifier(IAttributeMod flatMod)
        {
            bool removed = _flatMods.Remove(flatMod);

            if (removed)
            {
                _modsValue = CalculateMods();
                RaiseAttributeChanged();
            }

            return(removed);
        }
예제 #11
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);
        }