diced

Types

pub type Dice {
  Basic(amount: Int, value: Int, modifiers: List(Modifier))
  Fate(amount: Int, modifiers: List(Modifier))
  Number(value: Int, modifiers: List(Modifier))
}

Constructors

  • Basic(amount: Int, value: Int, modifiers: List(Modifier))

    A “normal” dice roll with an amount, value and a list of modifiers to apply

  • Fate(amount: Int, modifiers: List(Modifier))

    A fate dice roll with an amount, and a list of modifiers to apply. Fate dice are dice with 3 results, all with an equal number of faces. Learn more

  • Number(value: Int, modifiers: List(Modifier))

    A basic number and some modifiers that could be applied.

pub type DiceError {
  InvalidAmount
  InvalidString
  InvalidValue
  InvalidModifier
}

Constructors

  • InvalidAmount
  • InvalidString
  • InvalidValue
  • InvalidModifier
pub type Modifier {
  KeepHighest(Int)
  KeepLowest(Int)
  DropHighest(Int)
  DropLowest(Int)
  Reroll(Int)
  RecursiveReroll(Int)
  Explode(Int)
  Minimum(Int)
  Maximum(Int)
}

Constructors

  • KeepHighest(Int)
  • KeepLowest(Int)
  • DropHighest(Int)
  • DropLowest(Int)
  • Reroll(Int)
  • RecursiveReroll(Int)
  • Explode(Int)
  • Minimum(Int)
  • Maximum(Int)

Values

pub fn parse(string string: String) -> Result(Dice, DiceError)

Convert a string containing algebraic dice notation into a type describing how the dice should behave when rolled.

diced.parse("2d20kh")
// Ok(diced.Basic(2, 20, [KeepHighest(1)]))
Search Document