Skip to content

Commit

Permalink
chore: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
evilmonkeyinc committed Oct 21, 2021
1 parent 1eb5c88 commit b557bf6
Showing 1 changed file with 41 additions and 2 deletions.
43 changes: 41 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,45 @@ A simple library to take die rolling shorthand and return the result

## Installing

`npm install @evilmonkeyinc/die-roller`
This library ahs been published to NPM and can be installed with npm or yarn

`yarn add @evilmonkeyinc/die-roller`
```npm
npm install @evilmonkeyinc/die-roller
````
```yarn
yarn add @evilmonkeyinc/die-roller
```

The library will be compatible with both javascript and typescript

## Usage

```
import { parse } from '@evilmonkeyinc/die-roller'
...
const parsedExpression = parse('4d6k3')
console.log(parsedExpression.result);
// will return a number between 3 and 18
```

The `parse` function will take a die expression shorthand and evaluate it and return the result.

The expression should be in the format `{number of die}d{size of die}{options}`

The options are used to perform simple actions on the die results before giving back the result, such as `2d20k1` which would return the higher of two d20 rolls or `4d6k3` which would return the result of the best three d6 rolls out of 4.

| Option | Description |
| ---------- | --------------------------------------------- |
| k{number} | Keep only the highest {number} of die results |
| kh{number} | Keep only the highest {number} of die results |
| kl{number} | Keep only the lowest {number} of die results |
| d{number} | Drop the lowest {number} of die results |
| dl{number} | Drop the lowest {number} of die results |
| dh{number} | Drop the highest {number} of die results |

You can also chain expressions, or simply add or subtract whole numbers for the result by appending a `+` or `-` to an expression if you need to include modifiers to your results.

`1d20+2+3` for your Palidin attacking with their Longsword, with their 2 in proficiency and 3 strength. You hit, and decide to SMITE the enemy, you could then roll `1d8+3+2d8` for damage, `1d8+3` for the weapon and `2d8` for a Divine Smite at 1st level

0 comments on commit b557bf6

Please sign in to comment.