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.



144
145
146
147
# File 'lib/bcdice/game_system/Warhammer4.rb', line 144

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

Instance Method Details

#roll(randomizer, under_ganken_bonus) ⇒ Object



149
150
151
152
153
154
155
156
157
158
# File 'lib/bcdice/game_system/Warhammer4.rb', line 149

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