Class: BCDice::GameSystem::MagicaLogia::SkillExpandTable

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, items, skill_table) ⇒ SkillExpandTable

Returns a new instance of SkillExpandTable.



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/bcdice/game_system/MagicaLogia.rb', line 103

def initialize(name, type, items, skill_table)
  @name = name
  @items = items.freeze
  @skill_table = skill_table

  m = /(\d+)D(\d+)/i.match(type)
  unless m
    raise ArgumentError, "Unexpected table type: #{type}"
  end

  @times = m[1].to_i
  @sides = m[2].to_i
end

Class Method Details

.from_i18n(key, locale, skill_table) ⇒ Object



98
99
100
101
# File 'lib/bcdice/game_system/MagicaLogia.rb', line 98

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

Instance Method Details

#roll(randomizer) ⇒ Object



117
118
119
120
121
122
# File 'lib/bcdice/game_system/MagicaLogia.rb', line 117

def roll(randomizer)
  value = randomizer.roll_sum(@times, @sides)
  text = expand(@items[value - @times], randomizer)

  return DiceTable::RollResult.new(@name, value, text)
end