8000 GitHub - RANDSUM/randsum: A flexible, type-safe dice rolling ecosystem written in Typescript
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A flexible, type-safe dice rolling ecosystem written in Typescript

Notifications You must be signed in to change notification settings

RANDSUM/randsum

Repository files navigation

Randsum Logo. A Dotted D6 rolled a 6 with the dots arranged to look like an R.

Randsum

An Ergonomic, flexible, and type-safe dice rolling ecosystem for NPM

License CI Status Bun Built with Moon TypeScript NPM Downloads Maintenance Types

🚀 Quick Example

import { D20, roll } from '@randsum/dice'

// Simple d20 roll
D20.roll() // Returns 1-20

// Complex dice notation
roll('4d6L') // Roll 4d6, drop lowest

// D&D 5e character ability score generation
const abilityScores = Array.from({ length: 6 }, () => roll('4d6L').sum)

// Advantage and disadvantage
roll('2d20H') // Roll with advantage (2d20, keep highest)
roll('2d20L') // Roll with disadvantage (2d20, keep lowest)

Or directly from your terminal:

npx randsum 2d20    # Roll two twenty-sided dice
npx randsum 4d6L    # Character stat roll (drop lowest)
npx randsum 2d20H   # Roll with advantage

📦 Packages

This monorepo contains the following packages and applications:

npm version bundle size Types Downloads

A Flexible, Type-safe, and Tree-shakeable dice rolling implementation. Where it all started. Optimized for minimal bundle size.

npm install @randsum/dice

npm version bundle size Types Downloads

Dice notation parser and validator, for parsing Randsum Dice Notation.

npm install @randsum/notation

npm version bundle size Types Downloads

A dice roller compatible with 5th Edition RPG Systems

npm install @randsum/5e

npm version bundle size Types Downloads

A dice roller for the Root RPG system.

npm install @randsum/root-rpg

npm version bundle size Types Downloads

A dice roller for Blades in the dark (and forged in the dark) RPG systems.

npm install @randsum/blades

npm version bundle size Types Downloads

A dice roller for the Salvage Union RPG system. Contains all official Salvage Union roll tables, and a contextual roll function for determining success.

npm install @randsum/salvageunion

@randsum/core

npm version bundle size Types

Internal package containing shared utilities and types. Not intended for direct usage. All types are exported in each subsequent package for ease of use.

🛠️ Development

This is a monorepo powered by Moon and Bun. To get started:

# Clone the repository
git clone https://github.com/RANDSUM/randsum.git
cd randsum

# Install dependencies for all packages
bun install

# Build all packages
bun moon :build

# Run tests
bun moon :test

# Run type checks
bun moon :tsCheck

# Lint and format
bun moon :lint
bun moon :format

Moon Tasks

Moon manages our task pipeline and dependencies. Common tasks include:

  • :build - Build all packages
  • :test - Run all tests
  • :lint - Run ESLint checks
  • :format - Run Prettier checks
  • :tsCheck - Run TypeScript checks
  • :publish - Publish packages (CI only)
  • :lint:fix - Run ESLint and fix issues
  • :format:fix - Run Prettier and fix formatting issues
  • :ci - Run all checks (build, test, lint, format, tsCheck)

Each package can be targeted directly with moon [package]:task, for example:

bun moon dice:test    # Run tests for @randsum/dice only
bun moon blades:build # Build @randsum/blades only

Further Reading

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to your branch
  5. Open a Pull Request

Please read our Contributing Guidelines for more details.


Why did you make this?

Sometime around 2012, I decided I wanted to learn to program. I had installed ruby on the best laptop six-hundred dollars could buy, set to make a dice roller as an easy first project.

I spent an easy 30 minutes trying to figure out how to make rand(n) return 1...n instead of 0...(n-1).

When I found the answer, I laughed and laughed. I've been chasing that high ever since.


LLM Statement

I love this thing we call programming. It seems as if (biiiiig scare quotes) "AI" is going to be a part of it moving forward. You will find the extent of my comfort with these tools in this project, for it is the closest thing I have on this earth to a life's work, and programming is my craft. I care deeply about it, and there is no better way for me to understand LLM's and their place in my craft than to use them. There is no better place for me to use and understand them than here. We'll have to see the extent to which I come to regret/resent/respect this decision in the coming years together!


Made with 👹 by RANDSUM
0