Class: BCDice::GameSystem::BeginningIdol::SkillGetTable
- Inherits:
-
DiceTable::Table
- Object
- DiceTable::Table
- BCDice::GameSystem::BeginningIdol::SkillGetTable
- Defined in:
- lib/bcdice/game_system/beginning_idol/skill_table.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, type, items, skill_table, locale) ⇒ SkillGetTable
constructor
A new instance of SkillGetTable.
- #roll(randomizer) ⇒ Object
Methods inherited from DiceTable::Table
Constructor Details
#initialize(name, type, items, skill_table, locale) ⇒ SkillGetTable
Returns a new instance of SkillGetTable.
18 19 20 21 22 23 24 25 26 |
# File 'lib/bcdice/game_system/beginning_idol/skill_table.rb', line 18 def initialize(name, type, items, skill_table, locale) super(name, type, items) @skill_table = skill_table skill_get_table = I18n.t("BeginningIdol.skill_get_table", locale: locale) @reroll_reg = Regexp.new(skill_get_table[:reroll_reg]) @reroll = skill_get_table[:reroll] @secondary_name = skill_get_table[:secondary_name] end |
Class Method Details
.from_i18n(key, skill_table, locale) ⇒ Object
13 14 15 16 |
# File 'lib/bcdice/game_system/beginning_idol/skill_table.rb', line 13 def self.from_i18n(key, skill_table, locale) table = I18n.t(key, locale: locale) new(table[:name], table[:type], table[:items], skill_table, locale) end |
Instance Method Details
#roll(randomizer) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/bcdice/game_system/beginning_idol/skill_table.rb', line 28 def roll(randomizer) chosen = super(randomizer) m = @reroll_reg.match(chosen.body) unless m return chosen end reroll_category = m.captures body = chosen.body + "\n" loop do skill = @skill_table.roll_skill(randomizer) body += "#{@secondary_name} > [#{skill.category_dice},#{skill.row_dice}] > #{skill}" unless reroll_category.include?(skill.category_name) break end body += " > #{@reroll}\n" end DiceTable::RollResult.new(chosen.table_name, chosen.value, body) end |