@randsum/root-rpg
Version:
A flexible, type-safe dice roller for the Root RPG system
82 lines (63 loc) âĸ 2.39 kB
Markdown
<div align="center">
<img width="150" height="150" src="https://raw.githubusercontent.com/RANDSUM/randsum/main/icon.webp">
<h1>@randsum/root-rpg</h1>
<h3>Root RPG compatible dice rolling for randsum</h3>
[](https://www.npmjs.com/package/@randsum/root-rpg)
[](https://bundlephobia.com/package/@randsum/root-rpg)
[](https://www.npmjs.com/package/@randsum/root-rpg)
[](https://github.com/RANDSUM/randsum/blob/main/LICENSE)
[](https://www.npmjs.com/package/@randsum/root-rpg)
</div>
A small collection of utilities for [Root RPG](https://magpiegames.com/collections/root)!
- đ˛ Standard Root RPG (2d6+N) rolls
- đ¯ Automatic handling of modifiers
- đ Full TypeScript support
- đĒļ smol (not larger than a wolf)
## Installation
```bash
npm install @randsum/root-rpg
# or
yarn add @randsum/root-rpg
# or
bun add @randsum/root-rpg
```
## Usage
```typescript
import { rollRoot } from '@randsum/root-rpg'
import type { RootResult } from '@randsum/root-rpg'
// Basic roll with modifier
const [outcome, details] = rollRoot(2)
// outcome: 'Strong Hit' | 'Weak Hit' | 'Miss'
// details: Contains the numeric roll result
// Type-safe result handling
const [result] = rollRoot(0)
switch (result) {
case 'Strong Hit':
// 10 or higher
break
case 'Weak Hit':
// 7-9
break
case 'Miss':
// 6 or lower
break
}
```
## API Reference
### `rollRoot`
Makes a 2d6 roll following Root RPG rules, returning both the interpreted result and the numeric details.
```typescript
function rollRoot(bonus: number): [RootResult, NumericRollResult]
```
```typescript
type RootResult = RootStrongHit | RootWeakHit | RootMiss
type RootStrongHit = 'Strong Hit'
type RootWeakHit = 'Weak Hit'
type RootMiss = 'Miss'
```
## Related Packages
- [@randsum/dice](https://github.com/RANDSUM/randsum/tree/main/packages/dice): Core dice rolling implementation
- [@randsum/notation](https://github.com/RANDSUM/randsum/tree/main/packages/notation): Dice notation parser
<div align="center">
Made with đš by <a href="https://github.com/RANDSUM">RANDSUM</a>
</div>