Class: BCDice::GameSystem::BeginningIdol::CostumeTable

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, items) ⇒ CostumeTable

Returns a new instance of CostumeTable.

Parameters:

  • name (String)
  • items (Hash{Integer => String})


14
15
16
17
# File 'lib/bcdice/game_system/beginning_idol/costume_table.rb', line 14

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

Class Method Details

.from_i18n(key, locale) ⇒ Object



7
8
9
10
# File 'lib/bcdice/game_system/beginning_idol/costume_table.rb', line 7

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

Instance Method Details

#brand_onlyDiceTable::D66Table

Returns:



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

def brand_only()
  DiceTable::D66Table.new(
    @name,
    D66SortType::ASC,
    @items.transform_values { |e| e.split("\n").first }
  )
end

#roll(randomizer) ⇒ String

Parameters:

Returns:

  • (String)


21
22
23
24
# File 'lib/bcdice/game_system/beginning_idol/costume_table.rb', line 21

def roll(randomizer)
  value = randomizer.roll_d66(D66SortType::ASC)
  "#{@name}(#{value}) > #{@items[value]}"
end