class ParaDice::Cup
A Cup
hold a selection of dice and a selection of readers. It’s main purpose
is to provide a reusable component that you can call #roll on and get a complex result from
Public Instance Methods
roll(roll_rng = rng)
click to toggle source
roll reach die in cup and call each reader in turn on the results, return
the result of the last reader
@param [Random,#rand] roll_rng default: self.rng
# File lib/para_dice/cup.rb, line 25 def roll(roll_rng = rng) readers.reduce(roll!(roll_rng)) { |faces, reader| reader.resolve(faces) } end
roll!(roll_rng = rng)
click to toggle source
roll each die in cup using roll_rng and return array of raw results from @param [Random,#rand] roll_rng default: self.rng
# File lib/para_dice/cup.rb, line 31 def roll!(roll_rng = rng) dice.map { |d| d.roll(roll_rng) } end