Ejemplo n.º 1
0
        /// <summary>
        /// Perform a series of die rolls and keep the best results
        /// </summary>
        /// <param name="NumberOfRolls"></param>
        /// <param name="KeepHowMany"></param>
        /// <returns></returns>
        public DieRollResults MultiRoll(int NumberOfRolls, int KeepHowMany)
        {
            // make the required number of rolls
            DieRollResults rolls = new DieRollResults();

            for (int i = 0; i < NumberOfRolls; i++)
            {
                rolls.Add(this.Roll());
            }

            // keep at least 1 and not more than we rolled
            rolls.KeepBest(Math.Min(Math.Max(KeepHowMany, 1), NumberOfRolls));
            return(rolls);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Results sorted in ascending or descending order
        /// </summary>
        /// <param name="sortOrder"></param>
        /// <returns></returns>
        public DieRollResults Sorted(SortOrder sortOrder)
        {
            DieRollResults list = new DieRollResults();

            for (int i = 0; i < this.Count; i++)
            {
                list.Add(this[i]);
            }
            list.Sort();
            if (sortOrder == SortOrder.Descending)
            {
                list.Reverse();
            }
            return(list);
        }