Sha256: 0298953272b0aa8e0ffa414ceb9d8771b358c213213db720d6c66c8cb4bdd7eb

Contents?: true

Size: 921 Bytes

Versions: 3

Compression:

Stored size: 921 Bytes

Contents

require "games_dice/version"
require "games_dice/constants"
require "games_dice/probabilities"
require "games_dice/die"
require "games_dice/die_result"
require "games_dice/reroll_rule"
require "games_dice/map_rule"
require "games_dice/complex_die"
require "games_dice/bunch"
require "games_dice/dice"
require "games_dice/parser"

module GamesDice
  # @!visibility private
  @@parser = GamesDice::Parser.new

  # Creates an instance of GamesDice::Dice from a string description.
  # @param [String] dice_description Uses a variation of common game notation, examples: '1d6', '3d8+1d4+7', '5d10k2'
  # @param [#rand] prng Optional random number generator, default is to use Ruby's built-in #rand()
  # @return [GamesDice::Dice] A new dice object.
  #
  def self.create dice_description, prng = nil
    parsed = @@parser.parse( dice_description )
    GamesDice::Dice.new( parsed[:bunches], parsed[:offset], prng )
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
games_dice-0.2.4 lib/games_dice.rb
games_dice-0.2.3 lib/games_dice.rb
games_dice-0.2.2 lib/games_dice.rb