Пример #1
0
        /// <summary>
        /// Complete random roll of random count of random dice type
        /// </summary>
        /// <returns></returns>
        /// <remarks>There will be 1 to 9 rolled dices</remarks>
        public int Roll(IRandomizer rnd)
        {
            int dicesCount = rnd.GetNext(1, 10);
            string[] numDiceTypes = Enum.GetNames(typeof(Dices));
            int selectedDiceIndex = rnd.GetNext(numDiceTypes.Length);
            Dices selectedDice = (Dices)Enum.Parse(typeof(Dices), numDiceTypes[selectedDiceIndex]);

            return Roll(dicesCount, selectedDice, rnd);
        }
Пример #2
0
        /// <summary>
        /// Complete random roll of random count of random dice type
        /// </summary>
        /// <returns></returns>
        /// <remarks>There will be 1 to 9 rolled dices</remarks>
        public int Roll(IRandomizer rnd)
        {
            int dicesCount = rnd.GetNext(1, 10);

            string[] numDiceTypes      = Enum.GetNames(typeof(Dices));
            int      selectedDiceIndex = rnd.GetNext(numDiceTypes.Length);
            Dices    selectedDice      = (Dices)Enum.Parse(typeof(Dices), numDiceTypes[selectedDiceIndex]);

            return(this.Roll(dicesCount, selectedDice, rnd));
        }
Пример #3
0
 public void Setup()
 {
     _fieldFactory = new FakeFieldFactory();
     _randomizer   = Substitute.For <IRandomizer>();
     _randomizer.GetNext().Returns((uint)2);
     _uut = new Roulette(_fieldFactory, _randomizer);
 }
Пример #4
0
        // TODO: make it singleton and IDebugable

        public int Roll(int count, int diceSides, IRandomizer rnd)
        {
            int result = rnd.GetNext(count, diceSides * count + 1);

            //DoDebugLog(string.Format("Dice roll: {0}d{1} = {2}", count, diceSides, result));

            return(result);
        }
Пример #5
0
        // TODO: make it singleton and IDebugable

        public int Roll(int count, int diceSides, IRandomizer rnd)
        {
            int result = rnd.GetNext(count, diceSides * count + 1);

            //DoDebugLog(string.Format("Dice roll: {0}d{1} = {2}", count, diceSides, result));

            return result;
        }
        public void Init()
        {
            randomizer     = Substitute.For <IRandomizer>();
            fieldGenerator = Substitute.For <IFieldGenerator>();

            randomizer.GetNext(0, 1).Returns((uint)0);
            fieldGenerator.CreateFields().Returns(new List <Field> {
                new Field(0, color: Field.Green)
            });

            uut = new Roulette(fieldGenerator, randomizer);
        }
        public T DrawElement(IRandomizer randomizer)
        {
            if (this._revolver != null)
            {
                return(this._revolver.DrawElement(randomizer));
            }
            else
            {
                int  rnd        = randomizer.GetNext(0, (int)this._totalScale);
                uint totalScore = 0;
                foreach (T element in this._elements)
                {
                    totalScore += element.ProbabilityWeight;
                    if (totalScore >= rnd)
                    {
                        return(element);
                    }
                }

                // closing element
                return(this._elements[this._elements.Count]);
            }
        }
Пример #8
0
        public void Spin()
        {
            var n = _randomizer.GetNext();

            _result = _fields[(int)n];
        }
            public T DrawElement(IRandomizer randomizer)
            {
                int rnd = randomizer.GetNext(0, (int)this._totalScale);

                return(this._cylinder[rnd]);
            }
Пример #10
0
        public void Spin()
        {
            var n = _randomizer.GetNext(Lowerbound, Higherbound);

            _result = _fields[(int)n];
        }