@randsum/root-rpg
Version:
A flexible, type-safe dice roller for the Root RPG system
81 lines (62 loc) âĸ 2.35 kB
Markdown
<div align="center">
<img width="150" height="150" src="https://raw.githubusercontent.com/RANDSUM/randsum/refs/heads/main/icon.webp" alt="Randsum Logo">
<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 { rollRootRpg } from "@randsum/root-rpg"
import type { RootRpgRollResult } from "@randsum/root-rpg"
// Basic roll with modifier
const { outcome, roll, result } = rollRootRpg(2)
// outcome: 'Strong Hit' | 'Weak Hit' | 'Miss'
// roll: numeric total, result: detailed roll information
// Type-safe result handling
const { outcome } = rollRootRpg(0)
switch (outcome) {
case "Strong Hit":
// 10 or higher
break
case "Weak Hit":
// 7-9
break
case "Miss":
// 6 or lower
break
}
```
## API Reference
### `rollRootRpg`
Makes a 2d6 roll following Root RPG rules, returning an object with the interpreted result and numeric details.
```typescript
function rollRootRpg(bonus: number): RootRpgRollResult
```
```typescript
type RootResult = RootStrongHit | RootWeakHit | RootMiss
type RootStrongHit = "Strong Hit"
type RootWeakHit = "Weak Hit"
type RootMiss = "Miss"
```
## Related Packages
- [@randsum/roller](https://github.com/RANDSUM/randsum/tree/main/packages/roller): Core dice rolling implementation
<div align="center">
Made with đš by <a href="https://github.com/RANDSUM">RANDSUM</a>
</div>