Пример #1
0
        public void HasSameValuesTest()
        {
            var b = new StatCollection <ST>(StatCollectionType.Base);

            b[ST.A] = 10;
            b[ST.B] = 11;

            foreach (var c in CreateStatCollections())
            {
                c[ST.A] = 0;
                c[ST.B] = 0;

                Assert.IsFalse(c.HasSameValues(b));
                Assert.IsFalse(b.HasSameValues(c));

                c[ST.A] = 10;

                Assert.IsFalse(c.HasSameValues(b));
                Assert.IsFalse(b.HasSameValues(c));

                c[ST.B] = 11;

                Assert.IsTrue(c.HasSameValues(b));
                Assert.IsTrue(b.HasSameValues(c));

                c[ST.A] = 0;

                Assert.IsFalse(c.HasSameValues(b));
                Assert.IsFalse(b.HasSameValues(c));
            }
        }
Пример #2
0
        /// <summary>
        /// Checks if this ItemEntity can be stacked with another ItemEntity. To stack, both items must contain the same
        /// stat modifiers, name, description, value, and graphic index.
        /// </summary>
        /// <param name="source">Item to check if can stack on this ItemEntity.</param>
        /// <returns>True if the two items can stack on each other, else false.</returns>
        public bool CanStack(ItemEntity source)
        {
            // Check for equal reference
            if (ReferenceEquals(this, source))
            {
                // Although it makes sense for an ItemEntity to be able to stack onto itself,
                // there is no reason this should ever happen intentionally
                const string errmsg =
                    "Trying to stack an ItemEntity `{0}` onto itself. Although this is not an error, " +
                    "it makes no sense why it would be attempted.";
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat(errmsg, this);
                }
                Debug.Fail(string.Format(errmsg, this));
                return(true);
            }

            // Check for non-equal values
            if (Value != source.Value || GraphicIndex != source.GraphicIndex || Type != source.Type || Name != source.Name ||
                Description != source.Description || Range != source.Range || WeaponType != source.WeaponType)
            {
                return(false);
            }

            // Check for non-equal stats
            if (!BaseStats.HasSameValues(source.BaseStats) || !ReqStats.HasSameValues(source.ReqStats))
            {
                return(false);
            }

            // Everything important is equal, so they can be stacked
            return(true);
        }
Пример #3
0
        void AssertModStatsAreCorrect()
        {
            var oldValues = _modStats.DeepCopy();

            RecalculateStatBonuses();
            if (!_modStats.HasSameValues(oldValues))
            {
                Debug.Fail("Somehow, at some point, the ModStats became out of sync!");
            }
        }
Пример #4
0
        public void HasSameValuesTest()
        {
            var b = new StatCollection<ST>(StatCollectionType.Base);
            b[ST.A] = 10;
            b[ST.B] = 11;

            foreach (var c in CreateStatCollections())
            {
                c[ST.A] = 0;
                c[ST.B] = 0;

                Assert.IsFalse(c.HasSameValues(b));
                Assert.IsFalse(b.HasSameValues(c));

                c[ST.A] = 10;

                Assert.IsFalse(c.HasSameValues(b));
                Assert.IsFalse(b.HasSameValues(c));

                c[ST.B] = 11;

                Assert.IsTrue(c.HasSameValues(b));
                Assert.IsTrue(b.HasSameValues(c));

                c[ST.A] = 0;

                Assert.IsFalse(c.HasSameValues(b));
                Assert.IsFalse(b.HasSameValues(c));
            }
        }