Class: BCDice::DiceTable::D66GridTable
- Inherits:
-
Object
- Object
- BCDice::DiceTable::D66GridTable
- Defined in:
- lib/bcdice/dice_table/d66_grid_table.rb
Overview
D66を振って6x6マスの表を参照する
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, items) ⇒ D66GridTable
constructor
A new instance of D66GridTable.
-
#roll(randomizer) ⇒ String
表を振る.
Constructor Details
#initialize(name, items) ⇒ D66GridTable
Returns a new instance of D66GridTable.
17 18 19 20 |
# File 'lib/bcdice/dice_table/d66_grid_table.rb', line 17 def initialize(name, items) @name = name @items = items.freeze end |
Class Method Details
.from_i18n(key, locale) ⇒ D66GridTable
10 11 12 13 |
# File 'lib/bcdice/dice_table/d66_grid_table.rb', line 10 def self.from_i18n(key, locale) table = I18n.t(key, locale: locale, raise: true) new(table[:name], table[:items]) end |
Instance Method Details
#roll(randomizer) ⇒ String
表を振る
25 26 27 28 29 30 31 32 33 |
# File 'lib/bcdice/dice_table/d66_grid_table.rb', line 25 def roll(randomizer) dice1 = randomizer.roll_once(6) dice2 = randomizer.roll_once(6) value = dice1 * 10 + dice2 index1 = dice1 - 1 index2 = dice2 - 1 return RollResult.new(@name, value, @items[index1][index2]) end |