Class: StarWarsDice

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

Overview

Note:

no claim is made for the name StarWarsDice

A class for representing the game dice from Star Wars: Edge of the Empire,

Star Wars: Age of Rebellion, Star Wars: Force and Destiny.  Mostly here as
an example of how to create a custom dice bag.

Constant Summary collapse

DATA_FILE_NAME =

yaml file containing dice definitions

'data/star_wars_dice.yml'
OPPOSING =

opposite facing to be used by the reader CancelOpposing

[
    ['blank', 'blank'],
    ['success', 'failure'],
    ['advantage', 'threat']
]
DEFAULT_READERS =

The normal reader order for StarWarsDice. First split the face names using

'_', then cancel opposing faces, finally return as a 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:

  • (Array<#resolve>)


34
# File 'lib/star_wars_dice.rb', line 34

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

#diceHash<String,StringDie>

Returns:

  • (Hash<String,StringDie>)


# File 'lib/star_wars_dice.rb', line 31

Class Method Details

.getObject

load and return a bag of StarWarsDice



37
38
39
40
# File 'lib/star_wars_dice.rb', line 37

def self.get
  hash = YAML.load_file(DATA_FILE_NAME)
  self.new(name: 'Star Wars Dice', dice: hash)
end