Giter Club home page Giter Club logo

rpg_tools's Introduction

rpg_tools Dependency Status

A gem that gives you tools for your RPGs : dices, coins and playing cards !

Usage

Coins

RpgTools::Coin.new

  • The flip method set its value to a heads or tails string.

Dices

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::Numerical
  • RpgTools::Dice::Fudge
  • RpgTools::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.

Dice Bags

RpgTools::Dice::Bag.new(arg) (arg is case insensitive).

  • It works the same way RpgTools.roll_dice does but will give you a RpgTools::Dice::Bag object 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.

Playing card deck

RpgTools::PlayingCardDeck.new(arg) (arg can only be 32 or 52).

  • The card method returns a card of a 32 or 52 cards deck + 2 jokers, depending of arg value.
  • The hand method return an array of 5 card calls.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

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.