Class: BCDice::GameSystem::DeadlineHeroes::HeroNameBaseChart

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

Instance Method Summary collapse

Constructor Details

#initialize(name, items) ⇒ HeroNameBaseChart

Returns a new instance of HeroNameBaseChart.



326
327
328
329
# File 'lib/bcdice/game_system/DeadlineHeroes.rb', line 326

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

Instance Method Details

#roll(randomizer) ⇒ Array<(String, String)>

Parameters:

Returns:

  • (Array<(String, String)>)


333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/bcdice/game_system/DeadlineHeroes.rb', line 333

def roll(randomizer)
  dice = randomizer.roll_once(10)
  chosen = @items[dice - 1]

  result = "#{@name}(#{dice}) > #{chosen}"
  if (m = chosen.match(/^[(.+)]$/))
    element_type = m[1]
    element_chart = HERO_NAME_ELEMENT_CHARTS[element_type]

    element_result, chosen = element_chart.roll(randomizer)
    result = [result, element_result].join("")
  end

  return result, chosen
end