[−][src]Struct critfail::CheckOutcomeBuilder
This is used to create a 'fudged' CheckOutcome
without actually
randomly generating anything.
use critfail::CheckOutcomeBuilder; // To create a result that could come from rolling 'r+4-1d4' let outcome = CheckOutcomeBuilder::new() .check(10) .modifier(4) .dice(-4, vec![2]) .build(); assert_eq!(outcome.score(), 12); assert_eq!( format!("{:?}", outcome), "(10)+4-[2]" );
Implementations
impl CheckOutcomeBuilder
[src]
pub fn new() -> Self
[src]
Create a new CheckOutcomeBuilder
.
pub fn check_adv(self, r1: Score, r2: Score) -> Self
[src]
Set the check roll with advantage.
use critfail::CheckOutcomeBuilder; let outcome = CheckOutcomeBuilder::new() .check_adv(10, 12) .build(); assert_eq!(outcome.score(), 12); assert_eq!( format!("{:?}", outcome), "(12/10)" );
pub fn check_dis(self, r1: Score, r2: Score) -> Self
[src]
Set the check roll with disadvantage.
use critfail::CheckOutcomeBuilder; let outcome = CheckOutcomeBuilder::new() .check_dis(10, 12) .build(); assert_eq!(outcome.score(), 10); assert_eq!( format!("{:?}", outcome), "(10/12)" );
pub fn check(self, r: Score) -> Self
[src]
Set the check roll without advantage or disadvantage.
use critfail::CheckOutcomeBuilder; let outcome = CheckOutcomeBuilder::new() .check(8) .build(); assert_eq!(outcome.score(), 8); assert_eq!( format!("{:?}", outcome), "(8)" );
pub fn modifier(self, modifier: Score) -> Self
[src]
Add a constant modifier to the roll. This method can be chained multiple times for multiple modifiers.
use critfail::CheckOutcomeBuilder; // To create a result that could come from rolling 'r-2+6' let outcome = CheckOutcomeBuilder::new() .check(10) .modifier(-2) .modifier(6) .build(); assert_eq!(outcome.score(), 14); assert_eq!( format!("{:?}", outcome), "(10)-2+6" );
pub fn dice(self, sides: Sides, scores: Vec<Score>) -> Self
[src]
Add a dice modifier to the roll. This method can be chained
multiple times for multiple modifiers. sides
specifies the die
that was rolled.
use critfail::CheckOutcomeBuilder; // To create a result that could come from rolling 'r-2d4+1d6' let outcome = CheckOutcomeBuilder::new() .check(10) .dice(-4, vec![1, 2]) .dice(6, vec![5]) .build(); assert_eq!(outcome.score(), 12); assert_eq!( format!("{:?}", outcome), "(10)-[1+2]+[5]" );
pub fn build(self) -> CheckOutcome
[src]
Create a CheckOutcome
from this builder.
Trait Implementations
impl Default for CheckOutcomeBuilder
[src]
fn default() -> CheckOutcomeBuilder
[src]
Auto Trait Implementations
impl RefUnwindSafe for CheckOutcomeBuilder
impl Send for CheckOutcomeBuilder
impl Sync for CheckOutcomeBuilder
impl Unpin for CheckOutcomeBuilder
impl UnwindSafe for CheckOutcomeBuilder
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,