Esempio n. 1
0
        public void Add(DiceRoll other)
        {
            // If the other is zero, nothing to do.
            if (other.Equals(Zero))
                return;

            // If we're zero, take their values
            if (this.Equals(Zero))
            {
                Rolls = other.Rolls;
                DiceFaces = other.DiceFaces;
                Multiplier = other.Multiplier;
                ToAdd = other.ToAdd;
                return;
            }

            // If neither are zero, the d'ness better match
            if (DiceFaces != other.DiceFaces)
                throw new InvalidOperationException(string.Format("Can't add dice rolls: {0} + {1}", this, other));

            Rolls += other.Rolls;
            ToAdd += other.ToAdd;
            Multiplier += 1 - other.Multiplier;
        }