public decimal CalculateProbability() { var successfulSides = _target.GetModifiedSuccessfulSides(_die.TotalSides, _modifier).ToArray(); var rerollSides = _rerollOptions.GetRerollSides(_die, _target).ToArray(); var initialSuccessfulSides = successfulSides.Except(rerollSides); var baseProbability = _die.CalculateProbability(initialSuccessfulSides.Count()); var rerollProbability = _rerollOptions.CalculateProbability(_die, _target, _modifier); return(baseProbability + rerollProbability); }
public decimal CalculateProbability(Die die, IRollTarget target, IRollModifier modifier) { return(die.CalculateProbability(1) * die.CalculateProbability(target.GetModifiedSuccessfulSides(die.TotalSides, modifier).Count())); }
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())); }