ParaDice Gem Version

Build Status Dependency Status PullReview stats Inline docs

An extensible dice gem.

Introduction

ParaDice is a ruby library that provides a customizable dice system made of 4 component. Dice, Bags, Cups, and Readers. Dice is pretty obvious. Cups are a group of dice ready to roll and read the result. Bags are a container that keep track of dice and creates cups. Finally the readers are used to take raw results and produce final results with.

Installation

Add this line to your application's Gemfile:

gem 'para_dice'

And then execute:

$ bundle

Or install it yourself as:

$ gem install para_dice

Usage

require 'para_dice'

# Create a simple die
coin = ParaDice::StringDie.new(faces: ['heads','tails'], name: 'coin')
coin.roll # => 'heads' or 'tails'

# Use a set of polyhedral dice
bag = ParaDice::PolyBag.new
#   Get a dice cup to roll 3 d6 in this case
cup = bag.take_cup([:d6, :d6, :d6])
# use roll to roll the dice and read the results
cup.roll # 10
#use roll! to roll the dice and return raw values
cup.roll! # [4, 2, 4]

Contributing

  1. Fork it ( https://github.com/anithri/para_dice/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request