Esempio n. 1
0
        /// <summary> Returns a <see cref="String" /> that represents this instance. </summary>
        /// <returns> A <see cref="String" /> that represents this instance. </returns>
        public override string ToString()
        {
            Contract.Ensures(Contract.Result <string>() != null);

            // Flag which will stop "1" being shown as a dice count, so "1d6" will be shown as just"d6".
            bool useCountString;

            if (RollCountProvider is FixedDie)
            {
                int fixedCount = (int)((FixedDie)RollCountProvider).Roll();
                useCountString = (fixedCount > 1);
            }
            else
            {
                useCountString = (RollCountProvider != null);
            }

            string count = useCountString ? RollCountProvider.ToString() : String.Empty;
            string value = RollValueProvider.ToString();

            return(count + value);
        }
Esempio n. 2
0
        private int GetDiceCount()
        {
            Contract.Ensures(Contract.Result <int>() >= 0);

            return((RollCountProvider != null) ? Math.Max(0, (int)RollCountProvider.Roll()) : 1);
        }