Project

easy_dice

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Gem for rolling polyhedral dice.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 4.3
~> 10.1
~> 0.7
 Project Readme

easy_dice Build Status Gem Version

A super simple gem for rolling polyhedral dice with ruby.

I wrote this when learning how to develop a rubygem.

todo

  • help-output for roll executable
  • rdoc
  • add support for the SW dice system (Edge of the Empire, Age of Rebellion)

usage

ruby

include the gem in your project with require 'easy_dice'

  1. easy_dice will parse dice formatted as Strings
irb> d = EasyDice.read("1d6 + 8")
 => #<Die:0x00 ... >
irb> d.roll
 => 10
  1. you can throw straight ruby at easy_dice too
irb> d = 2.d(8) + 1.d(6) + 12
 => #<Die:0x00 ... >
irb> d.roll
 => 28
irb> (12.d(6) + 10).roll
 => 61
  1. easy_dice can give you a little bit of miscellaneous information
irb> d = 1.d(6) + 1.d(8)
 => #<Die:0x00 ... >
irb> d.min # what's the smallest number that can be rolled?
 => 2
irb> d.max # what's the largest number that can be rolled?
 => 14
irb > puts d # "i forgot what dice i was going to roll"
1d6 + 1d8
 => nil

bash

$ roll 1d8 + 1d6 + 8
16

help me help you

If you've come across a bug or error in easy_dice, please submit a Github issue describing the problem, and what version of easy_dice you're using.