home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / docs / lovelace / world.adb < prev    next >
Encoding:
Text File  |  1995-10-25  |  1.5 KB  |  55 lines

  1.  
  2. with Text_IO, Ada.Strings.Unbounded, Ustrings;
  3. use  Text_IO, Ada.Strings.Unbounded, Ustrings;
  4.  
  5. with Things, Players, Items, Rooms, Directions;
  6. use  Things, Players, Items, Rooms, Directions;
  7.  
  8. package body World is
  9.  
  10.  The_Player : Player_Access;    -- This is the object representing the
  11.                                 -- current player.
  12.  
  13.  
  14.  procedure Setup is
  15.    Starting_Room : Room_Access := new Room;
  16.    Box           : Item_Access := new Item;
  17.    Knife         : Item_Access := new Item;
  18.    Living_Room   : Room_Access := new Room;
  19.  begin
  20.    Set_Name(Starting_Room, The, "Hallway");
  21.    Set_Description(Starting_Room, "in the hallway. There is a living room " &
  22.                    "to the west");
  23.  
  24.    Set_Name(Box, A, "box");
  25.    Set_Description(Box, "a red box");
  26.    Place(T => Box, Into => Thing_Access(Starting_Room));
  27.  
  28.    Set_Name(Knife, A, "knife");
  29.    Set_Description(Box, "a black knife");
  30.    Place(T => Knife, Into => Thing_Access(Starting_Room));
  31.  
  32.    Set_Name(Living_Room, The, "Living Room");
  33.    Set_Description(Living_Room, "in the living room. " &
  34.                                 "A hallway is to your east");
  35.    Connect(Starting_Room, West, Living_Room);
  36.  
  37.    -- Setup player.
  38.    The_Player := new Player; 
  39.    Set_Name(The_Player, None, "Fred");
  40.    Set_Description(The_Player, Name(The_Player));
  41.    Place(T => Me,  Into => Thing_Access(Starting_Room));
  42.    Look(Me);
  43.  
  44.  end Setup;
  45.  
  46.  
  47.  function Me return Occupant_Access is
  48.   -- Return access value to current player.
  49.  begin
  50.   return Occupant_Access(The_Player);
  51.  end Me;
  52.  
  53. end World;
  54.  
  55.