Script Classes for Adventure Games/User Class
Author: Jeff Stephenson
The User Class
A User is an object which corresponds to the person playing the game and acts as the intermediary between the person and the other objects in the game. In the current games there is only one User, and thus we use the class User rather than an instance of the class.
alterEgoThe ID of the Ego which is controlled by the User.
canInputTRUE if the User should accept input lines from its player, FALSE otherwise. Any time you don't want the player to be able to type an input line, just set canInput to FALSE. Default at startup is FALSE.
canControlSet to TRUE to let the User control the alterEgo with direction keys, mouse, etc. Anytime you want to set the alterEgo on a pre- programmed motion, set canControl to FALSE to prevent the player from interrupting the motion and taking control. Default at startup is FALSE.
doit:The doit: method for User checks for an event. If one is present, User sends the handleEvent: event message in succession to TheMenuBar (the game's menu bar), alterEgo, and regions (the list of regions, beginning with the current room). If any of these objects respond to the event, they should set the claimed property of the event to TRUE to let the other objects receiving the event know that it has been dealt with. If, after everyone has had a look at it, the event is still unclaimed, User puts up an input line and waits for the player to type a line of input. If a line is entered and the kernel is able to parse the line, the User turns the event into a saidEvent, indicating that valid input has been entered, and again sends the handleEvent: event message to the above objects. Once it has done so, it disposes of the event and returns.