[][src]Struct critfail::CheckOutcomeBuilder

pub struct CheckOutcomeBuilder { /* fields omitted */ }

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]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,