home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LANGUAGE / ADA / LOVELACE / world.adb < prev    next >
Text File  |  1996-03-01  |  2KB  |  70 lines

  1. --
  2. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  3. -- Author: David A. Wheeler
  4. --
  5.  
  6. with Text_IO, Ada.Strings.Unbounded, Ustrings;
  7. use  Text_IO, Ada.Strings.Unbounded, Ustrings;
  8.  
  9. with Things, Players, Items, Rooms, Directions;
  10. use  Things, Players, Items, Rooms, Directions;
  11.  
  12. package body World is
  13.  
  14.  The_Player : Player_Access;    -- This is the object representing the
  15.                                 -- current player.
  16.  
  17.  
  18.  procedure Setup is
  19.    Starting_Room : Room_Access := new Room;
  20.    Box           : Item_Access := new Item;
  21.    Knife         : Item_Access := new Item;
  22.    Living_Room   : Room_Access := new Room;
  23.  begin
  24.    Set_Name(Starting_Room, The, "Hallway");
  25.    Set_Description(Starting_Room, "in the hallway. There is a living room " &
  26.                    "to the west");
  27.  
  28.    Set_Name(Box, A, "box");
  29.    Set_Description(Box, "a red box");
  30.    Place(T => Box, Into => Thing_Access(Starting_Room));
  31.  
  32.    Set_Name(Knife, A, "knife");
  33.    Set_Description(Box, "a black knife");
  34.    Place(T => Knife, Into => Thing_Access(Starting_Room));
  35.  
  36.    Set_Name(Living_Room, The, "Living Room");
  37.    Set_Description(Living_Room, "in the living room. " &
  38.                                 "A hallway is to your east");
  39.    Connect(Starting_Room, West, Living_Room);
  40.  
  41.    -- Setup player.
  42.    The_Player := new Player; 
  43.    Set_Name(The_Player, None, "Fred");
  44.    Set_Description(The_Player, Name(The_Player));
  45.    Place(T => Me,  Into => Thing_Access(Starting_Room));
  46.    Look(Me);
  47.  
  48.  end Setup;
  49.  
  50.  
  51.  function Me return Occupant_Access is
  52.   -- Return access value to current player.
  53.  begin
  54.   return Occupant_Access(The_Player);
  55.  end Me;
  56.  
  57. end World;
  58.  
  59. --
  60. -- Permission to use, copy, modify, and distribute this software and its
  61. -- documentation for any purpose and without fee is hereby granted,
  62. -- provided that the above copyright and authorship notice appear in all
  63. -- copies and that both that copyright notice and this permission notice
  64. -- appear in supporting documentation.
  65. -- 
  66. -- The ARA makes no representations about the suitability of this software
  67. -- for any purpose.  It is provided "as is" without express
  68. -- or implied warranty.
  69. -- 
  70.