Struct ndm::RollSet[][src]

pub struct RollSet { /* fields omitted */ }

Trait Implementations

impl Clone for RollSet[src]

impl Debug for RollSet[src]

impl<'de> Deserialize<'de> for RollSet[src]

impl Display for RollSet[src]

impl FromStr for RollSet[src]

In the syntax below, capital letters are variables and lower-case letters are verbatim. Optional fields are surrounded with [], mandatory fields are surrounded with <>.

In use, the parsed syntax is case insensitive and ignores internal spaces.

Dice may have no more than 1000 sides, not as a technical reason but because the number of times a d1001 or d2000 are needed should be vanishingly low.

Note that dice math is left to right:

  • 1 + 2 * 3 = 9, not 7
  • 1 + 2 * 3 + 4 * 5 = 65, not 27 (nor 29)
  • There’s no way to force precedence except for ordering
  • This is a feature; 2d6 + 4 * 2 + 1d6 is a common pattern

Line syntax: <M | X | R | C> [M | X | R | C]...

Example: lance 2d6 + 4 * 2 slashing + 1d6 fire

  • M: a modifier, defined below
  • X: a multiplier, defined below
  • R: a roll, defined below
  • C: a comment (anything that doesn’t match one of the above)

Bonus syntax: <+ | -> N

Examples: -5 or + 4

  • the sign is required
  • N is the value, and must be an integer
  • “+1.5” will be interpreted as +1 “.5”

Multiplier syntax: <x | *> F

Examples: x 1.5 or *2

  • x, X, and * are accepted
  • \x00d7 and \x2a09 aren’t accepted and will cause this to be parsed as a comment
  • F is either an integer or a floating point number
  • results are rounded down

Examples (sample use case in parens)

  • 3d8 (roll 3d8)
  • d20lh19! (roll a keen d20 which explodes, coloring 19s & 20s but not 1s) (not implemented)
  • 2d20/l (disadvantage, roll 2d20 but only keep the lower one)
  • 4d6/h3 (use a typical method to generate a stat)

Longer examples with surrounding modifiers and comments:

  • 3d8 bludgeoning (a damage roll)

  • d20l2h2+8 to hit (threat on 19-20, fail on 1-2)

  • 2d20/l+4 fort save with disadvantage

  • 4d6/h3 4d6/h3 4d6/h3 4d6/h3 4d6/h3 4d6/h3 chargen (the reader should ignore the total shown; external syntax should be created to roll without totalling)

  • The leading plus is optional

    • implemented
    • It’s normally used to join 2 rolls, but it isn’t required
    • Negative rolls aren’t parsed as such (the “-” is considered a comment)
  • N: the number of dice to roll

    • implemented
    • If missing, 1 is assumed
    • An explicit 0 is an error (to avoid interpreting 0d6 as “0” 1d6)
  • M: the number of sides

    • implemented
    • 0 is an error
    • 1 is legal but largely useless
    • f (or F) means Fate dice
    • If this is missing then the roll can’t be parsed as such and will be interpreted as a comment
  • X: the number of dice to keep

    • not implemented
    • /hX will mean keep the highest X rolls
    • /lX will mean keep the lowest X rolls
    • incompatible with ! (bang)
    • X > N is an error
    • X = N is ignored entirely
    • X = 0 is an error
    • must come after H and L if they’re present
  • ! means exploding

    • implemented for highest number only
    • must be the last thing on the dice roll
    • E means explode on E or higher, not just the highest number
    • E <= 1 is an error
    • E > N is ignored (but not an error)
    • Fate dice and one-sided dice can’t explode
    • exploded dice don’t count against the limit per roll (explosions don’t usually last long anyway)

type Err = RollParseError

The associated error which can be returned from parsing.

impl PartialEq<RollSet> for RollSet[src]

impl Serialize for RollSet[src]

impl StructuralPartialEq for RollSet[src]

Auto Trait Implementations

impl RefUnwindSafe for RollSet

impl Send for RollSet

impl Sync for RollSet

impl Unpin for RollSet

impl UnwindSafe for RollSet

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> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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>,