Пример #1
0
        public void Roll2D63D8()
        {
            var diceCup = new DiceCup();
            var dice    = diceCup.Roll(6, 6, 8, 8, 8);

            Assert.True(dice.Count() == 5);
        }
Пример #2
0
        public void DiceCup_RollTwoTimesAndCheckFinalizedState_FinalizedStateIsFalse()
        {
            // Arrange
            var die  = _dieMock.Object;
            var dice = new List <IDie> {
                die, die, die, die, die
            };

            // Act
            var diceCup = new DiceCup(dice);

            diceCup.Roll();
            diceCup.Roll();

            // Assert
            diceCup.IsFinal().Should().BeFalse();
        }
        public string Get()
        {
            var sb = new StringBuilder();

            if (!string.IsNullOrEmpty(effectDescription))
            {
                sb.Append(effectDescription + "; ");
            }

            int i = 0;

            while (i < (numberOfReRolls - 1))
            {
                sb.Append(effectFactory.GetFactory(tableDiceRoll.Roll()).Get() + "; ");
                i++;
            }
            sb.Append(effectFactory.GetFactory(tableDiceRoll.Roll()).Get());
            return(sb.ToString());
        }
Пример #4
0
        public void DiceCup_RollThreeTimesAndPreventFourthRoll_ReturnsNull()
        {
            // Arrange
            var die  = _dieMock.Object;
            var dice = new List <IDie> {
                die, die, die, die, die
            };

            // Act
            var diceCup = new DiceCup(dice);

            diceCup.Roll();
            diceCup.Roll();
            diceCup.Roll();

            // Assert
            IEnumerable <IDie> finalRoll = diceCup.Roll();

            finalRoll.Should().BeNull();
        }
Пример #5
0
        public void DiceCup_InitialRollSaveFirstThreeValues_ThreeDiceInTheCupWerePlacedInTheHeldState()
        {
            // Arrange
            var die  = _dieMock.Object;
            var dice = new List <IDie> {
                die, die, die, die, die
            };

            // Act
            var diceCup = new DiceCup(dice);

            diceCup.Roll();
            diceCup.Hold(0, 1, 2);

            //Assert
            _dieMock.VerifySet(x => x.State = DieState.Held, Times.Exactly(3));
        }
Пример #6
0
        public void DiceCup_InitialRoll_DieValuesMatchMockedDieValues()
        {
            // Arrange
            var die  = _dieMock.Object;
            var dice = new List <IDie> {
                die, die, die, die, die
            };
            var expectedResult = new[] { 4, 3, 2, 1, 2 };

            // Act
            var diceCup = new DiceCup(dice);

            diceCup.Roll();
            IEnumerable <IDie> rollResult = diceCup.Dice;

            // Assert
            rollResult.Select(x => x.Value).ToList().Should().BeEquivalentTo(expectedResult);
        }
Пример #7
0
        public void DiceCup_InitialRollHoldThreeValuesUnholdTwoValues_ThreeDiceInTheCupWerePlacedInTheHeldStateAndTwoDiceInTheCupWerePlacedInTheThrowableState()
        {
            // Arrange
            var die  = _dieMock.Object;
            var dice = new List <IDie> {
                die, die, die, die, die
            };

            // Act
            var diceCup = new DiceCup(dice);

            diceCup.Roll();
            diceCup.Hold(0, 2, 4);
            diceCup.Unhold(2, 4);

            // Assert
            _dieMock.VerifySet(x => x.State = DieState.Held, Times.Exactly(3));
            _dieMock.VerifySet(x => x.State = DieState.Throwable, Times.Exactly(2));
        }
Пример #8
0
        static void Main(string[] args)
        {
            DiceCup cup = new DiceCup();

            // Role the dice 100 times...
            for (int i = 0; i < 100; i++)
            {
                List <int> results = cup.Roll(2);

                int total = 0;
                foreach (int r in results)
                {
                    total += r;
                }

                Console.WriteLine(String.Format("Roll result = {0}", total));
            }

            Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Rollem' Simulated Dice Rolling App");
            DiceCup cup = new DiceCup
            {
                new Die(10),
                new Die(12),
                new Die(6)
            };

            // cup.GenerateKnownRoll(1);

            int[] dieResults = cup.Roll();
            Console.Write("Die Results: ");
            foreach (int result in dieResults)
            {
                Console.Write(result);
                Console.Write(" ");
            }
            Console.Write(" Total = ");
            Console.WriteLine(cup.LastDiceRollTotal);
        }
Пример #10
0
 public string Get()
 {
     return(gasTrapContents + " " + gasTrapContentFactory.GetFactory(gasTrapTableDie.Roll()).Get());
 }
Пример #11
0
        public string Get()
        {
            var mechanism = mechanismFactory.GetFactory(mechanismTableDie.Roll()).Get();

            return(string.Format("{0} ({1})", effectDescription, mechanism));
        }
Пример #12
0
 private void OnRollDice(object sender, EventArgs e)
 {
     _diceCup.Roll();
     View.ShowDiceRolling(_diceCup);
 }
 public void ShowDiceRolling(DiceCup diceCup)
 {
     int[] rolledDice = diceCup.Roll();
 }
 public string GetTrapDamageFactory()
 {
     return(trapDamagesFactory.GetFactory(trapDamageTableDie.Roll()).Get());
 }
 public string GetTrapEffectFactory()
 {
     return(effectFactory.GetFactory(effectPrimaryTableDie.Roll()).Get());
 }
 public string GetTrapBaseFactory()
 {
     return(trapBaseFactory.GetFactory(basePrimaryTableDie.Roll()).Get());
 }
Пример #17
0
        public void Dice_Test()
        {
            NDice dice = new NDice(6);

            for (int i = 0; i < 20; i++)
            {
                Assert.AreEqual(InRange(dice.Roll(), 1, 7), true);
            }

            dice = new Dice6();

            for (int i = 0; i < 20; i++)
            {
                Assert.AreEqual(InRange(dice.Roll(), 1, 7), true);
            }

            dice = new Dice8();

            for (int i = 0; i < 20; i++)
            {
                Assert.AreEqual(InRange(dice.Roll(), 1, 9), true);
            }

            dice = new Dice12();

            for (int i = 0; i < 20; i++)
            {
                Assert.AreEqual(InRange(dice.Roll(), 1, 13), true);
            }


            DiceCup cup = new DiceCup(6, 2);

            int[] results;
            for (int i = 0; i < 20; i++)
            {
                results = cup.Roll();

                foreach (int result in results)
                {
                    Assert.AreEqual(InRange(result, 1, 7), true);
                }

                Assert.AreEqual(InRange(results.Sum(), 2, 13), true);
            }


            DynamicDiceCup dynamicCup = new DynamicDiceCup();

            dynamicCup += new Dice12();
            dynamicCup.PushDice(new Dice6());


            for (int i = 0; i < 20; i++)
            {
                results = dynamicCup.Roll();

                Assert.AreEqual(InRange(results[0], 1, 13), true);
                Assert.AreEqual(InRange(results[1], 1, 7), true);

                Assert.AreEqual(InRange(results.Sum(), 2, 19), true);
            }

            dynamicCup--;

            Assert.AreEqual(dynamicCup.Count, 1);

            Assert.AreEqual(dynamicCup.PopDice().GetType(), typeof(Dice12));

            Assert.AreEqual(dynamicCup.Count, 0);

            try
            {
                dynamicCup.Roll();
                throw new Exception("Roll() didn't throw an exception. It should have been empty.");
            }
            catch (InvalidOperationException) { }
        }
 public string Get()
 {
     return(pitTrapContents + " " + pitContentEffectFactory.GetFactory(pitTrapTableDie.Roll()).Get());
 }
 public string Get()
 {
     return(effectDescription + "\r\n" + effectFactory.GetFactory(mainTableDice.Roll()).Get());
 }