Root RPG
The @randsum/games/root-rpg subpath provides mechanics for Root RPG, a tabletop roleplaying game set in the world of the Root board game. It uses a 2d6 + bonus system with success thresholds similar to Powered by the Apocalypse games.
Official Site Root RPG by Magpie Games
Installation
Section titled “Installation”bun add @randsum/gamesnpm install @randsum/gamesimport { roll } from '@randsum/games/root-rpg'
// Roll with a stat bonusconst { result, total } = roll(2)// result: 'Strong Hit' | 'Weak Hit' | 'Miss'import { roll } from '@randsum/games/root-rpg'
const { result } = roll(0)
switch (result) {case 'Strong Hit': // 10+ total: complete success breakcase 'Weak Hit': // 7-9 total: partial success with cost breakcase 'Miss': // 6- total: failure break}import { roll } from '@randsum/games/root-rpg'
roll(2) // Strong statroll(0) // No bonusroll(-1) // Penaltyroll(bonus: number)
Section titled “roll(bonus: number)”Input:
| Parameter | Type | Description |
|---|---|---|
bonus | number | Stat modifier (-20 to +20) |
Returns: GameRollResult with:
| Property | Type | Description |
|---|---|---|
result | RootRpgRollResult | 'Strong Hit' | 'Weak Hit' | 'Miss' |
total | number | Sum of 2d6 + bonus |
rolls | RollRecord[] | Raw dice data from the core roller |
Outcomes
Section titled “Outcomes”| Outcome | Total | Description |
|---|---|---|
Strong Hit | 10+ | Complete success — you achieve your goal |
Weak Hit | 7-9 | Partial success — you do it, but with a cost or complication |
Miss | 6- | Failure — things go badly |
Error handling
Section titled “Error handling”Game roll() can throw two types of errors:
ValidationError(from@randsum/roller) — numeric input out of range or not finite (e.g.,bonus: 999when max is 20)SchemaError(from@randsum/games/root-rpg) — game-specific issues like unmatched outcome tables
import { roll, SchemaError } from '@randsum/games/root-rpg'import { ValidationError } from '@randsum/roller'
try {roll(999)} catch (error) {if (error instanceof ValidationError) { // Out-of-range bonus (must be -20 to 20) console.log(error.code) // 'VALIDATION_ERROR'} else if (error instanceof SchemaError) { // Game-specific error console.log(error.code) // 'NO_TABLE_MATCH'}}import type { RootRpgRollResult, GameRollResult, RollRecord } from '@randsum/games/root-rpg'import { SchemaError } from '@randsum/games/root-rpg'Schema
Section titled “Schema”This game is powered by a .randsum.json spec that defines the 2d6+bonus resolution and outcome tiers. The TypeScript code is generated from this spec at build time. See Schema Overview for how game specs work.