Class: BCDice::GameSystem::MeikyuKingdomBasic::ItemFeature

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

Instance Method Summary collapse

Constructor Details

#initialize(name, type, items) ⇒ ItemFeature

Returns a new instance of ItemFeature.



228
229
230
231
232
# File 'lib/bcdice/game_system/meikyu_kingdom_basic/item_table.rb', line 228

def initialize(name, type, items)
  @name = name
  @times, @sides = type.split("D", 2).map(&:to_i)
  @items = items
end

Instance Method Details

#choice(randomizer) ⇒ Object



234
235
236
237
238
239
240
241
242
# File 'lib/bcdice/game_system/meikyu_kingdom_basic/item_table.rb', line 234

def choice(randomizer)
  dice = randomizer.roll_sum(@times, @sides)
  index = dice - @times

  chosen = @items[index]
  chosen = chosen.choice(randomizer) if chosen.respond_to?(:choice)

  return "[#{dice}]#{chosen}"
end