module RoomContent

Constants

CONTENT_DESC_EMPTY
CONTENT_DESC_MONSTERS_CLEARED
CONTENT_DESC_TRAP_CLEARED

Attributes

encounters_difficulty[RW]
party_levels[RW]

Public Instance Methods

clear() click to toggle source
# File lib/rooms/room_content.rb, line 25
def clear
  case @content
    when 'T'
      @content = nil
      @content_description = CONTENT_DESC_TRAP_CLEARED
    when 'M'
      @content = nil
      @content_description = CONTENT_DESC_MONSTERS_CLEARED
  end
end
set_entry_room() click to toggle source
# File lib/rooms/room_content.rb, line 14
def set_entry_room
  @entry_room = true
  @content = 'E'
  @content_description = 'This room is the entry room.'
end
set_treasure_room() click to toggle source
# File lib/rooms/room_content.rb, line 20
def set_treasure_room
  @content = 'H'
  @content_description = 'The treasure, you find it.'
end

Private Instance Methods

create_decorations() click to toggle source
# File lib/rooms/room_content.rb, line 53
def create_decorations
  roll = Hazard.d6
  create_four_columns if roll >= 5
end
create_encounters( lair ) click to toggle source
# File lib/rooms/room_content.rb, line 38
def create_encounters( lair )
  @content_description = CONTENT_DESC_EMPTY
  roll = Hazard.d6
  generate_trap if roll == 1
  generate_monster( lair ) if roll > 1 && roll < 6
end
create_four_columns() click to toggle source
# File lib/rooms/room_content.rb, line 58
def create_four_columns
  near = (Room::ROOM_SQUARE_SIZE/8.0).ceil
  distant = Room::ROOM_SQUARE_SIZE-[ (Room::ROOM_SQUARE_SIZE/8.0).ceil*2, 3 ].max

  column_1 = { top: near, left: near }
  column_2 = { top: near, left: distant }
  column_3 = { top: distant, left: near }
  column_4 = { top: distant, left: distant }

  @decorations << { decoration_type: :four_columns, decoration_data: [ column_1, column_2, column_3, column_4 ] }
end
generate_monster( lair ) click to toggle source
# File lib/rooms/room_content.rb, line 70
def generate_monster( lair )
  @content = 'M'
  @content_description = lair.encounter.to_s + '.'
end
load_decoration_from_json( decorations_types ) click to toggle source
# File lib/rooms/room_content.rb, line 45
def load_decoration_from_json( decorations_types )
  decorations_types.each do |decoration_type|
    if decoration_type == 'four_columns'
      create_four_columns
    end
  end
end