lib/t10/dungeon/traversable.rb
# Method adds the origin door to the room (receiver) based on the provided
# crest from the origin room (parameter). The method is called in
# {Traversable#connect_to}.
#
# The method raises an exception if the room first gets an origin door
# before the origin room adds the room to the @door. This prevents from
# the room having an origin door to a room which do not have the reference
# to that room (in case the origin room has it slots full with other rooms
# for example).
#
# If the origin room is not provided the method samples a direction
# from list and setups the internal orientation based on that. Otherwise
# it will use the crest from the origin room leading to room (receiver).
#
# @param origin_room [Room] The room that leads to receiver.
# @param crest_to_room [Symbol] The external orientation leading to
#                               receiver.
# @raise [StandardError] if the origin room doesn't lead to the receiver.
# @return [Room] the receiver.
Method adds the origin door to the room (receiver) based on the provided
crest from the origin room (parameter). The method is called in
{Traversable#connect_to}.

The method raises an exception if the room first gets an origin door
before the origin room adds the room to the @door. This prevents from
the room having an origin door to a room which do not have the reference
to that room (in case the origin room has it slots full with other rooms
for example).

If the origin room is not provided the method samples a direction
from list and setups the internal orientation based on that. Otherwise
it will use the crest from the origin room leading to room (receiver).
Method adds the origin door to the room ( receiver ) based on the provided crest from the origin room ( parameter ) . The method is called in { Traversable#connect_to } . The method raises an exception if the room first gets an origin door before the origin room adds the room to the @door . This prevents from the room having an origin door to a room which do not have the reference to that room ( in case the origin room has it slots full with other rooms for example ) . If the origin room is not provided the method samples a direction from list and setups the internal orientation based on that . Otherwise it will use the crest from the origin room leading to room ( receiver ) .
def add_origin_door(origin_room, crest_to_room)
        if origin_room && !crest_to_room
          fail StandardError,
               "#{origin_room} should lead to this (#{self.class} room) " \
               "before #{self.class} can lead to #{origin_room}"
        end
        case crest_to_room
        when :east
          @doors = {
            east:  @doors[:east].push(:ahead, nil),
            south: @doors[:south].push(:to_right, nil),
            west:   @doors[:west].push(:origin, origin_room),
            north:  @doors[:north].push(:to_left, nil)
          }
        when :south
          @doors = {
            east:  @doors[:east].push(:to_left, nil),
            south: @doors[:south].push(:ahead, nil),
            west:   @doors[:west].push(:to_right, nil),
            north:  @doors[:north].push(:origin, origin_room)
          }
        when :west
          @doors = {
            east:  @doors[:east].push(:origin, origin_room),
            south: @doors[:south].push(:to_left, nil),
            west:   @doors[:west].push(:ahead, nil),
            north:  @doors[:north].push(:to_right, nil)
          }
        when :north
          @doors = {
            east:  @doors[:east].push(:to_right, nil),
            south: @doors[:south].push(:origin, origin_room),
            west:   @doors[:west].push(:to_left, nil),
            north:  @doors[:north].push(:ahead, nil)
          }
        end
        self
      end
def add_origin_door ( origin_room , crest_to_room ) if origin_room && ! crest_to_room fail StandardError , "#{origin_room} should lead to this (#{self.class} room) " "before #{self.class} can lead to #{origin_room}" end case crest_to_room when :east @doors = { east : @doors [ :east ] . push ( :ahead , nil ) , south : @doors [ :south ] . push ( :to_right , nil ) , west : @doors [ :west ] . push ( :origin , origin_room ) , north : @doors [ :north ] . push ( :to_left , nil ) } when :south @doors = { east : @doors [ :east ] . push ( :to_left , nil ) , south : @doors [ :south ] . push ( :ahead , nil ) , west : @doors [ :west ] . push ( :to_right , nil ) , north : @doors [ :north ] . push ( :origin , origin_room ) } when :west @doors = { east : @doors [ :east ] . push ( :origin , origin_room ) , south : @doors [ :south ] . push ( :to_left , nil ) , west : @doors [ :west ] . push ( :ahead , nil ) , north : @doors [ :north ] . push ( :to_right , nil ) } when :north @doors = { east : @doors [ :east ] . push ( :to_right , nil ) , south : @doors [ :south ] . push ( :origin , origin_room ) , west : @doors [ :west ] . push ( :to_left , nil ) , north : @doors [ :north ] . push ( :ahead , nil ) } end self end
Method adds the origin door to the room (receiver) based on the provided
crest from the origin room (parameter).
Method adds the origin door to the room ( receiver ) based on the provided crest from the origin room ( parameter ) .
None
Room
[StandardError] if the origin room doesn't lead to the receiver.
[ StandardError ] if the origin room doesn ' t lead to the receiver .
origin_room
The room that leads to receiver.
The room that leads to receiver .
crest_to_room
The external orientation leading to receiver.
The external orientation leading to receiver .