Package body Rooms



with Text_IO, Ustrings;
use  Text_IO, Ustrings;

package body Rooms is

 procedure Connect(Source : access Room; Dir : in Direction; 
                   Destination : access Thing'Class;
                   Bidirectional : in Boolean := True) is
 begin
   Source.Destinations(Dir) := Destination;
   if Bidirectional then
     Room_Access(Destination).Destinations(Reverse_Direction(Dir)) := Source;
   end if;
 end Connect;

 procedure Disconnect(Source : access Room; Dir : in Direction; 
                      Bidirectional : in Boolean := True) is
 begin
   if Bidirectional then
     -- if (Source.Destinations(Dir).all'Tag in Room'Class) then
       Room_Access(Source.Destinations(Dir)).Destinations(Reverse_Direction(Dir)) := null;
     -- end if;
   end if;
   Source.Destinations(Dir) := null;
 end Disconnect;

 function What_Is(From : access Room; Dir : in Direction) return Thing_Access is
 begin
  return From.Destinations(Dir);
 end What_Is;

 procedure Put_View(T : access Room; Agent : access Thing'Class) is
 begin
  Put("You are ");
  Put(Long_Description(T));
  Put_Line(".");
  Put_Contents(T, Agent, "You see:");
 end Put_View;

end Rooms;






You may also see the corresponding specification. The following compilation units are referred to ("with"'ed) by Package body Rooms:

You may return to the Program Small Home Page

This hypertext format was generated by David A. Wheeler's ada2html