Exemplo n.º 1
0
        /// <inheritdoc/>
        public IDiceSet Create(int quantity)
        {
            var dice = new DiceSet();

            for (int i = 0; i < quantity; i++)
            {
                // ReSharper disable once ExceptionNotDocumented
                dice.Add(new FateDie());
            }

            return(dice);
        }
Exemplo n.º 2
0
        public void TestDieSetRoll()
        {
            // create dice and set
            Die     d1  = new Die();
            Die     d2  = new Die();
            Die     d3  = new Die();
            DiceSet set = new DiceSet();

            set.Add(d1);
            set.Add(d2);
            set.Add(d3);

            // roll dice bag
            set.Roll();

            // add rolls of dice
            int total = d1.RollResult + d2.RollResult + d3.RollResult;

            // test that the set roll matches the dice rolls
            Assert.AreEqual <int>(total, set.RollResult, "Dieset roll does not match total value of rolled dice.");
        }
Exemplo n.º 3
0
        /// <inheritdoc/>
        /// <exception cref="T:System.ArgumentOutOfRangeException">Quantity is less than 1.</exception>
        /// <exception cref="T:System.ArgumentException">Type was supplied when it should have been null.</exception>
        public virtual IDiceSet Create(int quantity, int?type)
        {
            if (quantity < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(quantity), "must be greater than 0.");
            }

            if (type.HasValue)
            {
                throw new ArgumentException("must not be supplied.", nameof(type));
            }

            var dice = new DiceSet();

            for (int i = 0; i < quantity; i++)
            {
                // ReSharper disable once ExceptionNotDocumented
                dice.Add(new FateDie());
            }

            return(dice);
        }
Exemplo n.º 4
0
        /// <inheritdoc/>
        /// <exception cref="T:System.ArgumentOutOfRangeException">Quantity is less than 1 or faces is less than 2.</exception>
        public virtual IDiceSet Create(int quantity, int?type)
        {
            if (quantity < 1)
            {
                throw new ArgumentOutOfRangeException(nameof(quantity), "must be greater than 0.");
            }

            if (!type.HasValue || type.Value < 2)
            {
                throw new ArgumentOutOfRangeException(nameof(type), "must be 2 or greater.");
            }

            // figure out what type of die we need and return 1 or more instances based on the die code
            var dice = new DiceSet();

            for (int i = 0; i < quantity; i++)
            {
                // ReSharper disable once ExceptionNotDocumented
                dice.Add(new BasicDie(type.Value));
            }

            return(new DiceSet(dice));
        }