Class: BCDice::GameSystem::BeginningIdol::RandomEventTable

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

Instance Method Summary collapse

Constructor Details

#initialize(locale) ⇒ MySkillNameTable

Parameters:

  • locale (Symbol)


9
10
11
# File 'lib/bcdice/game_system/beginning_idol/random_event_table.rb', line 9

def initialize(locale)
  @locale = locale
end

Instance Method Details

#roll(randomizer) ⇒ String

Parameters:

Returns:

  • (String)


15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/bcdice/game_system/beginning_idol/random_event_table.rb', line 15

def roll(randomizer)
  first_index = randomizer.roll_once(6)
  d66_index = randomizer.roll_d66(D66SortType::NO_SORT)

  i18n_key = first_index.even? ? "BeginningIdol.RE.on_event" : "BeginningIdol.RE.off_event"
  table = I18n.t(i18n_key, locale: @locale)
  name = I18n.t("BeginningIdol.RE.name", locale: @locale)
  result_format = I18n.t("BeginningIdol.RE.format", locale: @locale)

  chosen = table[:items][d66_index]

  return "#{name} > (1D6) > #{first_index}\n#{table[:name]} > [#{d66_index}] > #{format(result_format, event: chosen[0], page: chosen[1])}"
end