Class: BCDice::GameSystem::BeginningIdol::BadStatusTable
- Inherits:
-
Object
- Object
- BCDice::GameSystem::BeginningIdol::BadStatusTable
- Defined in:
- lib/bcdice/game_system/beginning_idol/bad_status_table.rb
Instance Method Summary collapse
-
#initialize(locale) ⇒ BadStatusTable
constructor
A new instance of BadStatusTable.
- #roll(randomizer, roll_counts = 1) ⇒ Object
- #roll_command(randomizer, command) ⇒ Object
Constructor Details
#initialize(locale) ⇒ BadStatusTable
Returns a new instance of BadStatusTable.
7 8 9 |
# File 'lib/bcdice/game_system/beginning_idol/bad_status_table.rb', line 7 def initialize(locale) @locale = locale end |
Instance Method Details
#roll(randomizer, roll_counts = 1) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bcdice/game_system/beginning_idol/bad_status_table.rb', line 23 def roll(randomizer, roll_counts = 1) if roll_counts <= 0 return nil end name = I18n.t("BeginningIdol.BT.name", locale: @locale) items = I18n.t("BeginningIdol.BT.items", locale: @locale) prefix_format = I18n.t("BeginningIdol.BT.prefix_format", locale: @locale) dice_list = randomizer.(roll_counts, 6).sort index_list = dice_list.uniq result_prefix = format(prefix_format, count_bad_status: index_list.size) + "\n" if index_list.size > 1 result_text = index_list.map { |i| items[i - 1] }.join("\n") return "#{name} > [#{dice_list.join(',')}] > #{result_prefix}#{result_text}" end |
#roll_command(randomizer, command) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/bcdice/game_system/beginning_idol/bad_status_table.rb', line 11 def roll_command(randomizer, command) m = /^BT(\d+)?$/.match(command) unless m return nil end roll_counts = m[1]&.to_i || 1 return roll(randomizer, roll_counts) end |