Class: BCDice::DiceTable::D66LeftRangeTable

Inherits:
D66Table
  • Object
show all
Defined in:
lib/bcdice/dice_table/d66_left_range_table.rb

Overview

左側(十の位)のみ Range を用いる D66 表

Instance Method Summary collapse

Methods inherited from D66Table

#choice, from_i18n, #roll

Constructor Details

#initialize(name, sort_type, items) ⇒ D66LeftRangeTable

Returns a new instance of D66LeftRangeTable.

Parameters:

  • name (String)

    表の名前

  • sort_type (Symbol)

    出目入れ替えの方式 BCDice::D66SortType

  • items (Array<(Range, Array<String>)>)

    表の項目の配列



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/bcdice/dice_table/d66_left_range_table.rb', line 12

def initialize(name, sort_type, items)
  expanded_items = {}
  items.each do |item|
    range, right_items = item

    range.each do |left_value|
      right_items.each_with_index do |right_item, right_value|
        key = left_value * 10 + (right_value + 1)
        expanded_items[key] = right_item
      end
    end
  end

  super(name, sort_type, expanded_items)
end