Sha256: 4beb250548d2d4f5998b975fd63d1953dfcc814b3d3c8f1149e1ced20539f7e8
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
class Portal < Thing attr_accessor :destination # Find the portal in the destination that returns to this portal's parent # # @return [Room] def find_reverse return nil if destination.nil? rev = direction.reverse if rev != nil destination.children.that_are(Portal).each { |c| if c.direction == rev return c end } end nil end # 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." # # @return [Direction] def direction @direction end def direction= d @direction = Direction.find(d) end def name @name || (direction.nil? ? destination.name : direction.name) end def instruction direction || (destination ? "to #{destination.definitely}" : name) end def synonyms "#{super} #{@destination} #{@direction} #{!direction.nil? ? direction.synonyms : ''}" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gamefic-standard-2.0.0 | lib/gamefic-standard/entities/portal.rb |