Class: BCDice::GameSystem::Yggdrasill::ChainTable
- Inherits:
-
DiceTable::Table
- Object
- DiceTable::Table
- BCDice::GameSystem::Yggdrasill::ChainTable
- Defined in:
- lib/bcdice/game_system/Yggdrasill.rb
Instance Method Summary collapse
-
#initialize(name, type, items, additonal_table:, additonal_index:) ⇒ ChainTable
constructor
A new instance of ChainTable.
- #roll(randomizer) ⇒ Object
Methods inherited from DiceTable::Table
Constructor Details
#initialize(name, type, items, additonal_table:, additonal_index:) ⇒ ChainTable
Returns a new instance of ChainTable.
331 332 333 334 335 336 |
# File 'lib/bcdice/game_system/Yggdrasill.rb', line 331 def initialize(name, type, items, additonal_table:, additonal_index:) super(name, type, items) @additonal_table = additonal_table @index = additonal_index end |
Instance Method Details
#roll(randomizer) ⇒ Object
338 339 340 341 342 343 344 345 346 |
# File 'lib/bcdice/game_system/Yggdrasill.rb', line 338 def roll(randomizer) value = randomizer.roll_sum(@times, @sides) chosen = choice(value) return chosen unless @index.include?(value) body = "#{chosen.body} > #{@additonal_table.roll(randomizer)}" DiceTable::RollResult.new(chosen.table_name, chosen.value, body) end |