diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2017-07-15 21:19:18 -0400 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2017-07-15 21:58:52 -0400 |
commit | 5597920f2561867db82cbd7dc5d81c34e6313364 (patch) | |
tree | 09caf2846bbaaf3861143f087f7f59cc78667a8e | |
parent | d939daae10c15b00652bf87625d87ad2eed1ce39 (diff) |
Update README
-rw-r--r-- | README.md | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -14,19 +14,18 @@ The API consists of three functions: * `parse(diceExpression)` parses an expression into an object understood by the other two functions. -* `pool(dice)` rolls each die in the `dice` object, returning an array of - results. +* `pool(dice)` rolls the dice and returns an array of their results. * `roll(dice)` rolls the dice and returns their sum. ### Examples const d6 = parse('1d6') - roll(d6) # 4 - roll(d6) # 5 - pool(d6) # [ 2 ] + roll(d6) // 4 + roll(d6) // 5 + pool(d6) // [ 2 ] const dice = parse('2d6 + 1d8') - roll(dice) # 10 - pool(dice) # [ 1, 4, 7 ] + roll(dice) // 10 + pool(dice) // [ 1, 4, 7 ] ## Dice expressions @@ -58,7 +57,7 @@ ignored): Semantics are defined in terms of the `pool` function. -* `N`, where an `N` is an integer, is a die that always rolls a single value +* `N`, where `N` is an integer, is a die that always rolls a single value equal to `N`. `pool` returns an array containing just `N`. * `DdE`, where `D` and `E` are dice expressions, is a die that rolls a number of dice equal to the result of rolling `D`, where each die has a number of sides @@ -74,6 +73,6 @@ Additionally: * The binary arithmetic operations (`+`, `-`) are left associative. * The die operation `d` is right associative (`1d2d3` is equivalent to - 1d(2d3)`, use explicit parentheses if you need `(1d2)d3`) + `1d(2d3)`, use explicit parentheses if you need `(1d2)d3`) * `d` binds stronger than the binary arithmetic operations (`1d6+1d4` is equivalent to `(1d6) + (1d4)`). |