Skip to content

Latest commit

 

History

History
67 lines (46 loc) · 1.69 KB

README.md

File metadata and controls

67 lines (46 loc) · 1.69 KB

Rubydice

Rubydice is a simple and flexible dice implementation to simulate tabletop dice.

Installation

In most cases its more aestetically pleasing to call Dice rather than Rubydice, and simply adding require: 'dice' to your Gemfile will make this happen.

gem 'rubydice', require: 'dice'

If you already have a Dice object you can simply leave out require: 'dice' and call methods on Rubydice instead.

Usage

Rubydice will accept, parse, and roll for any standard string indicating quanity, die, and modifier. Die type is limited to standard RPG dice variants 2, 3, 4, 6, 8, 10, 12, 20, 32, 36, and 100.

In the simplest case simply call the Dice.roll with:

 Dice.roll('3d6+1')

If you can parse and setup any dice confirguation for repeated rolls using the same configuration like:

stat_dice = Dice.parse('1D20')
stat1 = stat_dice.roll
stat2 = stat_dice.roll

Options

A number of options are supported to allow common use cases supported by different game systems.

best

Take the best n dice from the dice rolled

Dice.roll('4d6', best: 3)

worst

Take the worst n dice from the dice rolled

Dice.roll('4d6', worst: 3)

reroll

Reroll any dice with a value of 1

Dice.roll('1d20', reroll: 1)

explode

Any dice with this value get an accumulating reroll

Dice.roll('4d10', explode: 10)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/atavistock/rubydice. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.