A gem that gives you tools for your RPGs : dices, coins and playing cards !
RpgTools::Coin.new
- The
flipmethod set its value to aheadsortailsstring.
RpgTools.roll_dice(arg) (arg is case insensitive).
This returns a plain integer result based on the arg parameter.
-
It can be a stardard dice like
"1dX"for a X sided dice. -
It can be a fudge dice
"df": a three sided dice (-1, 0, +1). -
It can also be a percentile dice
"d%": a ten sided dice (from 10 to 100).
You can also add multiple chained modifiers like "+X", "-X", "*X" or "/X", to alter the roll result. RpgTools.roll_dice("4d6+2") will create 4 6-sided dices, roll them and add 2 to the sum of the roll result.
You can also manipulate all those dice types as objects :
RpgTools::Dice::NumericalRpgTools::Dice::FudgeRpgTools::Dice::Percentile
All those classes take two args: a mandatory side number and an optional modifier.
They respond to the .roll or .roll! methods to update their value to the result of the roll.
RpgTools::Dice::Numerical.new(6, '+4').roll will roll a six sided dice and add 4 to the roll result.
RpgTools::Dice::Bag.new(arg) (arg is case insensitive).
- It works the same way
RpgTools.roll_dicedoes but will give you aRpgTools::Dice::Bagobject instead of a plain integer.RpgTools::Dice::Bag.new("4d6-2")will create a bag of four 6 sided dices with a -2 modifier to the sum of all rolls.
RpgTools::PlayingCardDeck.new(arg) (arg can only be 32 or 52).
- The
cardmethod returns a card of a 32 or 52 cards deck + 2 jokers, depending ofargvalue. - The
handmethod return an array of 5cardcalls.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Added some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request