Пример #1
0
        /// <summary>
        /// Throw the dice with minimum and maximum value
        /// </summary>
        /// <param name="min">Minimum allowed value for each dice throw</param>
        /// <param name="max">Maximum allowed value for each dice throw</param>
        /// <returns></returns>
        public int ThrowDice(int min, int max)
        {
            var total = 0;

            for (var i = 0; i < GetNumberOfDice; i++)
            {
                var addedNumber = 0;
                var attempts    = 0;

                //CodeRev: There's something off about this logic. Why do I never use addednumber?
                while (addedNumber <= min || addedNumber >= max || attempts > 10)
                {
                    addedNumber = Calc.GetRandomNumber(min, max);
                    attempts++;
                }

                if (attempts < 10)
                {
                    total += Calc.GetRandomNumber(min, GetSizeOfDice);
                }
                else
                {
                    total += Calc.GetAverageNumber(min, max);
                }
            }

            return(total);
        }
Пример #2
0
        /// <summary>
        /// Throw the dice with minimum value
        /// </summary>
        /// <param name="min">Minimum allowed value for each dice throw</param>
        /// <returns>Throws the number of dice and returns the value</returns>
        public int ThrowDice(int min)
        {
            var total = 0;

            for (var i = 0; i < GetNumberOfDice; i++)
            {
                total += Calc.GetRandomNumber(min, GetSizeOfDice);
            }

            return(total);
        }
Пример #3
0
 /// <summary>
 /// This method sets the PC's Height variable to a
 /// random double within the parameters of the race's
 /// lowest and highest allowed height.
 /// </summary>
 public void SetRandomHeight(DungeonsRace race)
 {
     Height = Calc.GetRandomNumber(
         (int)race.AverageHeight.AverageLow,
         (int)race.AverageHeight.AverageHigh);
 }