@randsum/5e
TypeScript icon, indicating that this package has built-in type declarations

0.1.36 • Public • Published

@randsum/5e

5th Edition compatible dice rolling for randsum

npm version bundle size Types License Downloads

A type-safe implementation of 5th Edition dice rolling mechanics that supports:

  • 🎲 Standard d20 rolls with advantage/disadvantage
  • 🎯 Automatic handling of modifiers
  • 🔒 Full TypeScript support
  • 🎮 Perfect for 5e compatible applications
  • 🪶 Tree-shakeable implementation

Installation

npm install @randsum/5e
# or
yarn add @randsum/5e
# or
bun add @randsum/5e

Usage

import { roll5e, meetOrBeat5e } from '@randsum/5e'
import type { RollArgument5e } from '@randsum/5e'

// Basic roll with modifier
roll5e({ modifier: 5 })

// Roll with advantage
roll5e({
  modifier: 5,
  rollingWith: 'Advantage'
})

// Roll with disadvantage
roll5e({
  modifier: -2,
  rollingWith: 'Disadvantage'
})

// Check if roll meets or beats DC
const roll: RollArgument5e = {
  modifier: 5,
  rollingWith: 'Advantage'
}
meetOrBeat5e(15, roll) // Returns true if roll meets or exceeds DC 15

API Reference

roll5e

Makes a d20 roll following 5th Edition rules.

const result = roll5e({
  modifier: 5, // the result of your bonuses after all bonuses are applied
  rollingWith: 'Advantage' // Optional
})
// Returns a roll result with total and details

meetOrBeat5e

Checks if a roll meets or exceeds a Difficulty Class (DC).

const success = meetOrBeat5e(15, {
  modifier: 5,
  rollingWith: 'Advantage'
})
// Returns true if roll + modifier meets or exceeds 15

Related Packages

Made with 👹 by RANDSUM

Package Sidebar

Install

npm i @randsum/5e

Weekly Downloads

50

Version

0.1.36

License

MIT

Unpacked Size

51.4 kB

Total Files

20

Last publish

Collaborators

  • alxjrvs