Пример #1
0
        public void DefaultReroll_ShouldBeNone()
        {
            var rollBuilder = RollBuilder.WithDie(Die.D6)
                              .Targeting(Target.ValueAndAbove(4)) as RollBuilder;

            rollBuilder.RerollBehaviour.GetType().Should().Be <RerollNone>();
        }
Пример #2
0
        public void DefaultRollModifier_ShouldBeNoModifier()
        {
            var rollBuilder = RollBuilder.WithDie(Die.D6)
                              .Targeting(Target.ValueAndAbove(4)) as RollBuilder;

            rollBuilder.RollModifier.GetType().Should().Be <NoModifier>();
        }
        public void GivenD6_NoReroll_NoModifier(int valueAndAboveTarget)
        {
            var roll = RollBuilder.WithDie(Die.D6)
                       .Targeting(Target.ValueAndAbove(valueAndAboveTarget))
                       .Build();

            // Calc - SuccessfulSideCount / Sides
            var expectedProbability = (7 - valueAndAboveTarget) / 6m;

            CheckProbability(roll, expectedProbability);
        }
Пример #4
0
        public void GivenD6_NoReroll_NoModifier(int numberToGenerate, int expected)
        {
            var roll = RollBuilder.WithDie(Die.D6)
                       .WithNumbers(new ForcedNumberGenerator(numberToGenerate))
                       .Targeting(Target.ValueAndAbove(3))
                       .Build();

            var result = roll.Simulate();

            _output.WriteLine(result.ToString());
            result.Final.Should().Be(expected);
        }
Пример #5
0
        public void GivenD6_RerollFailures_NoModifier(int targeting, int initialRoll, int reroll, bool expectedReroll, int expectedFinal, bool expectedSuccess)
        {
            var roll = RollBuilder.WithDie(Die.D6)
                       .WithNumbers(new ForcedNumberGenerator(initialRoll, reroll))
                       .Targeting(Target.ValueAndAbove(targeting))
                       .WithReroll(Reroll.Failures)
                       .Build();

            var result = roll.Simulate();

            _output.WriteLine(result.ToString());
            ValidateRollResult(result, initialRoll, reroll, expectedReroll, expectedFinal, expectedSuccess);
        }
        public void GivenD6_RerollOnes_WhenOneIsSuccess()
        {
            var die  = Die.D6;
            var roll = RollBuilder.WithDie(die)
                       .Targeting(Target.ValueAndAbove(1))
                       .WithReroll(Reroll.Ones)
                       .Build();

            // Calc - If the base probability is already 100%, reroll should not increase it further as you should not be rerolling.
            var expectedProbability = 1m;

            CheckProbability(roll, expectedProbability);
        }
        public void GivenD6_RerollOnes(int valueAndAboveTarget)
        {
            var die  = Die.D6;
            var roll = RollBuilder.WithDie(die)
                       .Targeting(Target.ValueAndAbove(valueAndAboveTarget))
                       .WithReroll(Reroll.Ones)
                       .Build();

            // Calc - (SuccessfulSideCount / Sides) + ((1 / Sides) * (SuccessfulSideCount / Sides))
            var decimalSides        = (decimal)die.TotalSides;
            var successfulSideCount = die.TotalSides + 1 - valueAndAboveTarget;
            var expectedProbability = successfulSideCount / decimalSides + 1 / decimalSides * (successfulSideCount / decimalSides);

            CheckProbability(roll, expectedProbability);
        }
        public void GivenD6_RerollOnes_ModifierDecreaseByOne(int valueAndAboveTarget)
        {
            var modifier = -1;
            var die      = Die.D6;
            var roll     = RollBuilder.WithDie(die)
                           .Targeting(Target.ValueAndAbove(valueAndAboveTarget))
                           .WithReroll(Reroll.Ones)
                           .WithModifier(modifier)
                           .Build();

            // Calc - See CalcRerollWithModifier
            var successfulSideCount = die.TotalSides + 1 - valueAndAboveTarget;
            var expectedProbability = CalcProbabilityForRerollWithModifier(die.TotalSides, successfulSideCount, 1, modifier);

            CheckProbability(roll, expectedProbability);
        }
        public void GivenD6_NoReroll_ModifierDecreaseByOne(int valueAndAboveTarget)
        {
            var modifier = -1;
            var die      = Die.D6;
            var roll     = RollBuilder.WithDie(die)
                           .Targeting(Target.ValueAndAbove(valueAndAboveTarget))
                           .WithReroll(Reroll.None)
                           .WithModifier(-1)
                           .Build();

            // Calc - ((SuccessfulSideCount + ModifierAmount) / Sides)
            var decimalSides        = (decimal)die.TotalSides;
            var successfulSideCount = die.TotalSides + 1 - valueAndAboveTarget;
            var expectedProbability = (successfulSideCount + modifier) / decimalSides;

            CheckProbability(roll, expectedProbability);
        }