Sha256: d2bcc7ee4084476db8583b2f743dcd8d605d84d0cedffb34a678f77d5a8bd7d5
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true # An entity that provides access from one room to another. # class Portal < Thing # @return [Gamefic::Entity] attr_accessor :destination # 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] attr_reader :direction # Find the portal in the destination that returns to this portal's parent # # @return [Room, nil] def reverse return nil if destination.nil? destination.children.that_are(Portal).find do |portal| portal.destination == parent end end alias find_reverse reverse def direction=(dir) @direction = Direction.find(dir) end def name @name || direction&.name || destination.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-3.3.0 | lib/gamefic-standard/entities/portal.rb |