class CoopAl::AdventureGenerator

AdventureGenerator

Attributes

adventure[R]

Public Class Methods

new(name, description, bestiary) click to toggle source
# File lib/coop_al/adventure_generator.rb, line 8
def initialize(name, description, bestiary)
  initialize_adventure(name, description)
  @bestiary = bestiary
end

Public Instance Methods

chapter(name, description, &blk) click to toggle source
# File lib/coop_al/adventure_generator.rb, line 17
def chapter(name, description, &blk)
  generator = ChapterGenerator.new(name, description, @adventure, @bestiary)
  generator.instance_eval(&blk)
  @adventure.add_chapter(generator.chapter)
end
entry(name) click to toggle source
# File lib/coop_al/adventure_generator.rb, line 13
def entry(name)
  @adventure.add_entry(name)
end

Private Instance Methods

initialize_adventure(name, description) click to toggle source
# File lib/coop_al/adventure_generator.rb, line 25
def initialize_adventure(name, description)
  if Library.instance.adventure?(name)
    @adventure = Library.instance.adventure(name)
  else
    raise "Description required for adventure (#{name})" if description.nil?
    @adventure = Adventure.new(name, description)
    Library.instance.add_adventure(@adventure)
  end
end