Class: BCDice::GameSystem::BeginningIdol::D6TwiceTable

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, items1, items2) ⇒ D6TwiceTable

Returns a new instance of D6TwiceTable.

Parameters:

  • name (String)
  • items1 (Array<String>)
  • items2 (Array<String>)


18
19
20
21
22
# File 'lib/bcdice/game_system/beginning_idol/d6_twice_table.rb', line 18

def initialize(name, items1, items2)
  @name = name
  @items1 = items1
  @items2 = items2
end

Class Method Details

.from_i18n(key, locale) ⇒ D6TwiceTable

Parameters:

  • key (String)
  • locale (Symbol)

Returns:



10
11
12
13
# File 'lib/bcdice/game_system/beginning_idol/d6_twice_table.rb', line 10

def self.from_i18n(key, locale)
  table = I18n.t(key, locale: locale)
  new(table[:name], table[:items1], table[:items2])
end

Instance Method Details

#roll(randomizer) ⇒ String

Parameters:

Returns:

  • (String)


26
27
28
29
30
31
32
# File 'lib/bcdice/game_system/beginning_idol/d6_twice_table.rb', line 26

def roll(randomizer)
  value1, value2 = randomizer.roll_barabara(2, 6)
  chosen1 = @items1[value1 - 1]
  chosen2 = @items2[value2 - 1]

  "#{@name}[#{value1},#{value2}] > #{chosen1}#{chosen2}"
end