Skip to content

Commit

Permalink
Fix final table in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
christhekeele committed Mar 3, 2023
1 parent 03a5bf8 commit 8553c57
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 33 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Dice expressions let you describe rolling multiple dice of different sizes, and

| Operation | Expression | Interpretation | Example | Meaning | Notes |
| :---: | ---: | :--- | ---: | :--- | :--- |
| ***Roll*** | `dS` | Roll a die with `S` sides. | `d20` | Roll 1 `d20`. | Equivalent to ***Roll Many***: `1dS`. Equivalent to ***Range Die***: `d{1..20}`. |
| ***Addition*** | `dS + C` | Roll `N` dice with `S` sides, and add a constant value `C` from the result. | `d20 + 5` | Roll 1 `d20` and add `5` to the result. | |
| ***Subtraction*** | `dS - C` | Roll `N` dice with `S` sides, and subtract a constant value `C` from the result. | `d20 - 2` | Roll 1 `d20` and subtract `2` from the result. | |
| ***Roll*** | `dS` | Roll a die with `S` sides. | `d20` | Roll one `d20`. | Equivalent to ***Roll Many***: `1dS`. Equivalent to ***Range Die***: `d{1..20}`. |
| ***Addition*** | `dS + C` | Roll a die with `S` sides, and add `C` to the result. | `d20 + 1` | Roll one `d20` and add `1` to the result. | |
| ***Subtraction*** | `dS - C` | Roll a die with `S` sides, and subtract `C` from the result. | `d20 - 2` | Roll 1 `d20` and subtract `2` from the result. | |
| ***Roll Many*** | `NdS` | Roll `N` dice with `S` sides and add the results. | `3d6` | Roll 3 `d6` and add the results. | |
| ***Roll Different*** | `NdS + MdT + C` | Roll `N` dice with `S` sides, `M` dice with `T` sides, and add all together plus `C`. | `3d6 + d4 + 2` | Roll 3 `d6`, one `d4`, and add `2` to the results. | |

Expand Down Expand Up @@ -143,7 +143,7 @@ While `dS` syntax describes a die with `S` sides, with numbers `1`-`S` on those
Common custom die have shortcut aliases for easier use.

| Die | Expression | Interpretation | Notes |
| :---: | ---: | :--- | ---: | :--- | :--- |
| :---: | ---: | :--- | :--- |
| ***Percent Die*** | `d%` | Roll a `d100` to represent a probabilistic outcome. | Equivalent to ***Roll***: `d100`. |
| ***Standard Fudge Die*** | `dF` | Roll a 3-sided die with values `-1`, `0`, and `1` on the sides. | Equivalent to ***Range Die***: `d[-1..1]`. |
| ***Fudge Die*** | `dFN` | Roll a `2N + 1`-sided die with values between `-S` and `S`, including `0`. | Equivalent to ***Range Die***: `d[-S..S]`. |
28 changes: 0 additions & 28 deletions lib/dice/expression.ex
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
defprotocol Dice.Expression.Evaluate do
def evaluate(node)
end

defmodule Dice.Expression.Term do
import Dice.Parser.Builder

defparser do
choice([
parsec({Dice.Pool.Parser, :combinator}),
parsec({Dice.Constant.Parser, :combinator}),
])
end

end

defmodule Dice.Expression.Operation do
import Dice.Parser.Builder

defparser do
choice([
parsec({Dice.Operator.Addition.Parser, :combinator}),
parsec({Dice.Operator.Subtraction.Parser, :combinator}),
])
end

end

defmodule Dice.Expression do
defstruct [:expression]

Expand Down
3 changes: 3 additions & 0 deletions lib/dice/expression/evaluate.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defprotocol Dice.Expression.Evaluate do
def evaluate(node)
end
11 changes: 11 additions & 0 deletions lib/dice/expression/operation.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defmodule Dice.Expression.Operation do
import Dice.Parser.Builder

defparser do
choice([
parsec({Dice.Operator.Addition.Parser, :combinator}),
parsec({Dice.Operator.Subtraction.Parser, :combinator})
])
end

end
11 changes: 11 additions & 0 deletions lib/dice/expression/term.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
defmodule Dice.Expression.Term do
import Dice.Parser.Builder

defparser do
choice([
parsec({Dice.Pool.Parser, :combinator}),
parsec({Dice.Constant.Parser, :combinator}),
])
end

end
File renamed without changes.
1 change: 0 additions & 1 deletion lib/dice/parser/builder.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
defmodule Dice.Parser.Builder do
alias URI.Error
defmacro defparser(args \\ [], do: combinator) do
Module.put_attribute(__CALLER__.module, :combinator, combinator)

Expand Down

0 comments on commit 8553c57

Please sign in to comment.