Exemple #1
0
        public RollResult(IRollTarget target, SingleRollResult initialRollResult, SingleRollResult rerollResult, int modifierValue, int final)
        {
            Guard.Against.Null(target, nameof(target));
            Guard.Against.Null(initialRollResult, nameof(initialRollResult));

            InitialRollResult = initialRollResult;
            Target            = target;
            RerollResult      = rerollResult;
            ModifierValue     = modifierValue;
            Final             = final;
            IsSuccessful      = target.GetSuccessfulSides(initialRollResult.Die.TotalSides).Contains(final);
        }
Exemple #2
0
        internal Roll(Die die, IRollTarget target, IRerollBehaviour rerollOptions, IRollModifier modifier, INumberGenerator numberGenerator)
        {
            Guard.Against.Null(die, nameof(die));
            Guard.Against.Null(rerollOptions, nameof(rerollOptions));
            Guard.Against.Null(rerollOptions, nameof(rerollOptions));
            Guard.Against.Null(modifier, nameof(modifier));
            Guard.Against.Null(numberGenerator, nameof(numberGenerator));

            _die             = die;
            _target          = target;
            _rerollOptions   = rerollOptions;
            _modifier        = modifier;
            _numberGenerator = numberGenerator;
        }
Exemple #3
0
 public decimal CalculateProbability(Die die, IRollTarget target, IRollModifier modifier)
 {
     return(die.CalculateProbability(1) * die.CalculateProbability(target.GetModifiedSuccessfulSides(die.TotalSides, modifier).Count()));
 }
Exemple #4
0
 public bool RequiresReroll(SingleRollResult initial, IRollTarget target)
 {
     return(initial.SideRolled == 1);
 }
Exemple #5
0
 public IEnumerable <int> GetRerollSides(Die die, IRollTarget target)
 {
     return(new[] { 1 });
 }
 public bool RequiresReroll(SingleRollResult initial, IRollTarget target)
 {
     return(!target.GetSuccessfulSides(initial.Die.TotalSides).Contains(initial.SideRolled));
 }
 public IEnumerable <int> GetRerollSides(Die die, IRollTarget target)
 {
     return(die.GetSides().Except(target.GetSuccessfulSides(die.TotalSides)));
 }
        public decimal CalculateProbability(Die die, IRollTarget target, IRollModifier modifier)
        {
            var failures = die.TotalSides - target.GetSuccessfulSides(die.TotalSides).Count();

            return(die.CalculateProbability(failures) * die.CalculateProbability(target.GetModifiedSuccessfulSides(die.TotalSides, modifier).Count()));
        }
Exemple #9
0
 public bool RequiresReroll(SingleRollResult initial, IRollTarget target)
 {
     return(false);
 }
Exemple #10
0
 public decimal CalculateProbability(Die die, IRollTarget target, IRollModifier modifier)
 {
     return(0);
 }