Class: BCDice::GameSystem::OneWayHeroics::DungeonTable
- Inherits:
-
Object
- Object
- BCDice::GameSystem::OneWayHeroics::DungeonTable
- Defined in:
- lib/bcdice/game_system/one_way_heroics/dungeon_table.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(name, key, type, items) ⇒ DungeonTable
constructor
A new instance of DungeonTable.
- #roll_with_day(day, randomizer) ⇒ Object
Constructor Details
#initialize(name, key, type, items) ⇒ DungeonTable
Returns a new instance of DungeonTable.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bcdice/game_system/one_way_heroics/dungeon_table.rb', line 9 def initialize(name, key, type, items) @name = name @key = key @items = items.freeze 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 |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/bcdice/game_system/one_way_heroics/dungeon_table.rb', line 7 def key @key end |
Instance Method Details
#roll_with_day(day, randomizer) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/bcdice/game_system/one_way_heroics/dungeon_table.rb', line 23 def roll_with_day(day, randomizer) value = randomizer.roll_sum(@times, @sides) value += @times if day >= 4 index = value - @times return "#{@name}(#{value}) > #{@items[index]}" end |