Class: BCDice::GameSystem::Warhammer4::CriticalTable

Inherits:
Object
  • Object
show all
Defined in:
lib/bcdice/game_system/Warhammer4.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, items) ⇒ CriticalTable

Returns a new instance of CriticalTable.



126
127
128
129
# File 'lib/bcdice/game_system/Warhammer4.rb', line 126

def initialize(name, items)
  @name = name
  @items = items
end

Instance Method Details

#roll(randomizer, under_ganken_bonus) ⇒ Object



131
132
133
134
135
136
137
138
139
140
# File 'lib/bcdice/game_system/Warhammer4.rb', line 131

def roll(randomizer, under_ganken_bonus)
  dice = randomizer.roll_once(100)
  if under_ganken_bonus
    dice = (dice - 20).clamp(1, 100)
  end

  chosen = @items.find { |key, _| key >= dice }[1]

  "#{@name}(#{dice}) > #{chosen}"
end