Class: GothamDice

Inherits:
ParaDice::Bag show all
Defined in:
lib/gotham_dice.rb

Overview

Another example of creating a custom set of dice

Constant Summary collapse

DATA_FILE_NAME =

path to yml file

'data/gotham_dice.yml'
OPPOSING =

which faces are considered opposing, and thus cancel out in CancelOpposing

readers
[
    ['blank', 'blank'],
    ['pow', 'antipow'],
    ['clue', 'anticlue'],
    ['move', 'antimove'],
]
DEFAULT_READERS =

The Readers to use in order, in this case, use ‘_’ to split face names

(allowing single faces with multiple results), then cancel all of the
opposing results, then present the results as a frequency hash
[
    ParaDice::Results::SplitFaces.new('_'),
    ParaDice::Results::CancelOpposing.new(OPPOSING),
    ParaDice::Results::Hash
]

Instance Attribute Summary collapse

Attributes inherited from ParaDice::Bag

#name, #rng

Class Method Summary collapse

Methods inherited from ParaDice::Bag

#add_die, #get_cup, #get_dice

Instance Attribute Details

#default_readersArray<#resolve>

Returns , defaults to DEFAULT_READERS.

Returns:

  • (Array<#resolve>)

    , defaults to DEFAULT_READERS



36
# File 'lib/gotham_dice.rb', line 36

attribute :default_readers, Array, default: ->(*a) { DEFAULT_READERS }

#diceHash<String,Paradise::StringDie]

Returns Hash<String,Paradise::StringDie].

Returns:

  • (Hash<String,Paradise::StringDie])

    Hash<String,Paradise::StringDie]



# File 'lib/gotham_dice.rb', line 32

Class Method Details

.get(rng = nil) ⇒ GothamDice

simple way to get a bag of dice with optional rng

Returns:



40
41
42
43
# File 'lib/gotham_dice.rb', line 40

def self.get(rng = nil)
  hash = YAML.load_file(DATA_FILE_NAME)
  self.new(name: 'Gotham Dice', dice: hash, rng: rng)
end