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); }
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; }
public decimal CalculateProbability(Die die, IRollTarget target, IRollModifier modifier) { return(die.CalculateProbability(1) * die.CalculateProbability(target.GetModifiedSuccessfulSides(die.TotalSides, modifier).Count())); }
public bool RequiresReroll(SingleRollResult initial, IRollTarget target) { return(initial.SideRolled == 1); }
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())); }
public bool RequiresReroll(SingleRollResult initial, IRollTarget target) { return(false); }
public decimal CalculateProbability(Die die, IRollTarget target, IRollModifier modifier) { return(0); }