Class: BCDice::GameSystem::BeginningIdol::ChainD66Table

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

Instance Method Summary collapse

Constructor Details

#initialize(name, items) ⇒ ChainD66Table

Returns a new instance of ChainD66Table.

Parameters:

  • name (String)

    表の名前

  • items (Array<Array<String, #roll>>)

    表の項目の配列



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

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

Instance Method Details

#roll(randomizer) ⇒ String

表を振る

Parameters:

  • randomizer (#roll_sum)

    ランダマイザ

Returns:

  • (String)

    結果



17
18
19
20
21
22
23
24
25
# File 'lib/bcdice/game_system/beginning_idol/chain_d66_table.rb', line 17

def roll(randomizer)
  dice = randomizer.roll_barabara(2, 6).sort

  value = dice[0] * 10 + dice[1]
  chosen = @items[value]
  body = chosen.map { |item| item.respond_to?(:roll) ? item.roll(randomizer) : item }.join("\n")

  return "#{@name}(#{value}) > #{body}"
end