class Portal

Attributes

destination[RW]

@return [Gamefic::Entity]

direction[R]

Get the ordinal direction of this Portal Portals have distinct direction and name properties so games can display a bare compass direction for exits, e.g., “south” vs. “the southern door.”

A portal's destination can also be nil, in which case it can be referenced in commands by its destination, e.g., “go to the house.”

@return [Direction, nil]

Public Instance Methods

direction=(dir) click to toggle source
# File lib/gamefic-standard/entities/portal.rb, line 26
def direction= dir
  @direction = Direction.find(dir)
end
find_reverse()
Alias for: reverse
instruction() click to toggle source
# File lib/gamefic-standard/entities/portal.rb, line 34
def instruction
  direction || (destination ? "to #{destination.definitely}" : name)
end
name() click to toggle source
# File lib/gamefic-standard/entities/portal.rb, line 30
def name
  @name || (direction.nil? ? destination.name : direction.name)
end
reverse() click to toggle source

Find the portal in the destination that returns to this portal's parent

@return [Room, nil]

# File lib/gamefic-standard/entities/portal.rb, line 18
def reverse
  return nil if destination.nil?
  destination.children.that_are(Portal).find do |portal|
    portal.destination == parent
  end
end
Also aliased as: find_reverse
synonyms() click to toggle source
# File lib/gamefic-standard/entities/portal.rb, line 38
def synonyms
  "#{super} #{@destination} #{@direction} #{!direction.nil? ? direction.synonyms : ''}"
end