Git Product home page Git Product logo

roll's Introduction

Roll Go Report Card License GoDoc Build Status

A simple dice roll parsing engine that (mostly) supports the Roll20 Dice Rolling Language Specification

Usage

package main

import (
	"fmt"
	"math/rand"
	"os"
	"time"

	"github.com/darkliquid/roll"
)

func main() {
	rand.Seed(time.Now().UnixNano())
	out, err := roll.Parse(os.Stdin)
	if err != nil {
		fmt.Fprintln(os.Stderr, err)
		return
	}
	fmt.Println(out)
}

then run echo '3d6+1' | go run main.go to get some output like:

Rolled "3d6+1" and got 6, 6, 4 for a total of 17

roll's People

Contributors

darkliquid avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

roll's Issues

Ability to limit die sizes and recursion

At the moment, there is zero protection against silly die sizes or infinite recursion. This means you can roll a 1d1!, which will explode forever, or do silly sided dice like d100000000000000000000000 which, while nice to support, would be nicer if you could restrict it.

It'd also be nice to restrict the total number of dice rolled in complex rolls that make use of multiple dice, or exploding rolls.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.