Module: Gamefic::World
- Defined in:
- lib/gamefic-standard/entities/room.rb
Instance Method Summary collapse
-
#connect(origin, destination, direction = nil, type: Portal, two_way: true) ⇒ Portal
Create portals between rooms.
Instance Method Details
#connect(origin, destination, direction = nil, type: Portal, two_way: true) ⇒ Portal
Create portals between rooms.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/gamefic-standard/entities/room.rb', line 38 def connect origin, destination, direction = nil, type: Portal, two_way: true if direction.nil? portal = make type, :parent => origin, :destination => destination if two_way == true portal2 = make type, :parent => destination, :destination => origin end else if direction.kind_of?(String) direction = Direction.find(direction) end portal = make type, :direction => direction, :parent => origin, :destination => destination portal.proper_named = true if type == Portal if two_way == true reverse = direction.reverse if reverse == nil raise "#{direction.name.cap_first} does not have an opposite direction" end portal2 = make type, :direction => reverse, :parent => destination, :destination => origin portal2.proper_named = true if type == Portal end end portal end |