Sha256: ef907b76277782b9213e9a55ef25eff7a291626a83a86cc3eb05e91ea824edea

Contents?: true

Size: 763 Bytes

Versions: 4

Compression:

Stored size: 763 Bytes

Contents

module Degica
  class Door
    include Actionable
    include Collectable

    attr_reader :description

    def initialize(room1, room2)
      @description = DoorNameGenerator.sample
      @rooms = [room1, room2]

      # connect rooms
      room1.doors << self
      room2.doors << self
    end

    def actions
      [Action.new(:enter, self), Action.new(:open, self)]
    end

    def open
      Game.objects.actor.focus = self
      "You opened the door. Try to (enter) it.".highlight
    end

    def enter
      next_room = (@rooms - [Game.objects.actor.location])[0]
      Game.objects.actor.location = next_room
      next_room.generate!
      next_room
    end

    def describe
      @description
    end

    def prompt
      "door"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
degica-1.0.3 lib/degica/door.rb
degica-1.0.2 lib/degica/door.rb
degica-1.0.1 lib/degica/door.rb
degica-1.0.0 lib/degica/door.rb