示例#1
0
        public void SetUp()
        {
            _mockDice = Fixture.Mock <IDice>();
            _mockDice.Setup(d => d.Roll()).Callback(() => _lastDecoratedDieRoll = Fixture.Create <IRoll>()).Returns(() => _lastDecoratedDieRoll);

            _diceWithCache = new DiceWithCacheDecorator(_mockDice.Object);
        }
        public IRoll Roll()
        {
            var roll = _decoratedDice.Roll();

            _lastRoll = roll;
            return(roll);
        }
示例#3
0
        public string RollOnRoll(IRoll roll)
        {
            string rollOnRollResult = string.Empty;

            using (var utility = new RandomUtility())
            {
                if (roll.TypeOfRoll == GmDashboardTypes.StandardRoll || roll.TypeOfRoll == GmDashboardTypes.RangeRoll || roll.TypeOfRoll == GmDashboardTypes.TextRoll)
                {
                    var chartRoll = (StandardRoll)roll;
                    //TODO  THIS SHOULD BE USEING THE DICE NUMBER TO PICK THE ROLL...
                    //THE REASON WE ARE NOT IS BECAUSE WE HAVE NOT FULL GOTTEN THE PRECENT ROLL
                    var diceOutcome = utility.RollDice(((StandardRoll)roll).Outcomes.Count) - 1;

                    var resultOfRoll = chartRoll.Outcomes.ElementAt(diceOutcome);
                    if (resultOfRoll.TypeOfRoll == GmDashboardTypes.StandardRoll)
                    {
                        chartRoll.Outcome += chartRoll.Description + RollOnRoll(resultOfRoll);
                    }
                    else
                    {
                        var outcome = chartRoll.Description + " " + resultOfRoll.GetDescription;
                        chartRoll.Outcome = outcome;
                        return(outcome);
                    }
                }
                return("");
            }
        }
示例#4
0
        public void Register(IRoll roll)
        {
            _bonusMultiplier.Register(roll.Type);
            var rollScore = _bonusMultiplier.Current * roll.PinsKnocked;

            Score += rollScore;
        }
示例#5
0
 private IEnumerable <RollResult> TestRoll(IRoll rolls)
 {
     foreach (var roll in rolls.Results)
     {
         RollResultDisposition result = roll.Value + Modifier >= TargetValue ? RollResultDisposition.Pass : RollResultDisposition.Fail;
         yield return(new RollResult(roll.Value, result));
     }
 }
示例#6
0
        public void no_possible_success_if_AP_too_strong()
        {
            Save save             = new Save(1);
            var  allPossibleDices = new IRoll[]
            {
                new OnlyRollOne(),
                new OnlyRollTwo(),
                new OnlyRollThree(),
                new OnlyRollFour(),
                new OnlyRollFive(),
                new OnlyRollSix()
            };

            var rolls = allPossibleDices.Select(d => save.Roll(d, 6));

            Assert.IsTrue(rolls.All(r => r.Missed));
        }
示例#7
0
 private static bool IsEmpty(IRoll next)
 {
     return !(next.IsHit || next.IsSpare || next.IsStrike);
 }
示例#8
0
 public Roll(char roll, IRoll next = null)
 {
     _roll = roll;
     Next = next ?? new NullRoll();
 }
示例#9
0
 public TestedRoll(int targetValue, int modifier, IRoll roll)
 {
     TargetValue = targetValue;
     Modifier    = modifier;
     Results     = TestRoll(roll);
 }
示例#10
0
 public void Register(IRoll roll)
 {
     _bonusMultiplier.Register(roll.Type);
     var rollScore = _bonusMultiplier.Current * roll.PinsKnocked;
     Score += rollScore;
 }