Esempio n. 1
0
        /// <summary>
        /// The + operator for adding RollResult.
        /// </summary>
        /// <param name="x">The first RollResult.</param>
        /// <param name="y">The second RollResult.</param>
        /// <returns>The resulting RollResult adding both rolls</returns>
        public static RollResult operator +(RollResult x, RollResult y)
        {
            RollResult result = new RollResult();
            result.Total = x.Total + y.Total;
            result.Mod = x.Mod + y.Mod;
            result.Rolls.AddRange(x.Rolls);
            result.Rolls.AddRange(y.Rolls);

            return result;
        }
Esempio n. 2
0
        /// <summary>
        /// The + operator for adding RollResult.
        /// </summary>
        /// <param name="x">The first RollResult.</param>
        /// <param name="y">The second RollResult.</param>
        /// <returns>The resulting RollResult adding both rolls</returns>
        public static RollResult operator +(RollResult x, RollResult y)
        {
            RollResult result = new RollResult();

            result.Total = x.Total + y.Total;
            result.Mod   = x.Mod + y.Mod;
            result.Rolls.AddRange(x.Rolls);
            result.Rolls.AddRange(y.Rolls);

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Make a random roll for this DieRoll
        /// </summary>
        /// <returns>A RollResult object with the resulting rolling of the dice.</returns>
        public RollResult Roll()
        {
            RollResult result = new RollResult();

            result.Mod   = this.Mod;
            result.Total = this.Mod;

            foreach (DieRollElement element in this.AllRolls)
            {
                for (int i = 0; i < element.Count; i++)
                {
                    DieResult res = new DieResult();
                    res.Die       = element.Die;
                    res.Result   += Random.Next(1, element.Die + 1);
                    result.Total += res.Result;
                    result.Rolls.Add(res);
                }
            }

            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// Make a random roll for this DieRoll
        /// </summary>
        /// <returns>A RollResult object with the resulting rolling of the dice.</returns>
        public RollResult Roll()
        {
            RollResult result = new RollResult();
            result.Mod = this.Mod;
            result.Total = this.Mod;

            foreach (DieRollElement element in this.AllRolls)
            {
                for (int i = 0; i < element.Count; i++)
                {
                    DieResult res = new DieResult();
                    res.Die = element.Die;
                    res.Result += Random.Next(1, element.Die + 1);
                    result.Total += res.Result;
                    result.Rolls.Add(res);
                }
            }

            return result;
        }