class BCDice::GameSystem::Yggdrasill::YggTable
Public Class Methods
new(name, type, items, additonal_type:, additonal_format:, additonal_index:, out_of_control: nil)
click to toggle source
Calls superclass method
BCDice::DiceTable::Table::new
# File lib/bcdice/game_system/Yggdrasill.rb, line 297 def initialize(name, type, items, additonal_type:, additonal_format:, additonal_index:, out_of_control: nil) super(name, type, items) m = /(\d+)D(\d+)/i.match(additonal_type) unless m raise ArgumentError, "Unexpected table type: #{additonal_type}" end @additonal_times = m[1].to_i @additonal_sides = m[2].to_i @format = additonal_format @index = additonal_index @out_of_control = out_of_control end
Public Instance Methods
roll(randomizer)
click to toggle source
# File lib/bcdice/game_system/Yggdrasill.rb, line 312 def roll(randomizer) value = randomizer.roll_sum(@times, @sides) chosen = choice(value) return chosen unless @index.include?(value) || @out_of_control == value body = if @out_of_control == value "#{chosen.body} : #{RA90.roll(randomizer)}" else list = randomizer.roll_barabara(@additonal_times, @additonal_sides) chosen.body + format(@format, total: list.sum(), list: list.join(",")) end DiceTable::RollResult.new(chosen.table_name, chosen.value, body) end