# `Srd.Dice`
[🔗](https://github.com/autodidaddict/agentic-realms/tree/main/packages/srd_5e/blob/main/lib/srd/dice.ex#L1)

Dice rolling for SRD 5.2 resolution.

# `d20`

Performs a d20 roll. Options can modify the number of D20s rolled:

* `:advantage` - Rolls 2d20 and takes the max
* `:disadvantage` - Rolls 2d20 and takes the min

Normal behavior is a 1d20.

# `roll`

```elixir
@spec roll(
  String.t() | Srd.Dice.Expr.t(),
  keyword()
) :: Srd.Dice.Roll.t()
```

Roll a dice expression and return an immutable `Srd.Dice.Roll`.

Takes a notation string or a parsed `Srd.Dice.Expr`. The `:reduce` option names
how the dice are combined before the modifier is added. The default is `:sum`

    iex> Srd.Dice.roll("2d6+3")
    %Srd.Dice.Roll{count: 2, sides: 6, modifier: 3, dice: [4, 5], reduce: :sum, total: 12}

    iex> Srd.Dice.roll("2d20", reduce: :max)   # advantage
    %Srd.Dice.Roll{count: 2, sides: 20, modifier: 0, dice: [7, 18], reduce: :max, total: 18}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
