示例#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);
        }
示例#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;
        }
示例#3
0
 public decimal CalculateProbability(Die die, IRollTarget target, IRollModifier modifier)
 {
     return(die.CalculateProbability(1) * die.CalculateProbability(target.GetModifiedSuccessfulSides(die.TotalSides, modifier).Count()));
 }
示例#4
0
 public bool RequiresReroll(SingleRollResult initial, IRollTarget target)
 {
     return(initial.SideRolled == 1);
 }
示例#5
0
 public IEnumerable <int> GetRerollSides(Die die, IRollTarget target)
 {
     return(new[] { 1 });
 }
示例#6
0
 public bool RequiresReroll(SingleRollResult initial, IRollTarget target)
 {
     return(!target.GetSuccessfulSides(initial.Die.TotalSides).Contains(initial.SideRolled));
 }
示例#7
0
 public IEnumerable <int> GetRerollSides(Die die, IRollTarget target)
 {
     return(die.GetSides().Except(target.GetSuccessfulSides(die.TotalSides)));
 }
示例#8
0
        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()));
        }
示例#9
0
 public bool RequiresReroll(SingleRollResult initial, IRollTarget target)
 {
     return(false);
 }
示例#10
0
 public decimal CalculateProbability(Die die, IRollTarget target, IRollModifier modifier)
 {
     return(0);
 }