コード例 #1
0
 public DiceRollModel(int die, int sides, int rollModifier, int totalModifier)
 {
     Die           = die;
     Sides         = sides;
     RollModifier  = rollModifier;
     TotalModifier = totalModifier;
     Rolls         = DiceService.Roll(die, sides, rollModifier);
     Total         = Accumulate(Rolls) + TotalModifier;
     Description   = ToString();
 }
コード例 #2
0
        public void DiceWithSixOnceSuccessfully()
        {
            diceService = new DiceService();
            DiceThrowVM result;

            result = diceService.Roll(6, 1);

            Assert.True(result.Result[0] <= 6);
            Assert.True(result.Result[0] >= 0);
        }
コード例 #3
0
        public int AwardBonusMoves(DiceService diceService, RobotDifficulty difficulty)
        {
            if (difficulty != RobotDifficulty.Difficult)
            {
                return(0);
            }

            var bonusMoves = diceService.Roll(3);

            MovesRemaining = MovesRemaining + bonusMoves;
            return(bonusMoves);
        }
コード例 #4
0
        public void Should_roll_dice_multiple_times(int times, int sides, int expected)
        {
            var random = Mock.Create <IRandomHelper>();

            Mock.Arrange(() => random.Next()).Occurs(times);

            var roller = new DiceService(random);

            var totalRoll = roller.Roll(times, sides);

            Assert.AreEqual(expected, totalRoll);
        }
コード例 #5
0
 public int Attack(DiceService diceService)
 {
     return(diceService.Roll(DamageMaximum));
 }