! -------------------------------------------------------------------------
! entrypts.inf -- A component of the Inform Port of Ditch Day Drifter
!
! This file contains the source for the optional entry points that are
! defined for Ditch Day Drifter.
! -------------------------------------------------------------------------
! -------------------------------------------------------------------------
!
! -- Table of Contents --
!
! ENTRY POINTS (8)
!   AfterPrompt (8.1)
!   ChooseObjects (8.2)
!   InScope (8.3)
!   Initialise (8.4)
!   PrintRank (8.5)
!   PrintVerb (8.6)
!
! -------------------------------------------------------------------------

! (8) ENTRY POINTS

! (8.1)
! AfterPrompt is an excellent place to do things which must be done at the
! very end of every turn.
[ AfterPrompt;
  buy_obj=0;
];

! (8.2)
Constant FORCE_INCLUSION 1;
Constant FORCE_EXCLUSION 2;
Constant AGREE 0;
Constant EXCLUDING 0;
Constant INCLUDING 1;
Constant SCORING 2;

[ ChooseObjects obj code 
  ret_value;

  switch (code) {
    EXCLUDING: 
       ! Include objects on supporters in 'all'.
       if (obj hasnt concealed && parent(obj) has supporter)
         ret_value=FORCE_INCLUSION;
       else 
         ret_value=AGREE;
    INCLUDING: 
       ! Exclude scenery, concealed, and animate objects from 'all'.
       if (obj has scenery or animate or concealed)
         ret_value=FORCE_EXCLUSION; 
       else 
         ret_value=AGREE;

    ! Help resolve ambiguous inputs. Note that it can only be helpful for
    ! actions without indirect objects. This is because you can't
    ! distinguish between direct and indirect objects with ChooseObjects.
    ! However, the noun=Routine grammar token can be used for that purpose
    ! (see "verbs.inf").

    SCORING: 
      ! Scores range from 0 to 9. Higher scoring objects are given
      ! preference over lower scoring objects.
      switch (action_to_be) {
        ##Take:
          if (obj notin player) ret_value=3;
        ##Eat:
          if (obj has edible) ret_value=3;
        ! ##Open will prefer doors and containers, and will further
        ! prefer openable ones, and still further prefer closed doors.
        ##Open:
          if (obj has door or container) {
            if (obj has open) ret_value=1;
            else ret_value=5;
          }
          else ret_value=2;
          if (obj has openable) ret_value++;
          if (obj has door) ret_value++;
        ! Parallel rules for ##Close.
        ##Close: 
          if (obj has door or container) {
            if (obj has open) ret_value=5;
            else ret_value=1;
          }
          else ret_value=2;
          if (obj has openable) ret_value++;
          if (obj has door) ret_value++;
        default:
          ret_value=2;
      }
  }
  return ret_value;
];

! (8.3)
! I wanted the player to be able to hear Lloyd in the dark. In stock Inform
! the react_before routines of objects are not called in the dark.
! 
! Important: You must return false from the InScope library entry point or
! nothing further will be in scope.
[ InScope;
  if (scope_reason==REACT_BEFORE_REASON && 
      location==thedark && parent(lloyd)==parent(player))
    PlaceInScope(lloyd);
  rfalse;
];

! (8.4)
! This is the only mandatory entry point in Inform, and the only mandatory
! thing it does is set the initial location for the game. It is traditional
! to put the opening "hook" message here.
[ Initialise;
  location=RoomThree; ! "surface.inf":1.1
  player=person;      ! "misc.inf":12.1
  thedark.description="It is pitch black.";

  ! Since automatic pronoun assignment is turned off in this game, set it
  ! to something appropriate to start with.
  SetPronoun('it', waste_basket);

  print "^^^^You wake up to the sound of voices in the hall. You are 
    confused for a moment; it's only 8 AM, far too early for anyone to be
    getting up. Then it dawns on you: it's Ditch Day here at the
    fictitious California Institute of Technology, in the mythical city of
    Pasadena, California. Ditch Day, that strange tradition wherein seniors
    bar their doors with various devices and underclassmen attempt to
    defeat these devices (for no other apparent reason than that the
    devices are there) has arrived.^^";
];
  
! (8.5)
[ PrintRank;
  print ", earning you a rank of ";
  if (score >=80) "graduate.";
  if (score > 60) "senior.";
  if (score > 40) "junior.";
  if (score > 25) "sophomore.";
  if (score > 10) "freshman.";
  "high-school hopeful.";
];

! (8.6)
! The single word "hello" needs to be refered to correctly by the library
! as the verb, "say hello".
[ PrintVerb vb;
  if (vb == 'hello' or 'hi' or 'greetings' or 'salutations') {
    print "say ";
    switch (vb) {
      'hello', 'hi', 'greetings': print (address) vb;
      ! This word is too long to print using (address).
      'salutations': print "salutations";
    }
    rtrue;
  }
  rfalse;
];