Sha256: d01706dca591dd5b6804e889916eadce4c59eb1640bff2c9a9c1df44fde2a39a

Contents?: true

Size: 1013 Bytes

Versions: 3

Compression:

Stored size: 1013 Bytes

Contents

require "games_dice/version"
begin
  require "games_dice/games_dice"
rescue LoadError
  require "games_dice/probabilities"
end
require "games_dice/constants"
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"
require "games_dice/marshal"

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.3.10 lib/games_dice.rb
games_dice-0.3.9 lib/games_dice.rb
games_dice-0.3.8 lib/games_dice.rb